File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -2392,12 +2392,14 @@ class ScalarArrayExprLowering {
2392
2392
// 2) Lower the lhs expression to an array_update.
2393
2393
semant = ConstituentSemantics::ProjectedCopyInCopyOut;
2394
2394
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
+ }
2401
2403
return lexv;
2402
2404
}
2403
2405
You can’t perform that action at this time.
0 commit comments