diff options
author | Peter Klausler <pklausler@nvidia.com> | 2025-05-12 12:15:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-12 12:15:46 -0700 |
commit | 5b9bd8838842896b482fea20dce56906d42cc7b1 (patch) | |
tree | f8ba7e29f466583c8e69b02fa5a9390f8ea3da9d /flang/lib/Semantics/mod-file.cpp | |
parent | ea87d7c0dbceaf21ddbd53d261600ca5e3aeddd7 (diff) | |
download | llvm-5b9bd8838842896b482fea20dce56906d42cc7b1.zip llvm-5b9bd8838842896b482fea20dce56906d42cc7b1.tar.gz llvm-5b9bd8838842896b482fea20dce56906d42cc7b1.tar.bz2 |
[flang] Fix crash with USE of hermetic module file (#138785)
When one hermetic module file uses another, a later compilation may
crash in semantics when it itself is used, since the module file reader
sets the "current hermetic module file scope" to null after reading one
rather than saving and restoring that pointer.
Diffstat (limited to 'flang/lib/Semantics/mod-file.cpp')
-rw-r--r-- | flang/lib/Semantics/mod-file.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp index 3ea37ce..a1ec956 100644 --- a/flang/lib/Semantics/mod-file.cpp +++ b/flang/lib/Semantics/mod-file.cpp @@ -1548,6 +1548,7 @@ Scope *ModFileReader::Read(SourceName name, std::optional<bool> isIntrinsic, // created under -fhermetic-module-files? If so, process them first in // their own nested scope that will be visible only to USE statements // within the module file. + Scope *previousHermetic{context_.currentHermeticModuleFileScope()}; if (parseTree.v.size() > 1) { parser::Program hermeticModules{std::move(parseTree.v)}; parseTree.v.emplace_back(std::move(hermeticModules.v.front())); @@ -1563,7 +1564,7 @@ Scope *ModFileReader::Read(SourceName name, std::optional<bool> isIntrinsic, GetModuleDependences(context_.moduleDependences(), sourceFile->content()); ResolveNames(context_, parseTree, topScope); context_.foldingContext().set_moduleFileName(wasModuleFileName); - context_.set_currentHermeticModuleFileScope(nullptr); + context_.set_currentHermeticModuleFileScope(previousHermetic); if (!moduleSymbol) { // Submodule symbols' storage are owned by their parents' scopes, // but their names are not in their parents' dictionaries -- we |