mirror of https://github.com/microsoft/clang.git
PR35214: don't crash if we see an array of unknown bound added to an empty but invalid designator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318258 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fc25bec207
commit
7c604e87f1
|
@ -1351,10 +1351,11 @@ namespace {
|
|||
Designator.setInvalid();
|
||||
return;
|
||||
}
|
||||
|
||||
assert(getType(Base)->isPointerType() || getType(Base)->isArrayType());
|
||||
Designator.FirstEntryIsAnUnsizedArray = true;
|
||||
Designator.addUnsizedArrayUnchecked(ElemTy);
|
||||
if (checkSubobject(Info, E, CSK_ArrayToPointer)) {
|
||||
assert(getType(Base)->isPointerType() || getType(Base)->isArrayType());
|
||||
Designator.FirstEntryIsAnUnsizedArray = true;
|
||||
Designator.addUnsizedArrayUnchecked(ElemTy);
|
||||
}
|
||||
}
|
||||
void addArray(EvalInfo &Info, const Expr *E, const ConstantArrayType *CAT) {
|
||||
if (checkSubobject(Info, E, CSK_ArrayToPointer))
|
||||
|
|
|
@ -144,3 +144,11 @@ void *PR28739a = (__int128)(unsigned long)-1 + &PR28739a;
|
|||
void *PR28739b = &PR28739b + (__int128)(unsigned long)-1;
|
||||
__int128 PR28739c = (&PR28739c + (__int128)(unsigned long)-1) - &PR28739c;
|
||||
void *PR28739d = &(&PR28739d)[(__int128)(unsigned long)-1];
|
||||
|
||||
struct PR35214_X {
|
||||
int k;
|
||||
int arr[];
|
||||
};
|
||||
int PR35214_x;
|
||||
int PR35214_y = ((struct PR35214_X *)&PR35214_x)->arr[1]; // expected-error {{not a compile-time constant}}
|
||||
int *PR35214_z = &((struct PR35214_X *)&PR35214_x)->arr[1]; // ok, &PR35214_x + 2
|
||||
|
|
Loading…
Reference in New Issue