PR2347: Fix crash iterating over VLAs; this started triggering because

we now iterate over the whole AST when we destroy it.

llvm-svn: 51363
This commit is contained in:
Eli Friedman 2008-05-21 05:06:46 +00:00
parent 14b2993484
commit 0883bfb541
2 changed files with 12 additions and 5 deletions

View File

@ -36,16 +36,16 @@ void StmtIteratorBase::NextVA() {
p = FindVA(p->getElementType().getTypePtr());
setVAPtr(p);
if (!p && decl) {
if (!p && inDecl()) {
if (VarDecl* VD = dyn_cast<VarDecl>(decl))
if (VD->Init)
return;
NextDecl();
}
else {
} else if (inSizeOfTypeVA()) {
assert(!decl);
RawVAPtr = 0;
}
}
}
void StmtIteratorBase::NextDecl(bool ImmediateAdvance) {
@ -101,7 +101,6 @@ StmtIteratorBase::StmtIteratorBase(VariableArrayType* t)
RawVAPtr |= reinterpret_cast<uintptr_t>(t);
}
Stmt*& StmtIteratorBase::GetDeclExpr() const {
if (VariableArrayType* VAPtr = getVAPtr()) {
assert (VAPtr->SizeExpr);

View File

@ -5,3 +5,11 @@ int test1() {
static int y = sizeof(x); // expected-error {{not constant}}
}
// PR2347
void f (unsigned int m)
{
extern int e[2][m];
e[0][0] = 0;
}