From a878dc8fb37434c4b1897e28e72420f3fd043b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Clement=20=28=E3=83=90=E3=83=AC=E3=83=B3?= =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=B3=20=E3=82=AF=E3=83=AC=E3=83=A1?= =?UTF-8?q?=E3=83=B3=29?= Date: Wed, 6 Nov 2024 13:19:09 -0800 Subject: [PATCH] [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. --- flang/lib/Semantics/check-declarations.cpp | 4 +++- flang/test/Semantics/cuf03.cuf | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp index f8e873008ceabc..86881225e1e55c 100644 --- a/flang/lib/Semantics/check-declarations.cpp +++ b/flang/lib/Semantics/check-declarations.cpp @@ -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(), diff --git a/flang/test/Semantics/cuf03.cuf b/flang/test/Semantics/cuf03.cuf index a98dd60cdb8a4e..93b136ad7d3157 100644 --- a/flang/test/Semantics/cuf03.cuf +++ b/flang/test/Semantics/cuf03.cuf @@ -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