fix a valgrind problem I noticed while developing another patch,

if a decl is invalid, it isn't added to the Decls array, so we
need to pass in Decls.size() to avoid reading uninit memory.

llvm-svn: 68913
This commit is contained in:
Chris Lattner 2009-04-12 20:51:10 +00:00
parent 109af6232b
commit 14bdb78430
2 changed files with 5 additions and 1 deletions

View File

@ -2620,7 +2620,7 @@ Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, DeclPtrTy *Group,
}
}
return DeclGroupPtrTy::make(DeclGroupRef::Create(Context,
&Decls[0], NumDecls));
&Decls[0], Decls.size()));
}

View File

@ -8,6 +8,10 @@ typedef union <anonymous> __mbstate_t; // expected-error {{declaration of anony
void x();
int a() {
int r[x()]; // expected-error {{size of array has non-integer type 'void'}}
static y ?; // expected-error{{unknown type name 'y'}} \
expected-error{{expected identifier or '('}} \
expected-error{{expected ';' at end of declaration}}
}
int; // expected-error {{declaration does not declare anything}}