@@ -874,27 +874,39 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
874
874
// element if this is an array in an elemental call.
875
875
hlfir::Entity actual = preparedActual.getActual (loc, builder);
876
876
877
- // Handles the procedure pointer actual arguments.
877
+ // Handle the procedure pointer actual arguments.
878
878
if (actual.isProcedurePointer ()) {
879
+ // Procedure pointer actual to procedure pointer dummy.
879
880
if (hlfir::isBoxProcAddressType (dummyType))
880
- // Procedure pointer actual to procedure pointer dummy.
881
881
return PreparedDummyArgument{actual, /* cleanups=*/ {}};
882
+ // Procedure pointer actual to procedure dummy.
882
883
if (hlfir::isFortranProcedureValue (dummyType)) {
883
- // Procedure pointer actual to procedure dummy.
884
884
actual = hlfir::derefPointersAndAllocatables (loc, builder, actual);
885
885
return PreparedDummyArgument{actual, /* cleanups=*/ {}};
886
886
}
887
887
}
888
888
889
- // Do nothing if this is a procedure argument. It is already a
890
- // fir.boxproc/fir.tuple<fir.boxproc, len> as it should.
889
+ // NULL() actual to procedure pointer dummy
890
+ if (Fortran::evaluate::IsNullProcedurePointer (expr) &&
891
+ hlfir::isBoxProcAddressType (dummyType)) {
892
+ auto boxTy{Fortran::lower::getUntypedBoxProcType (builder.getContext ())};
893
+ auto tempBoxProc{builder.createTemporary (loc, boxTy)};
894
+ hlfir::Entity nullBoxProc (
895
+ fir::factory::createNullBoxProc (builder, loc, boxTy));
896
+ builder.create <fir::StoreOp>(loc, nullBoxProc, tempBoxProc);
897
+ return PreparedDummyArgument{tempBoxProc, /* cleanups=*/ {}};
898
+ }
899
+
891
900
if (actual.isProcedure ()) {
901
+ // Procedure actual to procedure pointer dummy.
892
902
if (hlfir::isBoxProcAddressType (dummyType)) {
893
- // Procedure actual to procedure pointer dummy.
894
903
auto tempBoxProc{builder.createTemporary (loc, actual.getType ())};
895
904
builder.create <fir::StoreOp>(loc, actual, tempBoxProc);
896
905
return PreparedDummyArgument{tempBoxProc, /* cleanups=*/ {}};
897
906
}
907
+ // Procedure actual to procedure dummy.
908
+ // Do nothing if this is a procedure argument. It is already a
909
+ // fir.boxproc/fir.tuple<fir.boxproc, len> as it should.
898
910
if (actual.getType () != dummyType)
899
911
actual = fixProcedureDummyMismatch (loc, builder, actual, dummyType);
900
912
return PreparedDummyArgument{actual, /* cleanups=*/ {}};
0 commit comments