@@ -1085,11 +1085,8 @@ static hlfir::Entity fixProcedureDummyMismatch(mlir::Location loc,
1085
1085
mlir::Value static getZeroLowerBounds (mlir::Location loc,
1086
1086
fir::FirOpBuilder &builder,
1087
1087
hlfir::Entity entity) {
1088
- // Assumed rank should not fall here, but better safe than sorry until
1089
- // implemented.
1090
- if (entity.isAssumedRank ())
1091
- TODO (loc, " setting lower bounds of assumed rank to zero before passing it "
1092
- " to BIND(C) procedure" );
1088
+ assert (!entity.isAssumedRank () &&
1089
+ " assumed-rank must use fir.rebox_assumed_rank" );
1093
1090
if (entity.getRank () < 1 )
1094
1091
return {};
1095
1092
mlir::Value zero =
@@ -1216,14 +1213,16 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
1216
1213
if (mustSetDynamicTypeToDummyType) {
1217
1214
// Note: this is important to do this before any copy-in or copy so
1218
1215
// that the dummy is contiguous according to the dummy type.
1219
- if (actualIsAssumedRank)
1220
- TODO (loc, " passing polymorphic assumed-rank to non polymorphic dummy "
1221
- " argument" );
1222
1216
mlir::Type boxType = fir::BoxType::get (
1223
1217
hlfir::getFortranElementOrSequenceType (dummyTypeWithActualRank));
1224
- entity = hlfir::Entity{builder.create <fir::ReboxOp>(
1225
- loc, boxType, entity, /* shape=*/ mlir::Value{},
1226
- /* slice=*/ mlir::Value{})};
1218
+ if (actualIsAssumedRank) {
1219
+ entity = hlfir::Entity{builder.create <fir::ReboxAssumedRankOp>(
1220
+ loc, boxType, entity, fir::LowerBoundModifierAttribute::SetToOnes)};
1221
+ } else {
1222
+ entity = hlfir::Entity{builder.create <fir::ReboxOp>(
1223
+ loc, boxType, entity, /* shape=*/ mlir::Value{},
1224
+ /* slice=*/ mlir::Value{})};
1225
+ }
1227
1226
}
1228
1227
if (arg.hasValueAttribute () ||
1229
1228
// Constant expressions might be lowered as variables with
@@ -1330,19 +1329,19 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
1330
1329
if (needToAddAddendum || actualBoxHasAllocatableOrPointerFlag ||
1331
1330
needsZeroLowerBounds) {
1332
1331
if (actualIsAssumedRank) {
1333
- if (needToAddAddendum)
1334
- TODO (loc, " passing intrinsic assumed-rank to unlimited polymorphic "
1335
- " assumed-rank" );
1336
- else
1337
- TODO (loc, " passing pointer or allocatable assumed-rank to non "
1338
- " pointer non allocatable assumed-rank" );
1332
+ auto lbModifier = needsZeroLowerBounds
1333
+ ? fir::LowerBoundModifierAttribute::SetToZeroes
1334
+ : fir::LowerBoundModifierAttribute::SetToOnes;
1335
+ entity = hlfir::Entity{builder.create <fir::ReboxAssumedRankOp>(
1336
+ loc, dummyTypeWithActualRank, entity, lbModifier)};
1337
+ } else {
1338
+ mlir::Value shift{};
1339
+ if (needsZeroLowerBounds)
1340
+ shift = getZeroLowerBounds (loc, builder, entity);
1341
+ entity = hlfir::Entity{builder.create <fir::ReboxOp>(
1342
+ loc, dummyTypeWithActualRank, entity, /* shape=*/ shift,
1343
+ /* slice=*/ mlir::Value{})};
1339
1344
}
1340
- mlir::Value shift{};
1341
- if (needsZeroLowerBounds)
1342
- shift = getZeroLowerBounds (loc, builder, entity);
1343
- entity = hlfir::Entity{builder.create <fir::ReboxOp>(
1344
- loc, dummyTypeWithActualRank, entity, /* shape=*/ shift,
1345
- /* slice=*/ mlir::Value{})};
1346
1345
}
1347
1346
addr = entity;
1348
1347
} else {
0 commit comments