Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[flang] Fix crash with USE of hermetic module file #138785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion 3 flang/lib/Semantics/mod-file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,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()));
Expand All @@ -1552,7 +1553,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
Expand Down
17 changes: 17 additions & 0 deletions 17 flang/test/Semantics/modfile75.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
!RUN: %flang -c -fhermetic-module-files -DWHICH=1 %s && %flang -c -fhermetic-module-files -DWHICH=2 %s && %flang_fc1 -fdebug-unparse %s | FileCheck %s

#if WHICH == 1
module modfile75a
use iso_c_binding
end
#elif WHICH == 2
module modfile75b
use modfile75a
end
#else
program test
use modfile75b
!CHECK: INTEGER(KIND=4_4) n
integer(c_int) n
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is broken here. See buildbots "flang/test/Semantics/modfile75.F90:15:11: error: Must be a constant value".

I am thinking this could be a lit "race" with module file (I am not sure, but I think all the tests are ran in the same directory in parallel, which would cause the issue since m1 are common names and could be overridden before the final part of the test).

end
#endif
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.