[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
Tue Jun 30 23:48:32 PDT 2026


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

>From b8eec6fb11ee1ee88ede5b7de56aebd0babf9060 Mon Sep 17 00:00:00 2001
From: ejose02 <ejose at amd.com>
Date: Fri, 17 Apr 2026 12:44:06 +0530
Subject: [PATCH 1/2] 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.
---
 flang/lib/Semantics/check-call.cpp     | 10 ++++++----
 flang/lib/Support/Fortran-features.cpp |  1 +
 flang/test/Semantics/call13.f90        |  8 ++++++++
 flang/test/Semantics/generic11.f90     |  1 +
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index 16c1e166ded66..019f30e8183f3 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,
+            "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 a8fa4ac4a7afe..98faa2961fa32 100644
--- a/flang/lib/Support/Fortran-features.cpp
+++ b/flang/lib/Support/Fortran-features.cpp
@@ -209,6 +209,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

>From 097367ebcb79d50ba2fe12192a54245d01aecb65 Mon Sep 17 00:00:00 2001
From: ejose02 <ejose at amd.com>
Date: Wed, 1 Jul 2026 11:59:46 +0530
Subject: [PATCH 2/2] Use reviewer-suggested warning text and keep
 ImplicitInterfaceActual pedantic-only; added call47.f90 regression test

---
 flang/lib/Semantics/check-call.cpp     |  4 ++--
 flang/lib/Support/Fortran-features.cpp |  1 -
 flang/test/Semantics/call13.f90        |  8 --------
 flang/test/Semantics/call48.f90        | 21 +++++++++++++++++++++
 flang/test/Semantics/generic11.f90     |  1 -
 5 files changed, 23 insertions(+), 12 deletions(-)
 create mode 100644 flang/test/Semantics/call48.f90

diff --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index 019f30e8183f3..a546930c1b441 100644
--- a/flang/lib/Semantics/check-call.cpp
+++ b/flang/lib/Semantics/check-call.cpp
@@ -83,13 +83,13 @@ void CheckImplicitInterfaceArg(evaluate::ActualArgument &arg,
       if (symbol.attrs().test(Attr::ASYNCHRONOUS)) {
         messages.Warn(/*inModuleFile=*/false, context.languageFeatures(),
             common::UsageWarning::ImplicitInterfaceActual,
-            "Procedure with ASYNCHRONOUS argument '%s' should have an explicit interface"_warn_en_US,
+            "ASYNCHRONOUS actual argument '%s' should be passed via an explicit interface"_warn_en_US,
             expr->AsFortran());
       }
       if (symbol.attrs().test(Attr::VOLATILE)) {
         messages.Warn(/*inModuleFile=*/false, context.languageFeatures(),
             common::UsageWarning::ImplicitInterfaceActual,
-            "Procedure with VOLATILE argument '%s' should have an explicit interface"_warn_en_US,
+            "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/lib/Support/Fortran-features.cpp b/flang/lib/Support/Fortran-features.cpp
index 98faa2961fa32..a8fa4ac4a7afe 100644
--- a/flang/lib/Support/Fortran-features.cpp
+++ b/flang/lib/Support/Fortran-features.cpp
@@ -209,7 +209,6 @@ 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 4197de9a381e0..90e19180f9c56 100644
--- a/flang/test/Semantics/call13.f90
+++ b/flang/test/Semantics/call13.f90
@@ -7,10 +7,6 @@ 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
@@ -28,10 +24,6 @@ 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/call48.f90 b/flang/test/Semantics/call48.f90
new file mode 100644
index 0000000000000..61ac7a5cc3cfe
--- /dev/null
+++ b/flang/test/Semantics/call48.f90
@@ -0,0 +1,21 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
+! Regression test for llvm/llvm-project#191343
+
+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
diff --git a/flang/test/Semantics/generic11.f90 b/flang/test/Semantics/generic11.f90
index 7db8cc4866942..14383ab150fe4 100644
--- a/flang/test/Semantics/generic11.f90
+++ b/flang/test/Semantics/generic11.f90
@@ -16,7 +16,6 @@ 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



More information about the flang-commits mailing list