[cfe-commits] r58846 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/init.c
Argiris Kirtzidis
akyrtzi at gmail.com
Fri Nov 7 05:01:23 PST 2008
Author: akirtzidis
Date: Fri Nov 7 07:01:22 2008
New Revision: 58846
URL: http://llvm.org/viewvc/llvm-project?rev=58846&view=rev
Log:
Fix crash caused by this:
void f() {
int +; // crash here
}
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/init.c
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=58846&r1=58845&r2=58846&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Nov 7 07:01:22 2008
@@ -1639,6 +1639,10 @@
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:
Modified: cfe/trunk/test/Sema/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/init.c?rev=58846&r1=58845&r2=58846&view=diff
==============================================================================
--- cfe/trunk/test/Sema/init.c (original)
+++ cfe/trunk/test/Sema/init.c Fri Nov 7 07:01:22 2008
@@ -16,6 +16,7 @@
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}}
}
More information about the cfe-commits
mailing list