Skip to content

[flang][openacc] Allow scalar in acc cache directive #70713

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

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions flang/docs/OpenACC.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ local:
* The `if` clause accepts scalar integer expression in addition to scalar
logical expression.
* `!$acc routine` directive can be placed at the top level.
* `!$acc cache` directive accepts scalar variable.
5 changes: 4 additions & 1 deletion flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,10 @@ static bool IsLastNameArray(const parser::Designator &designator) {
const evaluate::DataRef dataRef{*(name.symbol)};
return common::visit(
common::visitors{
[](const evaluate::SymbolRef &ref) { return ref->Rank() > 0; },
[](const evaluate::SymbolRef &ref) {
return ref->Rank() > 0 ||
ref->GetType()->category() == DeclTypeSpec::Numeric;
},
[](const evaluate::ArrayRef &aref) {
return aref.base().IsSymbol() ||
aref.base().GetComponent().base().Rank() == 0;
Expand Down
8 changes: 2 additions & 6 deletions flang/test/Semantics/OpenACC/acc-cache-validity.f90
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,11 @@ program openacc_cache_validity
!$acc cache(t%arr)
!$acc cache(ta(1:2)%arr)
!$acc cache(ta(1:2)%arr(1:4))

!ERROR: Only array element or subarray are allowed in CACHE directive
!$acc cache(ta(1:2)%s)

!ERROR: Only array element or subarray are allowed in CACHE directive
!$acc cache(i)
!$acc cache(t%s)

!ERROR: Only array element or subarray are allowed in CACHE directive
!$acc cache(t%s)
!$acc cache(t)

!ERROR: Only array element or subarray are allowed in CACHE directive
!$acc cache(/i/)
Expand Down