[flang-commits] [flang] [flang] Adjust new warnings for extensions (PR #94485)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Wed Jun 5 12:56:02 PDT 2024


https://github.com/klausler updated https://github.com/llvm/llvm-project/pull/94485

>From 67ae6bfded5ff11c19b6f671c583d046ef3012e7 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Wed, 5 Jun 2024 08:10:31 -0700
Subject: [PATCH] [flang] Adjust new warnings for extensions

Prevent messages from module files, respect the language feature
flags when enabling the relaxed PURE dummy argument checking, and
check that the new warnings are enabled.
---
 flang/lib/Semantics/check-declarations.cpp | 6 +++---
 flang/test/Semantics/call10.f90            | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index 25de9d4af1ffb..04d25263f7f66 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -731,14 +731,14 @@ void CheckHelper::CheckObjectEntity(
         }
       } else if (!IsIntentInOut(symbol)) { // C1586
         messages_.Say(
-            "non-POINTER dummy argument of pure %s must have INTENT() or VALUE attribute"_warn_en_US,
+            "non-POINTER dummy argument of pure %s must have INTENT() or VALUE attribute"_err_en_US,
             what);
         ok = false;
       }
-      if (ok && InFunction()) {
+      if (ok && InFunction() && !InModuleFile()) {
         if (context_.IsEnabled(common::LanguageFeature::RelaxedPureDummy)) {
           if (context_.ShouldWarn(common::LanguageFeature::RelaxedPureDummy) &&
-              !InModuleFile() && !InElemental()) {
+              !InElemental()) {
             messages_.Say(
                 "non-POINTER dummy argument of pure function should be INTENT(IN) or VALUE"_warn_en_US);
           }
diff --git a/flang/test/Semantics/call10.f90 b/flang/test/Semantics/call10.f90
index ff19f104b051b..ffb3b48c329e7 100644
--- a/flang/test/Semantics/call10.f90
+++ b/flang/test/Semantics/call10.f90
@@ -53,7 +53,7 @@ pure real function f02(a)
     real, value :: a ! ok
   end function
   pure real function f03(a) ! C1583
-    !ERROR: non-POINTER dummy argument of pure function must have INTENT() or VALUE attribute
+    !WARNING: non-POINTER dummy argument of pure function must have INTENT() or VALUE attribute
     real :: a
   end function
   pure real function f03a(a)
@@ -83,7 +83,7 @@ pure function f08() ! C1585
   end function
 
   pure subroutine s01(a) ! C1586
-    !ERROR: non-POINTER dummy argument of pure subroutine must have INTENT() or VALUE attribute
+    !WARNING: non-POINTER dummy argument of pure subroutine must have INTENT() or VALUE attribute
     real :: a
   end subroutine
   pure subroutine s01a(a)



More information about the flang-commits mailing list