-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[flang][OpenACC] Relax COMMON block usage restriction in OpenACC directives #162659
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
base: main
Are you sure you want to change the base?
Changes from 8 commits
042d2f6
f31c976
931b300
0bfb06c
86cb8b6
f462bf5
14ce6b6
8c344c3
e00d8f5
827f8f0
430660f
ff637dd
9e19979
66028ef
41336f1
eac75b7
553a3c3
63662d8
adcd69b
74de636
6527159
c042379
740894f
ca82173
2474da0
68363d2
5c84d48
cc4145c
06b2a01
8f802f7
b711009
ee0cdde
5349a65
b268f4e
6c8e7a0
bab4e67
ab01526
f2028c7
258050f
adf6b5f
86dc6a7
acde775
abd2f40
fc6beb7
19c1534
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
for (const Scope &childScope : context_.globalScope().children()) { | ||
if (childScope.kind() == Scope::Kind::Module) { | ||
if (auto *cb{childScope.FindCommonBlock(name->source)}) { | ||
name->symbol = cb; | ||
return cb; | ||
} | ||
} | ||
} | ||
return nullptr; | ||
} | ||
|
@@ -1755,8 +1761,8 @@ void AccAttributeVisitor::ResolveAccObject( | |
} | ||
} else { | ||
context_.Say(name.source, | ||
"COMMON block must be declared in the same scoping unit " | ||
"in which the OpenACC directive or clause appears"_err_en_US); | ||
"Could not find COMMON block '%s' used in OpenACC directive"_err_en_US, | ||
name.ToString()); | ||
} | ||
}, | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
! RUN: %python %S/../test_errors.py %s %flang -fopenacc | ||
module acc_common_decl | ||
implicit none | ||
integer a | ||
common /a_common/ a | ||
!$acc declare create (/a_common/) | ||
data a/42/ | ||
end module acc_common_decl | ||
|
||
program acc_decl_test | ||
use acc_common_decl | ||
implicit none | ||
|
||
a = 1 | ||
!$acc update device (/a_common/) | ||
a = 2 | ||
!ERROR: Could not find COMMON block 'a_common_bad' used in OpenACC directive | ||
!$acc update device (/a_common_bad/) | ||
end program |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be more clear as
if (name) { ...
, I think.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.