Skip to content

[flang] Adjust new warnings for extensions #94485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2024
Merged

Conversation

klausler
Copy link
Contributor

@klausler klausler commented Jun 5, 2024

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.

@klausler klausler requested a review from wangzpgi June 5, 2024 15:13
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Jun 5, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 5, 2024

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/94485.diff

2 Files Affected:

  • (modified) flang/lib/Semantics/check-declarations.cpp (+16-5)
  • (modified) flang/test/Semantics/call10.f90 (+2-2)
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index 25de9d4af1ffb..80d1003d0adaa 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -730,15 +730,26 @@ 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,
-            what);
+        if (!InModuleFile()) {
+          if (context_.IsEnabled(common::LanguageFeature::RelaxedPureDummy)) {
+            if (context_.ShouldWarn(
+                    common::LanguageFeature::RelaxedPureDummy)) {
+              messages_.Say(
+                  "non-POINTER dummy argument of pure %s should have INTENT() or VALUE attribute"_warn_en_US,
+                  what);
+            }
+          } else {
+            messages_.Say(
+                "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..a332efe0a1155 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 should 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 should have INTENT() or VALUE attribute
     real :: a
   end subroutine
   pure subroutine s01a(a)

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.
@klausler klausler merged commit 8bcf40b into llvm:main Jun 12, 2024
7 checks passed
@klausler klausler deleted the bug1633 branch June 12, 2024 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants