Skip to content

Commit

Permalink
[flang][cuda] Allow POINTER component to have device attribute (llvm#…
Browse files Browse the repository at this point in the history
  • Loading branch information
clementval authored and Icohedron committed Feb 11, 2025
1 parent 73b36f1 commit 594e189
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions flang/lib/Semantics/check-declarations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions flang/test/Semantics/cuf03.cuf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 594e189

Please sign in to comment.