[flang-commits] [flang] f2a0dd3 - [flang][cuda] Add restriction on assumed size device variable (#87664)
via flang-commits
flang-commits at lists.llvm.org
Thu Apr 4 12:48:12 PDT 2024
Author: Valentin Clement (バレンタイン クレメン)
Date: 2024-04-04T12:48:08-07:00
New Revision: f2a0dd3305beb0e69eb165c31c40214c16278697
URL: https://github.com/llvm/llvm-project/commit/f2a0dd3305beb0e69eb165c31c40214c16278697
DIFF: https://github.com/llvm/llvm-project/commit/f2a0dd3305beb0e69eb165c31c40214c16278697.diff
LOG: [flang][cuda] Add restriction on assumed size device variable (#87664)
According to
https://docs.nvidia.com/hpc-sdk/compilers/cuda-fortran-prog-guide/#cfpg-var-qual-attr-device
> A device array may be an explicit-shape array, an allocatable array,
or an assumed-shape dummy array.
Assumed size array are not supported. This patch adds an error for that
case.
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 dec8fee774c5be..b2de37759a0613 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -948,6 +948,11 @@ void CheckHelper::CheckObjectEntity(
"Component '%s' with ATTRIBUTES(DEVICE) must also be allocatable"_err_en_US,
symbol.name());
}
+ if (IsAssumedSizeArray(symbol)) {
+ messages_.Say(
+ "Object '%s' with ATTRIBUTES(DEVICE) may not be assumed size"_err_en_US,
+ symbol.name());
+ }
break;
case common::CUDADataAttr::Managed:
if (!IsAutomatic(symbol) && !IsAllocatable(symbol) &&
diff --git a/flang/test/Semantics/cuf03.cuf b/flang/test/Semantics/cuf03.cuf
index 41bfbb76781364..7384a104831d8d 100644
--- a/flang/test/Semantics/cuf03.cuf
+++ b/flang/test/Semantics/cuf03.cuf
@@ -51,7 +51,8 @@ module m
contains
attributes(device) subroutine devsubr(n,da)
integer, intent(in) :: n
- real, device :: da(*) ! ok
+ !ERROR: Object 'da' with ATTRIBUTES(DEVICE) may not be assumed size
+ real, device :: da(*)
real, managed :: ma(n) ! ok
!WARNING: Pointer 'dp' may not be associated in a device subprogram
real, device, pointer :: dp
More information about the flang-commits
mailing list