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

via flang-commits flang-commits at lists.llvm.org
Fri Apr 17 00:21:03 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-semantics

Author: ejose02

<details>
<summary>Changes</summary>

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. Updated 2 test cases to reflect the change.

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


4 Files Affected:

- (modified) flang/lib/Semantics/check-call.cpp (+6-4) 
- (modified) flang/lib/Support/Fortran-features.cpp (+1) 
- (modified) flang/test/Semantics/call13.f90 (+8) 
- (modified) flang/test/Semantics/generic11.f90 (+1) 


``````````diff
diff --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index 2dd47508a0b3f..a400f001f731d 100644
--- a/flang/lib/Semantics/check-call.cpp
+++ b/flang/lib/Semantics/check-call.cpp
@@ -76,13 +76,15 @@ static 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,
+            "Procedure with ASYNCHRONOUS argument '%s' should have 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,
+            "Procedure with VOLATILE argument '%s' should have an explicit interface"_warn_en_US,
             expr->AsFortran());
       }
       if (const auto *object{symbol.detailsIf<ObjectEntityDetails>()}) {
diff --git a/flang/lib/Support/Fortran-features.cpp b/flang/lib/Support/Fortran-features.cpp
index 4201f0b9b1e49..9d634af98b6ee 100644
--- a/flang/lib/Support/Fortran-features.cpp
+++ b/flang/lib/Support/Fortran-features.cpp
@@ -156,6 +156,7 @@ LanguageFeatureControl::LanguageFeatureControl() {
   warnUsage_.set(UsageWarning::HostAssociatedIntentOutInSpecExpr);
   warnUsage_.set(UsageWarning::NonVolatilePointerToVolatile);
   warnUsage_.set(UsageWarning::RealConstantWidening);
+  warnUsage_.set(UsageWarning::ImplicitInterfaceActual);
   // New warnings, on by default
   warnLanguage_.set(LanguageFeature::SavedLocalInSpecExpr);
   warnLanguage_.set(LanguageFeature::NullActualForAllocatable);
diff --git a/flang/test/Semantics/call13.f90 b/flang/test/Semantics/call13.f90
index 90e19180f9c56..4197de9a381e0 100644
--- a/flang/test/Semantics/call13.f90
+++ b/flang/test/Semantics/call13.f90
@@ -7,6 +7,10 @@ subroutine s(assumedRank, coarray, class, classStar, typeStar)
   end type
 
   real :: assumedRank(..), coarray[*]
+  real :: volatileVar
+  volatile :: volatileVar
+  real :: asyncVar
+  asynchronous :: asyncVar
   class(t) :: class
   class(*) :: classStar
   type(*) :: typeStar
@@ -24,6 +28,10 @@ subroutine s(assumedRank, coarray, class, classStar, typeStar)
   call implicit11(assumedRank)  ! 15.4.2.2(3)(c)
   call implicit12(coarray)  ! ok
   call implicit12a(coarray[1]) ! ok
+  !WARNING: Procedure with VOLATILE argument 'volatilevar' should have an explicit interface [-Wimplicit-interface-actual]
+  call implicit12b(volatileVar)
+  !WARNING: Procedure with ASYNCHRONOUS argument 'asyncvar' should have an explicit interface [-Wimplicit-interface-actual]
+  call implicit12c(asyncVar)
   !ERROR: Parameterized derived type actual argument requires an explicit interface
   call implicit13(pdtx)  ! 15.4.2.2(3)(e)
   call implicit14(class)  ! ok
diff --git a/flang/test/Semantics/generic11.f90 b/flang/test/Semantics/generic11.f90
index 14383ab150fe4..7db8cc4866942 100644
--- a/flang/test/Semantics/generic11.f90
+++ b/flang/test/Semantics/generic11.f90
@@ -16,6 +16,7 @@ subroutine sub2(rfun)
 real rfun
 complex zfun
 external ifun, rfun, zfun, xfun
+!WARNING: Actual procedure argument has an implicit interface which is not known to be compatible with dummy argument 'ifun=' which has an explicit interface [-Wimplicit-interface-actual]
 call sub(ifun)
 call sub(rfun)
 !ERROR: No specific subroutine of generic 'sub' matches the actual arguments

``````````

</details>


https://github.com/llvm/llvm-project/pull/192605


More information about the flang-commits mailing list