Skip to content

Commit d617316

Browse files
authored
[Flang] Get fir::SequenceType from hlfir::ExprType before getShape. (#90055)
This PR is to fix issue #88889 . Because the type of an actual argument of an array expression of character has type of `hlfir::ExprType`, we need to transform it to `fir::SequenceType` before calling `getBoxTypeWithNewShape`. Calling `hlfir::ExprType::getShape` inside of `getBoxTypeWithNewShape` will introduce a circular dependency on FIRDialect and HLFIRDialect libraries.
1 parent 3fe282a commit d617316

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

flang/lib/Lower/ConvertCall.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,12 +1184,15 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
11841184
// actual argument shape information. A descriptor with the dummy shape
11851185
// information will be created later when all actual arguments are ready.
11861186
mlir::Type dummyTypeWithActualRank = dummyType;
1187-
if (auto baseBoxDummy = mlir::dyn_cast<fir::BaseBoxType>(dummyType))
1187+
if (auto baseBoxDummy = mlir::dyn_cast<fir::BaseBoxType>(dummyType)) {
11881188
if (baseBoxDummy.isAssumedRank() ||
11891189
arg.testTKR(Fortran::common::IgnoreTKR::Rank) ||
1190-
arg.isSequenceAssociatedDescriptor())
1191-
dummyTypeWithActualRank =
1192-
baseBoxDummy.getBoxTypeWithNewShape(actual.getType());
1190+
arg.isSequenceAssociatedDescriptor()) {
1191+
mlir::Type actualTy =
1192+
hlfir::getFortranElementOrSequenceType(actual.getType());
1193+
dummyTypeWithActualRank = baseBoxDummy.getBoxTypeWithNewShape(actualTy);
1194+
}
1195+
}
11931196
// Preserve the actual type in the argument preparation in case IgnoreTKR(t)
11941197
// is set (descriptors must be created with the actual type in this case, and
11951198
// copy-in/copy-out should be driven by the contiguity with regard to the

0 commit comments

Comments
 (0)