[flang-commits] [flang] [flang][OpenACC] Relax COMMON block usage restriction in OpenACC directives (PR #162659)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Thu Oct 9 15:18:03 PDT 2025
================
@@ -1695,17 +1695,23 @@ 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;
- }
- // 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 (!name) {
+ return nullptr;
+ }
+ // Check the local and surrounding scopes first
+ if (auto *cb{GetProgramUnitOrBlockConstructContaining(GetContext().scope)
+ .FindCommonBlock(name->source)}) {
+ name->symbol = cb;
+ return cb;
+ }
+ // Look for COMMON block in the modules
----------------
eugeneepshteyn wrote:
It would have been very convenient to have a USE-associated common block available, but I don't see one created. With this program
```
module acc_decl
implicit none
integer a
common /a_common/ a
!$acc declare create (/a_common/)
data a/42/
end module acc_decl
program acc_decl_test
use acc_decl
implicit none
a = 1
!$acc update device (/a_common/)
a = 2
end program
```
... and `-fdebug-dump-symbols` I only see
```
MainProgram scope: ACC_DECL_TEST size=0 alignment=1 sourceRange=72 bytes
a (InDataStmt, InCommonBlock): Use from a in acc_decl
```
Perhaps this is the problem? Perhaps we should be creating USE-associated symbol from its use in `!$acc update device (/a_common/)`?
https://github.com/llvm/llvm-project/pull/162659
More information about the flang-commits
mailing list