[flang-commits] [flang] [flang][cuda] Downgrade allocate pinned error to a warning (PR #121589)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Fri Jan 3 10:09:18 PST 2025
https://github.com/clementval created https://github.com/llvm/llvm-project/pull/121589
To be in accordance with the reference compiler.
>From f5a32e67cc03855497c40dbd8794c89ab537af87 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Fri, 3 Jan 2025 10:07:47 -0800
Subject: [PATCH] [flang][cuda] Downgrade allocate pinned error to a warning
---
flang/lib/Semantics/check-allocate.cpp | 6 ++++--
flang/test/Semantics/cuf07.cuf | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/flang/lib/Semantics/check-allocate.cpp b/flang/lib/Semantics/check-allocate.cpp
index 1e5412324916d6..223bee6eb6f118 100644
--- a/flang/lib/Semantics/check-allocate.cpp
+++ b/flang/lib/Semantics/check-allocate.cpp
@@ -616,9 +616,11 @@ bool AllocationCheckerHelper::RunChecks(SemanticsContext &context) {
}
if (allocateInfo_.gotPinned) {
std::optional<common::CUDADataAttr> cudaAttr{GetCUDADataAttr(ultimate_)};
- if (!cudaAttr || *cudaAttr != common::CUDADataAttr::Pinned) {
+ if ((!cudaAttr || *cudaAttr != common::CUDADataAttr::Pinned) &&
+ context.languageFeatures().ShouldWarn(
+ common::UsageWarning::CUDAUsage)) {
context.Say(name_.source,
- "Object in ALLOCATE must have PINNED attribute when PINNED option is specified"_err_en_US);
+ "Object in ALLOCATE should have PINNED attribute when PINNED option is specified"_warn_en_US);
}
}
if (allocateInfo_.gotStream) {
diff --git a/flang/test/Semantics/cuf07.cuf b/flang/test/Semantics/cuf07.cuf
index c48abb5adf0d41..56b2164532ae25 100644
--- a/flang/test/Semantics/cuf07.cuf
+++ b/flang/test/Semantics/cuf07.cuf
@@ -28,7 +28,7 @@ module m
integer, allocatable, device :: ia(:)
logical :: plog
- !ERROR: Object in ALLOCATE must have PINNED attribute when PINNED option is specified
+ !WARNING: Object in ALLOCATE should have PINNED attribute when PINNED option is specified
allocate(ia(100), pinned = plog)
end subroutine
More information about the flang-commits
mailing list