Skip to content

Commit 1fb5083

Browse files
authored
[flang][cuda] Accept variable with UNIFIED attribute in main (#90647)
UNIFIED variables are accept in program scope. Update the check to allow them.
1 parent 6992433 commit 1fb5083

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

flang/lib/Semantics/check-declarations.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,10 @@ void CheckHelper::CheckObjectEntity(
984984
}
985985
break;
986986
case common::CUDADataAttr::Unified:
987-
if ((!subpDetails || inDeviceSubprogram) && !isComponent) {
987+
if (((!subpDetails &&
988+
symbol.owner().kind() != Scope::Kind::MainProgram) ||
989+
inDeviceSubprogram) &&
990+
!isComponent) {
988991
messages_.Say(
989992
"Object '%s' with ATTRIBUTES(UNIFIED) must be declared in a host subprogram"_err_en_US,
990993
symbol.name());

flang/test/Semantics/cuf03.cuf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,7 @@ module m
8989

9090

9191
end module
92+
93+
program p
94+
real, unified :: um ! ok
95+
end program

0 commit comments

Comments
 (0)