[flang-commits] [flang] 72d8e47 - [flang][openacc] Allow scalar in acc cache directive (#70713)

via flang-commits flang-commits at lists.llvm.org
Tue Oct 31 08:54:37 PDT 2023


Author: Valentin Clement (バレンタイン クレメン)
Date: 2023-10-31T08:54:33-07:00
New Revision: 72d8e47a2c345cfe163d91a2263ce01c3257cec2

URL: https://github.com/llvm/llvm-project/commit/72d8e47a2c345cfe163d91a2263ce01c3257cec2
DIFF: https://github.com/llvm/llvm-project/commit/72d8e47a2c345cfe163d91a2263ce01c3257cec2.diff

LOG: [flang][openacc] Allow scalar in acc cache directive (#70713)

Added: 
    

Modified: 
    flang/docs/OpenACC.md
    flang/lib/Semantics/resolve-directives.cpp
    flang/test/Semantics/OpenACC/acc-cache-validity.f90

Removed: 
    


################################################################################
diff  --git a/flang/docs/OpenACC.md b/flang/docs/OpenACC.md
index 41c974f837421b9..4c36a38f8bf5731 100644
--- a/flang/docs/OpenACC.md
+++ b/flang/docs/OpenACC.md
@@ -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.

diff  --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 66d3a9da3650579..fc0648b34bedef9 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -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;

diff  --git a/flang/test/Semantics/OpenACC/acc-cache-validity.f90 b/flang/test/Semantics/OpenACC/acc-cache-validity.f90
index 9eb12b9e2b7e4d4..49f400e763bfb53 100644
--- a/flang/test/Semantics/OpenACC/acc-cache-validity.f90
+++ b/flang/test/Semantics/OpenACC/acc-cache-validity.f90
@@ -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/)


        


More information about the flang-commits mailing list