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

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


Author: Valentin Clement (バレンタイン クレメン)
Date: 2024-04-30T14:11:35-07:00
New Revision: 1fb5083aed3f2bed3658f63ead895e2955f0bc4c

URL: https://github.com/llvm/llvm-project/commit/1fb5083aed3f2bed3658f63ead895e2955f0bc4c
DIFF: https://github.com/llvm/llvm-project/commit/1fb5083aed3f2bed3658f63ead895e2955f0bc4c.diff

LOG: [flang][cuda] Accept variable with UNIFIED attribute in main (#90647)

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

Added: 
    

Modified: 
    flang/lib/Semantics/check-declarations.cpp
    flang/test/Semantics/cuf03.cuf

Removed: 
    


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


        


More information about the flang-commits mailing list