[flang-commits] [flang] 39a9073 - [flang][cuda] Downgrade allocate pinned error to a warning (#121589)

via flang-commits flang-commits at lists.llvm.org
Fri Jan 3 10:35:14 PST 2025


Author: Valentin Clement (バレンタイン クレメン)
Date: 2025-01-03T10:35:11-08:00
New Revision: 39a9073f9eb71ac610cbafe7eed05ca668871b5c

URL: https://github.com/llvm/llvm-project/commit/39a9073f9eb71ac610cbafe7eed05ca668871b5c
DIFF: https://github.com/llvm/llvm-project/commit/39a9073f9eb71ac610cbafe7eed05ca668871b5c.diff

LOG: [flang][cuda] Downgrade allocate pinned error to a warning (#121589)

To be in accordance with the reference compiler.

Added: 
    

Modified: 
    flang/lib/Semantics/check-allocate.cpp
    flang/test/Semantics/cuf07.cuf

Removed: 
    


################################################################################
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