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

via flang-commits flang-commits at lists.llvm.org
Tue Nov 7 11:38:42 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-openmp

Author: Valentin Clement (バレンタイン クレメン) (clementval)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/71580.diff


2 Files Affected:

- (modified) flang/lib/Semantics/resolve-directives.cpp (+2-1) 
- (modified) flang/test/Semantics/OpenACC/acc-data.f90 (+6) 


``````````diff
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

``````````

</details>


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


More information about the flang-commits mailing list