================
@@ -4030,10 +4030,12 @@ findSubobject(EvalInfo &Info, const Expr *E, const
CompleteObject &Obj,
LastField = nullptr;
if (ObjType->isArrayType()) {
// Next subobject is an array element.
- const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(ObjType);
- assert(CAT && "vla in literal type?");
+ const ArrayType *AT = Info.Ctx.getAsArrayType(ObjType);
+ assert((isa<ConstantArrayType>(AT) || isa<IncompleteArrayType>(AT)) &&
+ "vla in literal type?");
uint64_t Index = Sub.Entries[I].getAsArrayIndex();
- if (CAT->getSize().ule(Index)) {
+ if (const auto *CAT = dyn_cast<ConstantArrayType>(AT);
+ CAT && CAT->getSize().ule(Index)) {
----------------
HerrCai0907 wrote:
according to spec, here should be unknown bound array.
But you are write, here we should forbidden to do constant calculation for
incomplete array type. But also we cannot simply convert it to complete array
type.
I think gcc does correct here https://godbolt.org/z/41fK7hjxW.
Maybe we can return false for incomplete array type?
https://github.com/llvm/llvm-project/pull/155080
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits