diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-11-07 13:01:22 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-11-07 13:01:22 +0000 |
commit | 48c2e909741a7b67ead01143edabd7b3fe42ee50 (patch) | |
tree | f286e12da32b3220ffb617c7144e68f79a581c39 | |
parent | bf8cb361038c71a76f8ffa0f9986cebc43732e87 (diff) |
Fix crash caused by this:
void f() {
int +; // crash here
}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58846 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 4 | ||||
-rw-r--r-- | test/Sema/init.c | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 3e4e2c5b2c..fd94c80d8b 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1639,6 +1639,10 @@ void Sema::AddInitializerToDecl(DeclTy *dcl, ExprTy *init) { void Sema::ActOnUninitializedDecl(DeclTy *dcl) { Decl *RealDecl = static_cast<Decl *>(dcl); + // If there is no declaration, there was an error parsing it. Just ignore it. + if (RealDecl == 0) + return; + if (VarDecl *Var = dyn_cast<VarDecl>(RealDecl)) { QualType Type = Var->getType(); // C++ [dcl.init.ref]p3: diff --git a/test/Sema/init.c b/test/Sema/init.c index a078a2a96b..c08500834f 100644 --- a/test/Sema/init.c +++ b/test/Sema/init.c @@ -16,6 +16,7 @@ int *h = &x; int test() { int a[10]; int b[10] = a; // expected-error {{initialization with "{...}" expected}} +int +; // expected-error {{expected identifier or '('}} expected-error {{declarator requires an identifier}} expected-error {{parse error}} } |