[flang-commits] [flang] [Flang] Add partial support for lowering procedure pointer assignment. (PR #70461)

Daniel Chen via flang-commits flang-commits at lists.llvm.org
Mon Nov 6 12:11:54 PST 2023


================
@@ -248,8 +248,12 @@ struct TypeBuilderImpl {
     // links, the fir type is built based on the ultimate symbol. This relies
     // on the fact volatile and asynchronous are not reflected in fir types.
     const Fortran::semantics::Symbol &ultimate = symbol.GetUltimate();
-    if (Fortran::semantics::IsProcedurePointer(ultimate))
-      TODO(loc, "procedure pointers");
+
+    if (Fortran::semantics::IsProcedurePointer(ultimate)) {
+      Fortran::evaluate::ProcedureDesignator proc(ultimate);
+      return Fortran::lower::translateSignature(proc, converter);
----------------
DanielCChen wrote:

-- " I think we should use it everywhere and that it would probably be simpler to return the signature type wrapped in a fir.boxproc here."
Agreed. As a matter of fact, I need to make this return a `BoxProcType` to support procedure pointer function result.

-- "Using the "true" type in fir.boxproc for procedure pointers while it was not done for procedure dummies sounds OK to me: procedure pointers usually comes with a PROCEDURE interface while procedure dummies do not in old Fortran."
The problem is that `fir::store` requires the same memory type. If a procedure pointer as a "true" `BoxProcType`, it would requires the RHS (address of a procedure) to also have the "true" type. We currently use "empty" `BoxProcType` for getting the address of a procedure in `convertProcedureDesignatorToHLFIR`. Can we using "empty" type for now until we update both places?

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


More information about the flang-commits mailing list