[flang-commits] [flang] [flang] More careful handling of PROCEDURE() components (PR #165468)

Eugene Epshteyn via flang-commits flang-commits at lists.llvm.org
Wed Oct 29 10:19:37 PDT 2025


================
@@ -9435,13 +9456,35 @@ bool ResolveNamesVisitor::SetProcFlag(
     SayWithDecl(name, symbol,
         "Implicit declaration of function '%s' has a different result type than in previous declaration"_err_en_US);
     return false;
-  } else if (symbol.has<ProcEntityDetails>()) {
-    symbol.set(flag); // in case it hasn't been set yet
-    if (flag == Symbol::Flag::Function) {
-      ApplyImplicitRules(symbol);
-    }
-    if (symbol.attrs().test(Attr::INTRINSIC)) {
-      AcquireIntrinsicProcedureFlags(symbol);
+  } else if (const auto *procDetails{symbol.detailsIf<ProcEntityDetails>()}) {
+    if (symbol.owner().IsDerivedType()) { // procedure pointer component
+      bool isFunction{IsFunction(symbol)};
+      const Symbol *explicitInterface{procDetails->procInterface()};
+      if (flag == Symbol::Flag::Function) {
+        if (!isFunction) {
+          SayWithDecl(name, symbol,
+              "Procedure pointer component '%s' was not declared to be a function"_err_en_US);
+        }
+      } else if (isFunction ||
+          (!explicitInterface &&
+              !context().IsEnabled(
+                  common::LanguageFeature::CallImplicitProcComponent))) {
+        SayWithDecl(name, symbol,
+            "Procedure pointer component '%s' was not declared to be a subroutine"_err_en_US);
----------------
eugeneepshteyn wrote:

I'm confused by this. Here `flag` is not function, so presumably it's subroutine? Or something else?

So if it's perhaps function with implicit interface, why is the error message "was not declared to be a subroutine"?  BTW, this error does not seem to be covered by the LIT test...

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


More information about the flang-commits mailing list