[flang-commits] [flang] a878dc8 - [flang][cuda] Do not emit warning for SHARED variable in device subprogram (#115195)
via flang-commits
flang-commits at lists.llvm.org
Wed Nov 6 13:19:12 PST 2024
Author: Valentin Clement (バレンタイン クレメン)
Date: 2024-11-06T13:19:09-08:00
New Revision: a878dc8fb37434c4b1897e28e72420f3fd043b3a
URL: https://github.com/llvm/llvm-project/commit/a878dc8fb37434c4b1897e28e72420f3fd043b3a
DIFF: https://github.com/llvm/llvm-project/commit/a878dc8fb37434c4b1897e28e72420f3fd043b3a.diff
LOG: [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.
Added:
Modified:
flang/lib/Semantics/check-declarations.cpp
flang/test/Semantics/cuf03.cuf
Removed:
################################################################################
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
More information about the flang-commits
mailing list