Skip to content

Commit ba6266c

Browse files
[flang] Fix COMMON block lookup for ACC
Do COMMON block lookups for ACC similarly to how OpenMP does it (see 5198923).
1 parent 40d8af8 commit ba6266c

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,17 +1649,13 @@ void AccAttributeVisitor::Post(const parser::Name &name) {
16491649

16501650
Symbol *AccAttributeVisitor::ResolveAccCommonBlockName(
16511651
const parser::Name *name) {
1652-
if (auto *prev{name
1653-
? GetContext().scope.parent().FindCommonBlock(name->source)
1654-
: nullptr}) {
1655-
name->symbol = prev;
1656-
return prev;
1652+
if (!name) {
1653+
return nullptr;
16571654
}
1658-
// Check if the Common Block is declared in the current scope
1659-
if (auto *commonBlockSymbol{
1660-
name ? GetContext().scope.FindCommonBlock(name->source) : nullptr}) {
1661-
name->symbol = commonBlockSymbol;
1662-
return commonBlockSymbol;
1655+
if (auto *cb{GetProgramUnitOrBlockConstructContaining(GetContext().scope)
1656+
.FindCommonBlock(name->source)}) {
1657+
name->symbol = cb;
1658+
return cb;
16631659
}
16641660
return nullptr;
16651661
}

0 commit comments

Comments
 (0)