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

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Tue Nov 7 11:38:09 PST 2023


https://github.com/clementval created https://github.com/llvm/llvm-project/pull/71580

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

>From 34e1c07895579a4f57c73dc53b830f66764d0987 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Tue, 7 Nov 2023 11:02:45 -0800
Subject: [PATCH] [flang][openacc] Allow constant variable in data clause

---
 flang/lib/Semantics/resolve-directives.cpp | 3 ++-
 flang/test/Semantics/OpenACC/acc-data.f90  | 6 ++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

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