[flang-commits] [flang] c362992 - [flang][openacc] Allow constant variable in data clause (#71580)

via flang-commits flang-commits at lists.llvm.org
Tue Nov 7 14:28:34 PST 2023


Author: Valentin Clement (バレンタイン クレメン)
Date: 2023-11-07T14:28:30-08:00
New Revision: c3629923aa2c28c912a08556950e45225ddc8db7

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

LOG: [flang][openacc] Allow constant variable in data clause (#71580)

The check introduced in #71444 was to restrictive and this patch relax
it so data clause can accept constant.

Added: 
    

Modified: 
    flang/lib/Semantics/resolve-directives.cpp
    flang/test/Semantics/OpenACC/acc-data.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index fefccd6c6ceb0f3..bbb105e3516da18 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -1123,7 +1123,8 @@ void AccAttributeVisitor::AllowOnlyVariable(const parser::AccObject &object) {
       common::visitors{
           [&](const parser::Designator &designator) {
             const auto &name{GetLastName(designator)};
-            if (name.symbol && !semantics::IsVariableName(*name.symbol)) {
+            if (name.symbol && !semantics::IsVariableName(*name.symbol) &&
+                !semantics::IsNamedConstant(*name.symbol)) {
               context_.Say(designator.source,
                   "Only variables are allowed in data clauses on the %s "
                   "directive"_err_en_US,

diff  --git a/flang/test/Semantics/OpenACC/acc-data.f90 b/flang/test/Semantics/OpenACC/acc-data.f90
index 095d06db91fc3ae..15176704c335a33 100644
--- a/flang/test/Semantics/OpenACC/acc-data.f90
+++ b/flang/test/Semantics/OpenACC/acc-data.f90
@@ -210,4 +210,10 @@ subroutine sub4(t)
     !$acc data copy(t%t1_proc)
     !$acc end data
   end subroutine
+
+  subroutine sub5()
+    integer, parameter :: iparam = 1024
+    !$acc data copyin(iparam)
+    !$acc end data
+  end subroutine
 end module


        


More information about the flang-commits mailing list