Skip to content

Commit 86cb8b6

Browse files
Searching for COMMON definition in top level modules
1 parent 0bfb06c commit 86cb8b6

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,15 +1698,18 @@ Symbol *AccAttributeVisitor::ResolveAccCommonBlockName(
16981698
if (!name) {
16991699
return nullptr;
17001700
}
1701+
// Check the local and surrounding scopes first
17011702
if (auto *cb{GetProgramUnitOrBlockConstructContaining(GetContext().scope)
17021703
.FindCommonBlock(name->source)}) {
17031704
name->symbol = cb;
17041705
return cb;
17051706
}
1706-
if (auto *cb{GetContext().scope.FindSymbol(name->source)}) {
1707-
if (auto *sym{&cb->GetUltimate()}; sym && sym->has<CommonBlockDetails>()) {
1708-
name->symbol = sym;
1709-
return sym;
1707+
// Look for COMMON block in the modules
1708+
for (const Scope &childScope : context_.globalScope().children()) {
1709+
if (childScope.kind() == Scope::Kind::Module) {
1710+
auto *cb{childScope.FindCommonBlock(name->source)};
1711+
name->symbol = cb;
1712+
return cb;
17101713
}
17111714
}
17121715
return nullptr;
@@ -1757,8 +1760,8 @@ void AccAttributeVisitor::ResolveAccObject(
17571760
}
17581761
} else {
17591762
context_.Say(name.source,
1760-
"COMMON block must be declared in the same scoping unit "
1761-
"in which the OpenACC directive or clause appears"_err_en_US);
1763+
"Could not find COMMON block '%s' used in OpenACC directive"_err_en_US,
1764+
name.ToString());
17621765
}
17631766
},
17641767
},

0 commit comments

Comments
 (0)