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

via flang-commits flang-commits at lists.llvm.org
Fri Oct 27 09:00:39 PDT 2023


================
@@ -3224,8 +3224,13 @@ class FirConverter : public Fortran::lower::AbstractConverter {
       mlir::Location loc, const Fortran::evaluate::Assignment &assign,
       const Fortran::evaluate::Assignment::BoundsSpec &lbExprs) {
     Fortran::lower::StatementContext stmtCtx;
-    if (Fortran::evaluate::IsProcedure(assign.rhs))
-      TODO(loc, "procedure pointer assignment");
+
+    if (Fortran::evaluate::IsProcedure(assign.rhs)) {
+      auto lhs{fir::getBase(genExprAddr(assign.lhs, stmtCtx, &loc))};
+      auto rhs{fir::getBase(genExprAddr(assign.rhs, stmtCtx, &loc))};
----------------
jeanPerier wrote:

You may need to dereference the RHS here if it is itself a procedure pointer. In general, this deference would need to be centralized or inserted at each place that are currently using ProcedureDesignator (like when passing a pointer procedure to a non pointer procedure dummy).

The best may be to ensure that [hlfir::derefPointersAndAllocatables](https://github.com/llvm/llvm-project/blob/58bdd165d505f3993d15442afd2286c4deedcba2/flang/include/flang/Optimizer/Builder/HLFIRTools.h#L271) works with them and to use that here with the RHS (and use that if it is not used in other places where that is needed).

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


More information about the flang-commits mailing list