From ba6266c1934654a9f3cd43b7212cf332b17ccf98 Mon Sep 17 00:00:00 2001 From: Eugene Epshteyn Date: Fri, 12 Sep 2025 12:35:25 -0400 Subject: [PATCH 1/2] [flang] Fix COMMON block lookup for ACC Do COMMON block lookups for ACC similarly to how OpenMP does it (see 5198923c70bb5b91b07e15ce141339d778322635). --- flang/lib/Semantics/resolve-directives.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp index 16b895d8259dd..eb74da5916420 100644 --- a/flang/lib/Semantics/resolve-directives.cpp +++ b/flang/lib/Semantics/resolve-directives.cpp @@ -1649,17 +1649,13 @@ void AccAttributeVisitor::Post(const parser::Name &name) { Symbol *AccAttributeVisitor::ResolveAccCommonBlockName( const parser::Name *name) { - if (auto *prev{name - ? GetContext().scope.parent().FindCommonBlock(name->source) - : nullptr}) { - name->symbol = prev; - return prev; + if (!name) { + return nullptr; } - // Check if the Common Block is declared in the current scope - if (auto *commonBlockSymbol{ - name ? GetContext().scope.FindCommonBlock(name->source) : nullptr}) { - name->symbol = commonBlockSymbol; - return commonBlockSymbol; + if (auto *cb{GetProgramUnitOrBlockConstructContaining(GetContext().scope) + .FindCommonBlock(name->source)}) { + name->symbol = cb; + return cb; } return nullptr; } From 81a7b384d32ed42e0475f8be94af4c0be91cb757 Mon Sep 17 00:00:00 2001 From: Eugene Epshteyn Date: Fri, 12 Sep 2025 12:38:02 -0400 Subject: [PATCH 2/2] clang-format --- flang/lib/Semantics/resolve-directives.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp index eb74da5916420..a6eecd18867da 100644 --- a/flang/lib/Semantics/resolve-directives.cpp +++ b/flang/lib/Semantics/resolve-directives.cpp @@ -1653,7 +1653,7 @@ Symbol *AccAttributeVisitor::ResolveAccCommonBlockName( return nullptr; } if (auto *cb{GetProgramUnitOrBlockConstructContaining(GetContext().scope) - .FindCommonBlock(name->source)}) { + .FindCommonBlock(name->source)}) { name->symbol = cb; return cb; }