Skip to content

Commit 72d8e47

Browse files
authored
[flang][openacc] Allow scalar in acc cache directive (llvm#70713)
1 parent b096b8b commit 72d8e47

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

flang/docs/OpenACC.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ local:
2424
* The `if` clause accepts scalar integer expression in addition to scalar
2525
logical expression.
2626
* `!$acc routine` directive can be placed at the top level.
27+
* `!$acc cache` directive accepts scalar variable.

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,10 @@ static bool IsLastNameArray(const parser::Designator &designator) {
10521052
const evaluate::DataRef dataRef{*(name.symbol)};
10531053
return common::visit(
10541054
common::visitors{
1055-
[](const evaluate::SymbolRef &ref) { return ref->Rank() > 0; },
1055+
[](const evaluate::SymbolRef &ref) {
1056+
return ref->Rank() > 0 ||
1057+
ref->GetType()->category() == DeclTypeSpec::Numeric;
1058+
},
10561059
[](const evaluate::ArrayRef &aref) {
10571060
return aref.base().IsSymbol() ||
10581061
aref.base().GetComponent().base().Rank() == 0;

flang/test/Semantics/OpenACC/acc-cache-validity.f90

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,11 @@ program openacc_cache_validity
2929
!$acc cache(t%arr)
3030
!$acc cache(ta(1:2)%arr)
3131
!$acc cache(ta(1:2)%arr(1:4))
32-
33-
!ERROR: Only array element or subarray are allowed in CACHE directive
34-
!$acc cache(ta(1:2)%s)
35-
36-
!ERROR: Only array element or subarray are allowed in CACHE directive
3732
!$acc cache(i)
33+
!$acc cache(t%s)
3834

3935
!ERROR: Only array element or subarray are allowed in CACHE directive
40-
!$acc cache(t%s)
36+
!$acc cache(t)
4137

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

0 commit comments

Comments
 (0)