Skip to content

Commit a878dc8

Browse files
authored
[flang][cuda] Do not emit warning for SHARED variable in device subprogram (#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.
1 parent 304c412 commit a878dc8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

flang/lib/Semantics/check-declarations.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,9 @@ void CheckHelper::CheckObjectEntity(
928928
details.cudaDataAttr().value_or(common::CUDADataAttr::Device) !=
929929
common::CUDADataAttr::Device &&
930930
details.cudaDataAttr().value_or(common::CUDADataAttr::Device) !=
931-
common::CUDADataAttr::Managed) {
931+
common::CUDADataAttr::Managed &&
932+
details.cudaDataAttr().value_or(common::CUDADataAttr::Device) !=
933+
common::CUDADataAttr::Shared) {
932934
Warn(common::UsageWarning::CUDAUsage,
933935
"Dummy argument '%s' may not have ATTRIBUTES(%s) in a device subprogram"_warn_en_US,
934936
symbol.name(),

flang/test/Semantics/cuf03.cuf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@ module m
5555
real, unified :: um
5656

5757
contains
58-
attributes(device) subroutine devsubr(n,da)
58+
attributes(device) subroutine devsubr(n,da,rs)
5959
integer, intent(in) :: n
6060
real, device :: da(*) ! ok
6161
real, managed :: ma(n) ! ok
6262
!WARNING: Pointer 'dp' may not be associated in a device subprogram
6363
real, device, pointer :: dp
6464
real, constant :: rc ! ok
65+
real, shared :: rs ! ok
6566
!ERROR: Object 'u' with ATTRIBUTES(UNIFIED) must be declared in a host subprogram
6667
real, unified :: u
6768
end subroutine

0 commit comments

Comments
 (0)