Skip to content

[flang][openacc] Allow constant variable in data clause #71580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 7, 2023

Conversation

clementval
Copy link
Contributor

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

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:openmp openacc flang:semantics labels Nov 7, 2023
@llvmbot
Copy link
Member

llvmbot commented Nov 7, 2023

@llvm/pr-subscribers-flang-semantics
@llvm/pr-subscribers-openacc

@llvm/pr-subscribers-flang-openmp

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

Changes

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

Copy link
Contributor

@razvanlupusoru razvanlupusoru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you!

@clementval clementval merged commit c362992 into llvm:main Nov 7, 2023
@clementval clementval deleted the acc_variable branch November 7, 2023 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:openmp flang:semantics flang Flang issues not falling into any other category openacc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants