Skip to content

Commit d3c498a

Browse files
authored
Merge pull request #1039 from schweitzpgi/ch-p9
Fix array value threading to allow degenerate assignments. The front end
2 parents 8fe40e0 + 0648a81 commit d3c498a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

flang/lib/Lower/ConvertExpr.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,12 +2392,14 @@ class ScalarArrayExprLowering {
23922392
// 2) Lower the lhs expression to an array_update.
23932393
semant = ConstituentSemantics::ProjectedCopyInCopyOut;
23942394
auto lexv = lower(lhs);
2395-
// 3) Thread the array value updated forward
2396-
auto oldInnerArg =
2397-
mlir::cast<fir::ArrayUpdateOp>(fir::getBase(lexv).getDefiningOp())
2398-
.sequence();
2399-
auto offset = expSpace.argPosition(oldInnerArg);
2400-
expSpace.setInnerArg(offset, fir::getBase(lexv));
2395+
// 3) Thread the array value updated forward. Note: the lhs might be
2396+
// ill-formed, in which case there is no array to thread.
2397+
if (auto updateOp = mlir::dyn_cast<fir::ArrayUpdateOp>(
2398+
fir::getBase(lexv).getDefiningOp())) {
2399+
auto oldInnerArg = updateOp.sequence();
2400+
auto offset = expSpace.argPosition(oldInnerArg);
2401+
expSpace.setInnerArg(offset, fir::getBase(lexv));
2402+
}
24012403
return lexv;
24022404
}
24032405

0 commit comments

Comments
 (0)