Fix a crash on test/Sema/invalid-decl.c

llvm-svn: 43188
This commit is contained in:
Chris Lattner 2007-10-19 20:10:30 +00:00
parent b5bc897864
commit 8beb9dee0e
2 changed files with 14 additions and 1 deletions

View File

@ -635,8 +635,14 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) {
void Sema::AddInitializerToDecl(DeclTy *dcl, ExprTy *init) {
Decl *RealDecl = static_cast<Decl *>(dcl);
Expr *Init = static_cast<Expr *>(init);
assert(Init && "missing initializer");
assert((RealDecl && Init) && "missing decl or initializer");
// If there is no declaration, there was an error parsing it. Just ignore
// the initializer.
if (RealDecl == 0) {
delete Init;
return;
}
VarDecl *VDecl = dyn_cast<VarDecl>(RealDecl);
if (!VDecl) {

View File

@ -0,0 +1,7 @@
void test() {
char = 4; // expected-error {{expected identifier}} expected-error{{declarator requires an identifier}}
}