[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
Wed Nov 8 08:56:39 PST 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))};
----------------
DanielCChen wrote:
I adopted your suggestion to have
```
if (Fortran::evaluate::IsProcedurePointerTarget(assign.rhs)) {
hlfir::Entity lhs = Fortran::lower::convertExprToHLFIR(
loc, *this, assign.lhs, localSymbols, stmtCtx);
hlfir::Entity rhs = Fortran::lower::convertExprToHLFIR(
loc, *this, assign.rhs, localSymbols, stmtCtx);
rhs = hlfir::derefPointersAndAllocatables(loc, *builder, rhs);
builder->createStoreWithConvert(loc, rhs, lhs);
return;
}
```
I ran into the following issue when do `pptr => foo()` where `foo` returns a procedure pointer.
```
flang/lib/Lower/ConvertExprToHLFIR.cpp:1428: not yet implemented: lowering ProcRef to HLFIR
```
Is lowering ProcRef being worked on?
https://github.com/llvm/llvm-project/pull/70461
More information about the flang-commits
mailing list