@@ -4029,14 +4029,12 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
4029
4029
LastField = nullptr;
4030
4030
if (ObjType->isArrayType()) {
4031
4031
// Next subobject is an array element.
4032
- const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(ObjType);
4033
- const IncompleteArrayType *IAT =
4034
- Info.Ctx.getAsIncompleteArrayType(ObjType);
4035
- const ArrayType *AT = CAT ? static_cast<const ArrayType *>(CAT)
4036
- : static_cast<const ArrayType *>(IAT);
4037
- assert(AT && "vla in literal type?");
4032
+ const ArrayType *AT = Info.Ctx.getAsArrayType(ObjType);
4033
+ assert((isa<ConstantArrayType>(AT) || isa<IncompleteArrayType>(AT)) &&
4034
+ "vla in literal type?");
4038
4035
uint64_t Index = Sub.Entries[I].getAsArrayIndex();
4039
- if (CAT && CAT->getSize().ule(Index)) {
4036
+ if (isa<ConstantArrayType>(AT) &&
4037
+ cast<ConstantArrayType>(AT)->getSize().ule(Index)) {
4040
4038
// Note, it should not be possible to form a pointer with a valid
4041
4039
// designator which points more than one past the end of the array.
4042
4040
if (Info.getLangOpts().CPlusPlus11)
@@ -4052,7 +4050,8 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
4052
4050
if (O->getArrayInitializedElts() > Index)
4053
4051
O = &O->getArrayInitializedElt(Index);
4054
4052
else if (!isRead(handler.AccessKind)) {
4055
- if (CAT && !CheckArraySize(Info, CAT, E->getExprLoc()))
4053
+ if (isa<ConstantArrayType>(AT) &&
4054
+ !CheckArraySize(Info, cast<ConstantArrayType>(AT), E->getExprLoc()))
4056
4055
return handler.failed();
4057
4056
4058
4057
expandArray(*O, Index);
0 commit comments