[flang-commits] [flang] [flang][cuda] Do not apply implicit data attribute on dummy arg with VALUE (PR #119927)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Fri Dec 13 13:12:35 PST 2024


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

Dummy arguments with the VALUE attribute do not need the implicit data attribute. 

>From 554b5dbdefce7cd4e7471104b5ad3d569984cdcd Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Fri, 13 Dec 2024 13:10:29 -0800
Subject: [PATCH] [flang][cuda] Do not apply implicit data attribute on dummy
 arg with VALUE

---
 flang/lib/Semantics/resolve-names.cpp | 2 +-
 flang/test/Semantics/modfile55.cuf    | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index aef2898919f3ff..313508eb423138 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -8976,7 +8976,7 @@ void ResolveNamesVisitor::FinishSpecificationPart(
     if (inDeviceSubprogram && IsDummy(symbol) &&
         symbol.has<ObjectEntityDetails>()) {
       auto *dummy{symbol.detailsIf<ObjectEntityDetails>()};
-      if (!dummy->cudaDataAttr()) {
+      if (!dummy->cudaDataAttr() && !IsValue(symbol)) {
         // Implicitly set device attribute if none is set in device context.
         dummy->set_cudaDataAttr(common::CUDADataAttr::Device);
       }
diff --git a/flang/test/Semantics/modfile55.cuf b/flang/test/Semantics/modfile55.cuf
index 6c0d152a382a88..cf01bdd5f58f6f 100644
--- a/flang/test/Semantics/modfile55.cuf
+++ b/flang/test/Semantics/modfile55.cuf
@@ -29,7 +29,6 @@ end
 !contains
 !attributes(global) subroutine globsub(x,y,z)
 !real(4),value::x
-!attributes(device) x
 !real(4)::y
 !attributes(device) y
 !real(4)::z



More information about the flang-commits mailing list