Skip to content

Commit

Permalink
[flang][cuda] Do not emit warning for SHARED variable in device subpr…
Browse files Browse the repository at this point in the history
…ogram (#115195)

SHARED attribute is explicitly meant to be used in device subprogram
(https://docs.nvidia.com/hpc-sdk/compilers/cuda-fortran-prog-guide/index.html#cfpg-var-qual-attr-shared).

Do not emit warning.
  • Loading branch information
clementval authored Nov 6, 2024
1 parent 304c412 commit a878dc8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion flang/lib/Semantics/check-declarations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,9 @@ void CheckHelper::CheckObjectEntity(
details.cudaDataAttr().value_or(common::CUDADataAttr::Device) !=
common::CUDADataAttr::Device &&
details.cudaDataAttr().value_or(common::CUDADataAttr::Device) !=
common::CUDADataAttr::Managed) {
common::CUDADataAttr::Managed &&
details.cudaDataAttr().value_or(common::CUDADataAttr::Device) !=
common::CUDADataAttr::Shared) {
Warn(common::UsageWarning::CUDAUsage,
"Dummy argument '%s' may not have ATTRIBUTES(%s) in a device subprogram"_warn_en_US,
symbol.name(),
Expand Down
3 changes: 2 additions & 1 deletion flang/test/Semantics/cuf03.cuf
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ module m
real, unified :: um

contains
attributes(device) subroutine devsubr(n,da)
attributes(device) subroutine devsubr(n,da,rs)
integer, intent(in) :: n
real, device :: da(*) ! ok
real, managed :: ma(n) ! ok
!WARNING: Pointer 'dp' may not be associated in a device subprogram
real, device, pointer :: dp
real, constant :: rc ! ok
real, shared :: rs ! ok
!ERROR: Object 'u' with ATTRIBUTES(UNIFIED) must be declared in a host subprogram
real, unified :: u
end subroutine
Expand Down

0 comments on commit a878dc8

Please sign in to comment.