Skip to content

Commit aa7c104

Browse files
authored
[flang][cuda] Allow fixed size array with the managed attribute (llvm#89436)
Fixed size array and scalar should be allowed with the `managed` attribute.
1 parent 3ea5dff commit aa7c104

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

flang/lib/Semantics/check-declarations.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,9 +956,9 @@ void CheckHelper::CheckObjectEntity(
956956
break;
957957
case common::CUDADataAttr::Managed:
958958
if (!IsAutomatic(symbol) && !IsAllocatable(symbol) &&
959-
!details.isDummy()) {
959+
!details.isDummy() && !evaluate::IsExplicitShape(symbol)) {
960960
messages_.Say(
961-
"Object '%s' with ATTRIBUTES(MANAGED) must also be allocatable, automatic, or a dummy argument"_err_en_US,
961+
"Object '%s' with ATTRIBUTES(MANAGED) must also be allocatable, automatic, explicit shape, or a dummy argument"_err_en_US,
962962
symbol.name());
963963
}
964964
break;

flang/test/Semantics/cuf03.cuf

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,11 @@ module m
3232
real, shared, target :: mst
3333
!ERROR: Object 'msa' with ATTRIBUTES(SHARED) must be declared in a device subprogram
3434
real, shared :: msa(*)
35-
!ERROR: Object 'mm' with ATTRIBUTES(MANAGED) must also be allocatable, automatic, or a dummy argument
36-
real, managed :: mm
37-
!ERROR: Object 'mmi' with ATTRIBUTES(MANAGED) must also be allocatable, automatic, or a dummy argument
38-
real, managed :: mmi = 1.
35+
real, managed :: mm ! ok
36+
real, managed :: mmi = 1. ! ok
3937
real, managed, allocatable :: mml ! ok
40-
!ERROR: Object 'mmp' with ATTRIBUTES(MANAGED) must also be allocatable, automatic, or a dummy argument
41-
real, managed, pointer :: mmp ! ok
42-
!ERROR: Object 'mmt' with ATTRIBUTES(MANAGED) must also be allocatable, automatic, or a dummy argument
38+
!ERROR: Object 'mmp' with ATTRIBUTES(MANAGED) must also be allocatable, automatic, explicit shape, or a dummy argument
39+
real, managed, pointer :: mmp(:)
4340
real, managed, target :: mmt
4441
!WARNING: Object 'mp' with ATTRIBUTES(PINNED) should also be allocatable
4542
real, pinned :: mp

0 commit comments

Comments
 (0)