Skip to content

Commit dbc24d3

Browse files
committed
[Flang] Add LIT test for NULLIFY statement for procedure pointer.
1 parent 61f97dd commit dbc24d3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

flang/lib/Lower/Bridge.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3099,7 +3099,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
30993099
Fortran::lower::StatementContext stmtCtx;
31003100
hlfir::Entity pptr = Fortran::lower::convertExprToHLFIR(
31013101
loc, *this, *expr, localSymbols, stmtCtx);
3102-
auto boxTy{Fortran::lower::getUntypedBoxProcType(&getMLIRContext())};
3102+
auto boxTy{
3103+
Fortran::lower::getUntypedBoxProcType(builder->getContext())};
31033104
hlfir::Entity nullBoxProc(
31043105
fir::factory::createNullBoxProc(*builder, loc, boxTy));
31053106
builder->createStoreWithConvert(loc, nullBoxProc, pptr);

flang/test/Lower/HLFIR/procedure-pointer.f90

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ subroutine sub3()
106106
! CHECK: %[[VAL_7:.*]] = fir.load %[[VAL_3]]#1 : !fir.ref<!fir.boxproc<(!fir.ref<f32>) -> f32>>
107107
! CHECK: %[[VAL_8:.*]] = fir.box_addr %[[VAL_7]] : (!fir.boxproc<(!fir.ref<f32>) -> f32>) -> ((!fir.ref<f32>) -> f32)
108108
! CHECK: %[[VAL_9:.*]] = fir.call %[[VAL_8]](%5#1) fastmath<contract> : (!fir.ref<f32>) -> f32
109+
110+
nullify(p1)
111+
! CHECK: %[[VAL_10:.*]] = fir.zero_bits () -> ()
112+
! CHECK: %[[VAL_11:.*]] = fir.emboxproc %[[VAL_10]] : (() -> ()) -> !fir.boxproc<() -> ()>
113+
! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (!fir.boxproc<() -> ()>) -> !fir.boxproc<(!fir.ref<f32>) -> f32>
114+
! CHECK: fir.store %[[VAL_12]] to %[[VAL_3]]#0 : !fir.ref<!fir.boxproc<(!fir.ref<f32>) -> f32>>
109115
end subroutine
110116

111117
subroutine sub4()

0 commit comments

Comments
 (0)