Skip to content

Commit 3090efc

Browse files
authored
[flang][cuda] Relax semantic for device variable in block construct (#89330)
1 parent 396cdab commit 3090efc

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

flang/lib/Semantics/check-declarations.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,9 +1042,10 @@ void CheckHelper::CheckObjectEntity(
10421042
parser::ToUpperCaseLetters(common::EnumToString(attr)));
10431043
}
10441044
} else if (!subpDetails && symbol.owner().kind() != Scope::Kind::Module &&
1045-
symbol.owner().kind() != Scope::Kind::MainProgram) {
1045+
symbol.owner().kind() != Scope::Kind::MainProgram &&
1046+
symbol.owner().kind() != Scope::Kind::BlockConstruct) {
10461047
messages_.Say(
1047-
"ATTRIBUTES(%s) may apply only to module, host subprogram, or device subprogram data"_err_en_US,
1048+
"ATTRIBUTES(%s) may apply only to module, host subprogram, block, or device subprogram data"_err_en_US,
10481049
parser::ToUpperCaseLetters(common::EnumToString(attr)));
10491050
}
10501051
}

flang/test/Semantics/cuf03.cuf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ module m
8585
real, unified :: ru ! ok
8686
type(t1), unified :: tu ! ok
8787
type(t2) :: t ! ok
88+
89+
block
90+
real, device :: a(100) ! ok
91+
end block
8892
end subroutine
8993

94+
9095
end module

flang/test/Semantics/cuf12.cuf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
! RUN: %python %S/test_errors.py %s %flang_fc1
2+
3+
program test
4+
real, device :: b(100) ! ok
5+
block
6+
real, device :: a(100) ! ok
7+
end block
8+
end program

0 commit comments

Comments
 (0)