[flang-commits] [flang] [flang][cuda] Do not emit warning for SHARED variable in device subprogram (PR #115195)
via flang-commits
flang-commits at lists.llvm.org
Wed Nov 6 11:09:05 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Valentin Clement (バレンタイン クレメン) (clementval)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/115195.diff
2 Files Affected:
- (modified) flang/lib/Semantics/check-declarations.cpp (+3-1)
- (modified) flang/test/Semantics/cuf03.cuf (+2-1)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/115195
More information about the flang-commits
mailing list