@@ -4353,8 +4353,6 @@ class FirConverter : public Fortran::lower::AbstractConverter {
43534353 void genForallPointerAssignment (
43544354 mlir::Location loc, const Fortran::evaluate::Assignment &assign,
43554355 const Fortran::evaluate::Assignment::BoundsSpec &lbExprs) {
4356- if (Fortran::evaluate::IsProcedureDesignator (assign.rhs ))
4357- TODO (loc, " procedure pointer assignment inside FORALL" );
43584356 std::optional<Fortran::evaluate::DynamicType> lhsType =
43594357 assign.lhs .GetType ();
43604358 // Polymorphic pointer assignment is delegated to the runtime, and
@@ -4383,27 +4381,38 @@ class FirConverter : public Fortran::lower::AbstractConverter {
43834381 Fortran::lower::StatementContext lhsContext;
43844382 hlfir::Entity lhs = Fortran::lower::convertExprToHLFIR (
43854383 loc, *this , assign.lhs , localSymbols, lhsContext);
4386-
43874384 auto lhsYieldOp = builder->create <hlfir::YieldOp>(loc, lhs);
43884385 Fortran::lower::genCleanUpInRegionIfAny (
43894386 loc, *builder, lhsYieldOp.getCleanup (), lhsContext);
43904387
43914388 // Lower RHS in its own region.
43924389 builder->createBlock (®ionAssignOp.getRhsRegion ());
43934390 Fortran::lower::StatementContext rhsContext;
4391+ mlir::Value rhs =
4392+ genForallPointerAssignmentRhs (loc, lhs, assign, rhsContext);
4393+ auto rhsYieldOp = builder->create <hlfir::YieldOp>(loc, rhs);
4394+ Fortran::lower::genCleanUpInRegionIfAny (
4395+ loc, *builder, rhsYieldOp.getCleanup (), rhsContext);
4396+
4397+ builder->setInsertionPointAfter (regionAssignOp);
4398+ }
4399+
4400+ mlir::Value
4401+ genForallPointerAssignmentRhs (mlir::Location loc, mlir::Value lhs,
4402+ const Fortran::evaluate::Assignment &assign,
4403+ Fortran::lower::StatementContext &rhsContext) {
4404+ if (Fortran::evaluate::IsProcedureDesignator (assign.rhs ))
4405+ return fir::getBase (Fortran::lower::convertExprToAddress (
4406+ loc, *this , assign.rhs , localSymbols, rhsContext));
4407+ // Data target.
43944408 hlfir::Entity rhs = Fortran::lower::convertExprToHLFIR (
43954409 loc, *this , assign.rhs , localSymbols, rhsContext);
43964410 // Create pointer descriptor value from the RHS.
43974411 if (rhs.isMutableBox ())
43984412 rhs = hlfir::Entity{builder->create <fir::LoadOp>(loc, rhs)};
43994413 auto lhsBoxType =
44004414 llvm::cast<fir::BaseBoxType>(fir::unwrapRefType (lhs.getType ()));
4401- mlir::Value newBox = hlfir::genVariableBox (loc, *builder, rhs, lhsBoxType);
4402- auto rhsYieldOp = builder->create <hlfir::YieldOp>(loc, newBox);
4403- Fortran::lower::genCleanUpInRegionIfAny (
4404- loc, *builder, rhsYieldOp.getCleanup (), rhsContext);
4405-
4406- builder->setInsertionPointAfter (regionAssignOp);
4415+ return hlfir::genVariableBox (loc, *builder, rhs, lhsBoxType);
44074416 }
44084417
44094418 // Create the 2 x newRank array with the bounds to be passed to the runtime as
0 commit comments