[flang-commits] [flang] d8df9b5 - [Flang] Fix for the spurious error for VOLATILE actual argument in implicit interface CALL (#192605)

via flang-commits flang-commits at lists.llvm.org
Sun Jul 12 21:56:29 PDT 2026


Author: ejose02
Date: 2026-07-13T10:26:25+05:30
New Revision: d8df9b5e925c580f076779e5cbfe2bffc451c3b6

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

LOG: [Flang] Fix for the spurious error for VOLATILE actual argument in implicit interface CALL (#192605)

Fixes #191343

Replaced the error with warning. Now it permits calling an external
procedure with implicit interface and passing a volatile argument. There
will be a warning that the procedure should have an explicit interface.

In addition to fixing the VOLATILE error, I updated the semantic check
for the ASYNCHRONOUS attribute. Both attributes were incorrectly
throwing a hard error when used as actual arguments in an implicit
interface call. According to the Fortran 2018 standard, an explicit
interface is only mandatory when the dummy argument has the VOLATILE or
ASYNCHRONOUS attribute. Since the standard doesn't restrict actual
arguments in this scenario, I downgraded both to emit a
-Wimplicit-interface-actual warning instead.

Added: 
    flang/test/Semantics/call48.f90

Modified: 
    flang/lib/Semantics/check-call.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index 16c1e166ded66..a546930c1b441 100644
--- a/flang/lib/Semantics/check-call.cpp
+++ b/flang/lib/Semantics/check-call.cpp
@@ -81,13 +81,15 @@ void CheckImplicitInterfaceArg(evaluate::ActualArgument &arg,
       }
       const Symbol &symbol{GetAssociationRoot(resolved)};
       if (symbol.attrs().test(Attr::ASYNCHRONOUS)) {
-        messages.Say(
-            "ASYNCHRONOUS argument '%s' requires an explicit interface"_err_en_US,
+        messages.Warn(/*inModuleFile=*/false, context.languageFeatures(),
+            common::UsageWarning::ImplicitInterfaceActual,
+            "ASYNCHRONOUS actual argument '%s' should be passed via an explicit interface"_warn_en_US,
             expr->AsFortran());
       }
       if (symbol.attrs().test(Attr::VOLATILE)) {
-        messages.Say(
-            "VOLATILE argument '%s' requires an explicit interface"_err_en_US,
+        messages.Warn(/*inModuleFile=*/false, context.languageFeatures(),
+            common::UsageWarning::ImplicitInterfaceActual,
+            "VOLATILE actual argument '%s' should be passed via an explicit interface"_warn_en_US,
             expr->AsFortran());
       }
       if (const auto *object{symbol.detailsIf<ObjectEntityDetails>()}) {

diff  --git a/flang/test/Semantics/call48.f90 b/flang/test/Semantics/call48.f90
new file mode 100644
index 0000000000000..17a34cd65fbc6
--- /dev/null
+++ b/flang/test/Semantics/call48.f90
@@ -0,0 +1,20 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic -Werror
+
+program test
+  integer :: i
+  volatile :: i
+  real :: volatileVar
+  volatile :: volatileVar
+  real :: asyncVar
+  asynchronous :: asyncVar
+  !WARNING: VOLATILE actual argument 'i' should be passed via an explicit interface [-Wimplicit-interface-actual]
+  call sub(i)
+  !WARNING: VOLATILE actual argument 'volatilevar' should be passed via an explicit interface [-Wimplicit-interface-actual]
+  call implicitVol(volatileVar)
+  !WARNING: ASYNCHRONOUS actual argument 'asyncvar' should be passed via an explicit interface [-Wimplicit-interface-actual]
+  call implicitAsync(asyncVar)
+end
+
+subroutine sub(i)
+  integer :: i
+end subroutine


        


More information about the flang-commits mailing list