[flang-commits] [flang] [flang] Missing function-vs-subroutine checks on bindings (PR #177699)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Sun Jan 25 14:45:16 PST 2026


================
@@ -0,0 +1,80 @@
+!RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
+module m
+  type :: tbps
+   contains
+    procedure, nopass :: fprocf, fprocs, ffunc1, ffunc2, ffunc3, fsub
+   end type
+ contains
+  function fprocf()
+    procedure(), pointer :: fprocf
+    fprocf => func
+  end
+  function fprocs()
+    procedure(), pointer :: fprocs
+    fprocs => sub
+  end
+  function ffunc1()
+    procedure(), pointer :: ffunc1
+    real ffunc1
----------------
klausler wrote:

I think what may be confusing you is that Fortran has many ways of specifying some or all attributes of procedures, dummy procedures, and procedure pointers.  These all have the `EXTERNAL` attribute, which can be specified with the `EXTERNAL` statement, the procedure-declaration statement, or an interface block.  They can have the `POINTER` attribute, which can be its own attribute statement or an attribute on the procedure-declaration-stmt.  They can have explicit interfaces, via interface blocks or by an interface-name on the procedure-declaration statement, or they can be functions with implicit interfaces, so long as their result types are declared -- and that can be done via a type-declaration-stmt, implicit typing (if called), or by a type name in the procedure-declaration-stmt.  They can also be left unclassified, so that only their usage (if any) distinguishes functions from subroutines.

So `PROCEDURE(REAL), POINTER :: FFUNC1` is synonymous with `EXTERNAL FFUNC1; REAL FFUNC1; POINTER FFUNC1`.  They both mean the same thing -- `FFUNC1` is a pointer to a real-valued function with an implicit interface.

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


More information about the flang-commits mailing list