@@ -1085,11 +1085,8 @@ static hlfir::Entity fixProcedureDummyMismatch(mlir::Location loc,
10851085mlir::Value static getZeroLowerBounds (mlir::Location loc,
10861086 fir::FirOpBuilder &builder,
10871087 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" );
10931090 if (entity.getRank () < 1 )
10941091 return {};
10951092 mlir::Value zero =
@@ -1216,14 +1213,16 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
12161213 if (mustSetDynamicTypeToDummyType) {
12171214 // Note: this is important to do this before any copy-in or copy so
12181215 // 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" );
12221216 mlir::Type boxType = fir::BoxType::get (
12231217 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+ }
12271226 }
12281227 if (arg.hasValueAttribute () ||
12291228 // Constant expressions might be lowered as variables with
@@ -1330,19 +1329,19 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
13301329 if (needToAddAddendum || actualBoxHasAllocatableOrPointerFlag ||
13311330 needsZeroLowerBounds) {
13321331 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{})};
13391344 }
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{})};
13461345 }
13471346 addr = entity;
13481347 } else {
0 commit comments