[flang-commits] [flang] [flang][cuda] Accept variable with UNIFIED attribute in main (PR #90647)

via flang-commits flang-commits at lists.llvm.org
Tue Apr 30 11:50:36 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-semantics

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

<details>
<summary>Changes</summary>

UNIFIED variables are accept in program scope. Update the check to allow them. 

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


2 Files Affected:

- (modified) flang/lib/Semantics/check-declarations.cpp (+4-1) 
- (modified) flang/test/Semantics/cuf03.cuf (+4) 


``````````diff
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index 901ac20f8aae9b..d49c8e059591c2 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -984,7 +984,10 @@ void CheckHelper::CheckObjectEntity(
       }
       break;
     case common::CUDADataAttr::Unified:
-      if ((!subpDetails || inDeviceSubprogram) && !isComponent) {
+      if (((!subpDetails &&
+               symbol.owner().kind() != Scope::Kind::MainProgram) ||
+              inDeviceSubprogram) &&
+          !isComponent) {
         messages_.Say(
             "Object '%s' with ATTRIBUTES(UNIFIED) must be declared in a host subprogram"_err_en_US,
             symbol.name());
diff --git a/flang/test/Semantics/cuf03.cuf b/flang/test/Semantics/cuf03.cuf
index 472d53db7462ae..a98dd60cdb8a4e 100644
--- a/flang/test/Semantics/cuf03.cuf
+++ b/flang/test/Semantics/cuf03.cuf
@@ -89,3 +89,7 @@ module m
 
 
 end module
+
+program p
+  real, unified :: um ! ok
+end program

``````````

</details>


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


More information about the flang-commits mailing list