diff options
author | Valentin Clement (バレンタイン クレメン) <clementval@gmail.com> | 2024-04-19 14:58:22 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-19 14:58:22 -0700 |
commit | 16e3464852efe3001060ff7feb3261dd397bfe84 (patch) | |
tree | 750f03266b41cc5ae575336850f5a257fc1ea57e | |
parent | 7c3dfb29dc4b5345da6a7fb25f92bf8d2919bce9 (diff) | |
download | llvm-16e3464852efe3001060ff7feb3261dd397bfe84.zip llvm-16e3464852efe3001060ff7feb3261dd397bfe84.tar.gz llvm-16e3464852efe3001060ff7feb3261dd397bfe84.tar.bz2 |
[flang][cuda] Enforce PINNED attribute when ALLOCATE with PINNED option (#89455)
When the PINNED option is specified on an ALLOCATE statement, the object
must have the PINNED attribute.
-rw-r--r-- | flang/lib/Semantics/check-allocate.cpp | 7 | ||||
-rw-r--r-- | flang/test/Semantics/cuf07.cuf | 8 |
2 files changed, 15 insertions, 0 deletions
diff --git a/flang/lib/Semantics/check-allocate.cpp b/flang/lib/Semantics/check-allocate.cpp index a7244e1..7bfd862 100644 --- a/flang/lib/Semantics/check-allocate.cpp +++ b/flang/lib/Semantics/check-allocate.cpp @@ -611,6 +611,13 @@ bool AllocationCheckerHelper::RunChecks(SemanticsContext &context) { return false; } } + if (allocateInfo_.gotPinned) { + std::optional<common::CUDADataAttr> cudaAttr{GetCUDADataAttr(ultimate_)}; + if (!cudaAttr || *cudaAttr != common::CUDADataAttr::Pinned) { + context.Say(name_.source, + "Object in ALLOCATE must have PINNED attribute when PINNED option is specified"_err_en_US); + } + } return RunCoarrayRelatedChecks(context); } diff --git a/flang/test/Semantics/cuf07.cuf b/flang/test/Semantics/cuf07.cuf index b520b5d..91a78e1 100644 --- a/flang/test/Semantics/cuf07.cuf +++ b/flang/test/Semantics/cuf07.cuf @@ -23,4 +23,12 @@ module m !BECAUSE: 'ma' is a host-associated allocatable and is not definable in a device subprogram deallocate(ma) end subroutine + + subroutine hostsub() + integer, allocatable, device :: ia(:) + logical :: plog + + !ERROR: Object in ALLOCATE must have PINNED attribute when PINNED option is specified + allocate(ia(100), pinned = plog) + end subroutine end module |