|
14 | 14 | #include "flang/Evaluate/expression.h"
|
15 | 15 | #include "flang/Lower/AbstractConverter.h"
|
16 | 16 | #include "flang/Lower/BuiltinModules.h"
|
| 17 | +#include "flang/Lower/ConvertExprToHLFIR.h" |
17 | 18 | #include "flang/Lower/ConvertType.h"
|
18 | 19 | #include "flang/Lower/ConvertVariable.h"
|
19 | 20 | #include "flang/Lower/Mangler.h"
|
| 21 | +#include "flang/Lower/StatementContext.h" |
| 22 | +#include "flang/Lower/SymbolMap.h" |
20 | 23 | #include "flang/Optimizer/Builder/Complex.h"
|
21 | 24 | #include "flang/Optimizer/Builder/MutableBox.h"
|
22 | 25 | #include "flang/Optimizer/Builder/Todo.h"
|
@@ -380,10 +383,21 @@ static mlir::Value genStructureComponentInit(
|
380 | 383 | }
|
381 | 384 |
|
382 | 385 | if (Fortran::semantics::IsPointer(sym)) {
|
383 |
| - if (Fortran::semantics::IsProcedure(sym)) |
384 |
| - TODO(loc, "procedure pointer component initial value"); |
385 |
| - mlir::Value initialTarget = |
386 |
| - Fortran::lower::genInitialDataTarget(converter, loc, componentTy, expr); |
| 386 | + mlir::Value initialTarget; |
| 387 | + if (Fortran::semantics::IsProcedure(sym)) { |
| 388 | + if (Fortran::evaluate::UnwrapExpr<Fortran::evaluate::NullPointer>(expr)) |
| 389 | + initialTarget = |
| 390 | + fir::factory::createNullBoxProc(builder, loc, componentTy); |
| 391 | + else { |
| 392 | + Fortran::lower::SymMap globalOpSymMap; |
| 393 | + Fortran::lower::StatementContext stmtCtx; |
| 394 | + auto box{getBase(Fortran::lower::convertExprToAddress( |
| 395 | + loc, converter, expr, globalOpSymMap, stmtCtx))}; |
| 396 | + initialTarget = builder.createConvert(loc, componentTy, box); |
| 397 | + } |
| 398 | + } else |
| 399 | + initialTarget = Fortran::lower::genInitialDataTarget(converter, loc, |
| 400 | + componentTy, expr); |
387 | 401 | res = builder.create<fir::InsertValueOp>(
|
388 | 402 | loc, recTy, res, initialTarget,
|
389 | 403 | builder.getArrayAttr(field.getAttributes()));
|
|
0 commit comments