Skip to content

Commit b00b193

Browse files
authored
[flang][cuda] Allow POINTER component to have device attribute (#126116)
1 parent d9500f5 commit b00b193

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

flang/lib/Semantics/check-declarations.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,9 +989,9 @@ void CheckHelper::CheckObjectEntity(
989989
}
990990
break;
991991
case common::CUDADataAttr::Device:
992-
if (isComponent && !IsAllocatable(symbol)) {
992+
if (isComponent && !IsAllocatable(symbol) && !IsPointer(symbol)) {
993993
messages_.Say(
994-
"Component '%s' with ATTRIBUTES(DEVICE) must also be allocatable"_err_en_US,
994+
"Component '%s' with ATTRIBUTES(DEVICE) must also be allocatable or pointer"_err_en_US,
995995
symbol.name());
996996
}
997997
break;

flang/test/Semantics/cuf03.cuf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ module m
5454
!ERROR: Object 'um' with ATTRIBUTES(UNIFIED) must be declared in a host subprogram
5555
real, unified :: um
5656

57+
type :: t3
58+
!ERROR: Component 'r' with ATTRIBUTES(DEVICE) must also be allocatable or pointer
59+
real, device :: r
60+
real, device, pointer :: rp ! ok
61+
real, device, allocatable :: ra ! ok
62+
real, device, pointer, contiguous :: rpc ! ok
63+
end type
64+
5765
contains
5866
attributes(device) subroutine devsubr(n,da,rs)
5967
integer, intent(in) :: n

0 commit comments

Comments
 (0)