Skip to content

Commit

Permalink
[flang][cuda] Relax semantic for device variable in block construct (l…
Browse files Browse the repository at this point in the history
  • Loading branch information
clementval authored Apr 19, 2024
1 parent 396cdab commit 3090efc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions flang/lib/Semantics/check-declarations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1042,9 +1042,10 @@ void CheckHelper::CheckObjectEntity(
parser::ToUpperCaseLetters(common::EnumToString(attr)));
}
} else if (!subpDetails && symbol.owner().kind() != Scope::Kind::Module &&
symbol.owner().kind() != Scope::Kind::MainProgram) {
symbol.owner().kind() != Scope::Kind::MainProgram &&
symbol.owner().kind() != Scope::Kind::BlockConstruct) {
messages_.Say(
"ATTRIBUTES(%s) may apply only to module, host subprogram, or device subprogram data"_err_en_US,
"ATTRIBUTES(%s) may apply only to module, host subprogram, block, or device subprogram data"_err_en_US,
parser::ToUpperCaseLetters(common::EnumToString(attr)));
}
}
Expand Down
5 changes: 5 additions & 0 deletions flang/test/Semantics/cuf03.cuf
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ module m
real, unified :: ru ! ok
type(t1), unified :: tu ! ok
type(t2) :: t ! ok

block
real, device :: a(100) ! ok
end block
end subroutine


end module
8 changes: 8 additions & 0 deletions flang/test/Semantics/cuf12.cuf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
! RUN: %python %S/test_errors.py %s %flang_fc1

program test
real, device :: b(100) ! ok
block
real, device :: a(100) ! ok
end block
end program

0 comments on commit 3090efc

Please sign in to comment.