[flang-commits] [flang] 3090efc - [flang][cuda] Relax semantic for device variable in block construct (#89330)

via flang-commits flang-commits at lists.llvm.org
Thu Apr 18 18:12:46 PDT 2024


Author: Valentin Clement (バレンタイン クレメン)
Date: 2024-04-18T18:12:41-07:00
New Revision: 3090efc6b65be0aa26b2ed0b734eef6efdd50322

URL: https://github.com/llvm/llvm-project/commit/3090efc6b65be0aa26b2ed0b734eef6efdd50322
DIFF: https://github.com/llvm/llvm-project/commit/3090efc6b65be0aa26b2ed0b734eef6efdd50322.diff

LOG: [flang][cuda] Relax semantic for device variable in block construct (#89330)

Added: 
    flang/test/Semantics/cuf12.cuf

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 824f1b6053ca39..875929e90fdd31 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -1042,9 +1042,10 @@ void CheckHelper::CheckObjectEntity(
             parser::ToUpperCaseLetters(common::EnumToString(attr)));
       }
     } else if (!subpDetails && symbol.owner().kind() != Scope::Kind::Module &&
-        symbol.owner().kind() != Scope::Kind::MainProgram) {
+        symbol.owner().kind() != Scope::Kind::MainProgram &&
+        symbol.owner().kind() != Scope::Kind::BlockConstruct) {
       messages_.Say(
-          "ATTRIBUTES(%s) may apply only to module, host subprogram, or device subprogram data"_err_en_US,
+          "ATTRIBUTES(%s) may apply only to module, host subprogram, block, or device subprogram data"_err_en_US,
           parser::ToUpperCaseLetters(common::EnumToString(attr)));
     }
   }

diff  --git a/flang/test/Semantics/cuf03.cuf b/flang/test/Semantics/cuf03.cuf
index 574add9faaade7..8decb8dcaa0f47 100644
--- a/flang/test/Semantics/cuf03.cuf
+++ b/flang/test/Semantics/cuf03.cuf
@@ -85,6 +85,11 @@ module m
     real, unified :: ru ! ok
     type(t1), unified :: tu ! ok
     type(t2) :: t ! ok
+
+    block
+      real, device :: a(100) ! ok
+    end block
   end subroutine
 
+
 end module

diff  --git a/flang/test/Semantics/cuf12.cuf b/flang/test/Semantics/cuf12.cuf
new file mode 100644
index 00000000000000..1b79c9889dfeaf
--- /dev/null
+++ b/flang/test/Semantics/cuf12.cuf
@@ -0,0 +1,8 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+
+program test
+  real, device :: b(100) ! ok
+  block
+    real, device :: a(100) ! ok
+  end block
+end program


        


More information about the flang-commits mailing list