diff --git a/compiler/AST/ModuleSymbol.cpp b/compiler/AST/ModuleSymbol.cpp index df4b57f9ebb3..27a3447c0e3b 100644 --- a/compiler/AST/ModuleSymbol.cpp +++ b/compiler/AST/ModuleSymbol.cpp @@ -630,16 +630,8 @@ void ModuleSymbol::addDefaultUses() { if (parentModule->modTag != MOD_USER) { SET_LINENO(this); - UnresolvedSymExpr* modRef; - - // If this is a Fortran compilation, we need to use ISO_Fortran_binding - if (fLibraryFortran) { - modRef = new UnresolvedSymExpr("ISO_Fortran_binding"); - block->insertAtHead(new UseStmt(modRef, false)); - } - - modRef = new UnresolvedSymExpr("ChapelStandard"); - block->insertAtHead(new UseStmt(modRef, false)); + UnresolvedSymExpr* modRef = new UnresolvedSymExpr("ChapelStandard"); + block->insertAtHead(new UseStmt(modRef, /* isPrivate */ true)); } // We don't currently have a good way to fetch the root module by name. @@ -649,6 +641,15 @@ void ModuleSymbol::addDefaultUses() { block->useListAdd(rootModule, false); } + + if (fLibraryFortran && modTag == MOD_INTERNAL) { + if (this == standardModule) { + SET_LINENO(this); + + UnresolvedSymExpr* modRef = new UnresolvedSymExpr("ISO_Fortran_binding"); + block->insertAtTail(new UseStmt(modRef, /* isPrivate */ false)); + } + } } // Helper function for computing the index in the module use list diff --git a/modules/internal/CPtr.chpl b/modules/internal/CPtr.chpl index b187b499a50c..d37ac36b7cf6 100644 --- a/modules/internal/CPtr.chpl +++ b/modules/internal/CPtr.chpl @@ -26,6 +26,7 @@ */ module CPtr { use ChapelStandard; + private use SysBasic, SysError; /* A Chapel version of a C NULL pointer. */ inline proc c_nil:c_void_ptr { diff --git a/modules/internal/ChapelDistribution.chpl b/modules/internal/ChapelDistribution.chpl index 8178512e6b0d..856e5efef9c9 100644 --- a/modules/internal/ChapelDistribution.chpl +++ b/modules/internal/ChapelDistribution.chpl @@ -19,6 +19,7 @@ module ChapelDistribution { + private use ChapelArray, ChapelLocks, ChapelRange; use LinkedLists; // diff --git a/modules/internal/ChapelRange.chpl b/modules/internal/ChapelRange.chpl index 3d2f2105f4b9..ceea79c1407f 100644 --- a/modules/internal/ChapelRange.chpl +++ b/modules/internal/ChapelRange.chpl @@ -152,6 +152,8 @@ */ module ChapelRange { + private use ChapelBase, SysBasic; + use Math; // Turns on range iterator debugging. diff --git a/modules/internal/ChapelStandard.chpl b/modules/internal/ChapelStandard.chpl index 7b52f0b539fe..5874346560ca 100644 --- a/modules/internal/ChapelStandard.chpl +++ b/modules/internal/ChapelStandard.chpl @@ -72,6 +72,8 @@ module ChapelStandard { use HaltWrappers only ; use Types; use Math; + use SysBasic; + use SysError; use stopInitCommDiags; // Internal, but uses standard/CommDiagnostics } diff --git a/modules/internal/DefaultAssociative.chpl b/modules/internal/DefaultAssociative.chpl index 9d45ce4bbb61..67c9bff536b6 100644 --- a/modules/internal/DefaultAssociative.chpl +++ b/modules/internal/DefaultAssociative.chpl @@ -23,6 +23,8 @@ pragma "unsafe" // workaround for trying to default-initialize nil objects module DefaultAssociative { use DSIUtil; + private use ChapelDistribution, ChapelRange, SysBasic, ChapelArray; + private use ChapelBase, ChapelLocks, IO; config param debugDefaultAssoc = false; config param debugAssocDataPar = false; diff --git a/modules/internal/DefaultRectangular.chpl b/modules/internal/DefaultRectangular.chpl index 7a8b9224a5b7..ef390dd8fc2b 100644 --- a/modules/internal/DefaultRectangular.chpl +++ b/modules/internal/DefaultRectangular.chpl @@ -28,6 +28,9 @@ module DefaultRectangular { if dataParMinGranularity<=0 then halt("dataParMinGranularity must be > 0"); use DSIUtil, ChapelArray; + private use ChapelDistribution, ChapelRange, SysBasic, SysError; + private use ChapelDebugPrint, ChapelLocks, OwnedObject, IO; + private use DefaultSparse, DefaultAssociative, DefaultOpaque; use ExternalArray; config param debugDefaultDist = false; diff --git a/modules/internal/ISO_Fortran_binding.chpl b/modules/internal/ISO_Fortran_binding.chpl index 42b0fd470716..8e4538e09c8a 100644 --- a/modules/internal/ISO_Fortran_binding.chpl +++ b/modules/internal/ISO_Fortran_binding.chpl @@ -21,6 +21,7 @@ // jupiter:/opt/intel/compilers_and_libraries_2019.0.117/linux/compiler/include/ISO_Fortran_binding.h module ISO_Fortran_binding { use SysCTypes; + private use ChapelRange, CPtr; require "chpl-ISO_Fortran_binding.h"; diff --git a/modules/internal/String.chpl b/modules/internal/String.chpl index 3840ec54e2e0..c4c420dceda1 100644 --- a/modules/internal/String.chpl +++ b/modules/internal/String.chpl @@ -136,6 +136,7 @@ module String { use CString; use SysCTypes; use StringCasts; + private use SysBasic; // Growth factor to use when extending the buffer for appends private config param chpl_stringGrowthFactor = 1.5; diff --git a/test/modules/bradc/printModStuff/foo.good b/test/modules/bradc/printModStuff/foo.good index 1203dc27a6da..c5ced9ad9a46 100644 --- a/test/modules/bradc/printModStuff/foo.good +++ b/test/modules/bradc/printModStuff/foo.good @@ -25,18 +25,18 @@ Parsing module files: $CHPL_HOME/modules/standard/HaltWrappers.chpl $CHPL_HOME/modules/standard/Types.chpl $CHPL_HOME/modules/standard/Math.chpl + $CHPL_HOME/modules/standard/SysBasic.chpl + $CHPL_HOME/modules/standard/SysError.chpl $CHPL_HOME/modules/standard/CommDiagnostics.chpl $CHPL_HOME/modules/standard/Reflection.chpl $CHPL_HOME/modules/standard/gen/.../SysCTypes.chpl $CHPL_HOME/modules/dists/DSIUtil.chpl + $CHPL_HOME/modules/standard/IO.chpl $CHPL_HOME/modules/packages/RangeChunk.chpl $CHPL_HOME/modules/packages/Sort.chpl $CHPL_HOME/modules/standard/LinkedLists.chpl - $CHPL_HOME/modules/standard/SysBasic.chpl - $CHPL_HOME/modules/standard/IO.chpl $CHPL_HOME/modules/packages/Search.chpl $CHPL_HOME/modules/standard/Sys.chpl - $CHPL_HOME/modules/standard/SysError.chpl $CHPL_HOME/modules/standard/Regexp.chpl In bar In baz diff --git a/test/modules/sungeun/init/printModuleInitOrder.good b/test/modules/sungeun/init/printModuleInitOrder.good index 8ad0ac8ec5dc..8ce602e6675f 100644 --- a/test/modules/sungeun/init/printModuleInitOrder.good +++ b/test/modules/sungeun/init/printModuleInitOrder.good @@ -1,10 +1,12 @@ Initializing Modules: ChapelStandard CPtr + SysBasic + SysCTypes + SysError HaltWrappers CString String - SysCTypes StringCasts OwnedObject ChapelDebugPrint @@ -25,23 +27,31 @@ Initializing Modules: DSIUtil ChapelArray Sort + MSBRadixSort + RadixSortHelp + ShellSort + QuickSort + InsertionSort + BubbleSort + HeapSort + BinaryInsertionSort + MergeSort + SelectionSort + ChapelDistribution + LinkedLists + IO + FormattedIO + Regexp + DefaultAssociative ExternalArray RangeChunk ChapelNumLocales Sys - SysBasic LocaleModelHelpRuntime LocaleModelHelpMem LocalesArray - ChapelDistribution - LinkedLists ChapelIO - IO - SysError - FormattedIO - Regexp LocaleTree - DefaultAssociative ChapelTaskTable MemTracking ChapelUtil diff --git a/test/modules/sungeun/init/printModuleInitOrder.na-none.good b/test/modules/sungeun/init/printModuleInitOrder.na-none.good index 13adebaf1aa0..89fd4c710b76 100644 --- a/test/modules/sungeun/init/printModuleInitOrder.na-none.good +++ b/test/modules/sungeun/init/printModuleInitOrder.na-none.good @@ -1,10 +1,12 @@ Initializing Modules: ChapelStandard CPtr + SysBasic + SysCTypes + SysError HaltWrappers CString String - SysCTypes StringCasts OwnedObject ChapelDebugPrint @@ -34,23 +36,21 @@ Initializing Modules: BinaryInsertionSort MergeSort SelectionSort + ChapelDistribution + LinkedLists + IO + FormattedIO + Regexp + DefaultAssociative ExternalArray RangeChunk ChapelNumLocales Sys - SysBasic LocaleModelHelpRuntime LocaleModelHelpMem LocalesArray - ChapelDistribution - LinkedLists ChapelIO - IO - SysError - FormattedIO - Regexp LocaleTree - DefaultAssociative ChapelTaskTable MemTracking ChapelUtil diff --git a/test/modules/use/usePollutesDueToChplStandard.bad b/test/modules/use/usePollutesDueToChplStandard.bad deleted file mode 100644 index 863473b5bfe3..000000000000 --- a/test/modules/use/usePollutesDueToChplStandard.bad +++ /dev/null @@ -1 +0,0 @@ -usePollutesDueToChplStandard.chpl:9: error: unresolved access of 'real(64)' by '[1]' diff --git a/test/modules/use/usePollutesDueToChplStandard.future b/test/modules/use/usePollutesDueToChplStandard.future deleted file mode 100644 index 8530187e9221..000000000000 --- a/test/modules/use/usePollutesDueToChplStandard.future +++ /dev/null @@ -1,9 +0,0 @@ -bug: 'use ChapelStandard' needs to be private / non-transitive - -This test demonstrates that because of the 'use ChapelStandard' -injected by the Chapel compiler to get automatically-included modules, -a module that looks completely innocuous like `Library` here can -eclipse user-level variables inadvertantly. I believe the fix here is -to implement `private` (non-transitive) `use` statements (issue #6093) -and then to have the compiler-injected `use ChapelStandard` be a -`private use`. diff --git a/test/modules/vass/deinit-order-modules.verbose.good b/test/modules/vass/deinit-order-modules.verbose.good index 5809287a2edd..f6d9eb6b4fda 100644 --- a/test/modules/vass/deinit-order-modules.verbose.good +++ b/test/modules/vass/deinit-order-modules.verbose.good @@ -27,10 +27,10 @@ UM4explicitDeinit.deinit user uv4ae.deinit UC MemTracking LocaleTree - IO LocalesArray LocaleModel DefaultRectangular + IO ChapelArray Sort ChapelLocale