Skip to content

Conversation

@clementval
Copy link
Contributor

No description provided.

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Feb 6, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 6, 2025

@llvm/pr-subscribers-flang-semantics

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

Changes

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

2 Files Affected:

  • (modified) flang/lib/Semantics/check-declarations.cpp (+2-2)
  • (modified) flang/test/Semantics/cuf03.cuf (+8)
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index 5c26469b9fa248..bf4dc16a15b4a2 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -989,9 +989,9 @@ void CheckHelper::CheckObjectEntity(
       }
       break;
     case common::CUDADataAttr::Device:
-      if (isComponent && !IsAllocatable(symbol)) {
+      if (isComponent && !IsAllocatable(symbol) && !IsPointer(symbol)) {
         messages_.Say(
-            "Component '%s' with ATTRIBUTES(DEVICE) must also be allocatable"_err_en_US,
+            "Component '%s' with ATTRIBUTES(DEVICE) must also be allocatable or pointer"_err_en_US,
             symbol.name());
       }
       break;
diff --git a/flang/test/Semantics/cuf03.cuf b/flang/test/Semantics/cuf03.cuf
index 93b136ad7d3157..fe9dd5b3ecf05b 100644
--- a/flang/test/Semantics/cuf03.cuf
+++ b/flang/test/Semantics/cuf03.cuf
@@ -54,6 +54,14 @@ module m
   !ERROR: Object 'um' with ATTRIBUTES(UNIFIED) must be declared in a host subprogram
   real, unified :: um
 
+  type :: t3
+  !ERROR: Component 'r' with ATTRIBUTES(DEVICE) must also be allocatable or pointer
+    real, device :: r
+    real, device, pointer :: rp ! ok
+    real, device, allocatable :: ra ! ok
+    real, device, pointer, contiguous :: rpc ! ok
+  end type
+
  contains
   attributes(device) subroutine devsubr(n,da,rs)
     integer, intent(in) :: n

@clementval clementval merged commit b00b193 into llvm:main Feb 7, 2025
11 checks passed
@clementval clementval deleted the cuf_comp_pointer branch February 7, 2025 03:43
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang:semantics flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants