Skip to content

Conversation

@klausler
Copy link
Contributor

When an external procedure has an explicit interface in one scope, and an implicit interface in another, and there's at least one call to it from which dummy argument information can be inferred, don't emit a warning about potential incompatibility if the only difference in their characteristics is that one of their interfaces was implicit.

When an external procedure has an explicit interface in one scope,
and an implicit interface in another, and there's at least one call
to it from which dummy argument information can be inferred, don't
emit a warning about potential incompatibility if the only difference
in their characteristics is that one of their interfaces was implicit.
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Oct 21, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 21, 2025

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

When an external procedure has an explicit interface in one scope, and an implicit interface in another, and there's at least one call to it from which dummy argument information can be inferred, don't emit a warning about potential incompatibility if the only difference in their characteristics is that one of their interfaces was implicit.


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

3 Files Affected:

  • (modified) flang/lib/Semantics/check-declarations.cpp (+1-1)
  • (added) flang/test/Semantics/bug1491.f90 (+21)
  • (modified) flang/test/Semantics/null-init.f90 (+1-1)
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index 31e246cf0ab03..3e21bc6f218a7 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -1781,7 +1781,7 @@ void CheckHelper::CheckExternal(const Symbol &symbol) {
         if (auto previousChars{Characterize(previous)}) {
           std::string whyNot;
           if (!chars->IsCompatibleWith(*previousChars,
-                  /*ignoreImplicitVsExplicit=*/false, &whyNot)) {
+                  /*ignoreImplicitVsExplicit=*/true, &whyNot)) {
             if (auto *msg{Warn(common::UsageWarning::ExternalInterfaceMismatch,
                     "The external interface '%s' is not compatible with an earlier definition (%s)"_warn_en_US,
                     symbol.name(), whyNot)}) {
diff --git a/flang/test/Semantics/bug1491.f90 b/flang/test/Semantics/bug1491.f90
new file mode 100644
index 0000000000000..ccc6eea31a1d4
--- /dev/null
+++ b/flang/test/Semantics/bug1491.f90
@@ -0,0 +1,21 @@
+!RUN: %python %S/test_errors.py %s %flang_fc1 -Werror -pedantic
+module m
+  interface
+    integer function foo1()
+    end function
+    integer function foo2(j)
+    end function
+    integer function foo3()
+    end function
+  end interface
+end module
+
+subroutine test()
+  integer, external :: foo1
+!WARNING: The external interface 'foo2' is not compatible with an earlier definition (distinct numbers of dummy arguments) [-Wexternal-interface-mismatch]
+  integer, external :: foo2
+  integer, external :: foo3
+  call bar(foo1())
+  call bar(foo2())
+  call baz(foo3)
+end subroutine
diff --git a/flang/test/Semantics/null-init.f90 b/flang/test/Semantics/null-init.f90
index d01ad75a75a11..a88cefe136a5e 100644
--- a/flang/test/Semantics/null-init.f90
+++ b/flang/test/Semantics/null-init.f90
@@ -37,7 +37,7 @@ module m6
 
 module m7
   interface
-    !WARNING: The external interface 'null' is not compatible with an earlier definition (incompatible procedure attributes: ImplicitInterface) [-Wexternal-interface-mismatch]
+    !WARNING: The external interface 'null' is not compatible with an earlier definition (function results have incompatible attributes) [-Wexternal-interface-mismatch]
     function null() result(p)
       integer, pointer :: p
     end function

@klausler klausler merged commit a377b85 into llvm:main Oct 24, 2025
13 checks passed
@klausler klausler deleted the bug1491 branch October 24, 2025 19:11
dvbuka pushed a commit to dvbuka/llvm-project that referenced this pull request Oct 27, 2025
When an external procedure has an explicit interface in one scope, and
an implicit interface in another, and there's at least one call to it
from which dummy argument information can be inferred, don't emit a
warning about potential incompatibility if the only difference in their
characteristics is that one of their interfaces was implicit.
Lukacma pushed a commit to Lukacma/llvm-project that referenced this pull request Oct 29, 2025
When an external procedure has an explicit interface in one scope, and
an implicit interface in another, and there's at least one call to it
from which dummy argument information can be inferred, don't emit a
warning about potential incompatibility if the only difference in their
characteristics is that one of their interfaces was implicit.
aokblast pushed a commit to aokblast/llvm-project that referenced this pull request Oct 30, 2025
When an external procedure has an explicit interface in one scope, and
an implicit interface in another, and there's at least one call to it
from which dummy argument information can be inferred, don't emit a
warning about potential incompatibility if the only difference in their
characteristics is that one of their interfaces was implicit.
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.

5 participants