diff --git a/flang/lib/Evaluate/fold-implementation.h b/flang/lib/Evaluate/fold-implementation.h index 34f79f9e6f25b4..093f26bea1a44f 100644 --- a/flang/lib/Evaluate/fold-implementation.h +++ b/flang/lib/Evaluate/fold-implementation.h @@ -201,11 +201,12 @@ std::optional> Folder::ApplySubscripts(const Constant &array, ConstantSubscripts resultShape; ConstantSubscripts ssLB; for (const auto &ss : subscripts) { - CHECK(ss.Rank() <= 1); if (ss.Rank() == 1) { resultShape.push_back(static_cast(ss.size())); elements *= ss.size(); ssLB.push_back(ss.lbounds().front()); + } else if (ss.Rank() > 1) { + return std::nullopt; // error recovery } } ConstantSubscripts ssAt(rank, 0), at(rank, 0), tmp(1, 0);