[cfe-commits] r148074 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/SemaObjC/severe-syntax-error.m
Fariborz Jahanian
fjahanian at apple.com
Thu Jan 12 16:14:12 PST 2012
Author: fjahanian
Date: Thu Jan 12 18:14:12 2012
New Revision: 148074
URL: http://llvm.org/viewvc/llvm-project?rev=148074&view=rev
Log:
objc parsing. Fixes a crash when parsing array initialization
inside a class implementation with parse errors. // rdar://10633434
Added:
cfe/trunk/test/SemaObjC/severe-syntax-error.m
Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=148074&r1=148073&r2=148074&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Jan 12 18:14:12 2012
@@ -1150,11 +1150,12 @@
MaybeParseGNUAttributes(D);
ParseDeclarator(D);
-
- Decl *ThisDecl = ParseDeclarationAfterDeclarator(D);
- D.complete(ThisDecl);
- if (ThisDecl)
- DeclsInGroup.push_back(ThisDecl);
+ if (!D.isInvalidType()) {
+ Decl *ThisDecl = ParseDeclarationAfterDeclarator(D);
+ D.complete(ThisDecl);
+ if (ThisDecl)
+ DeclsInGroup.push_back(ThisDecl);
+ }
}
if (DeclEnd)
Added: cfe/trunk/test/SemaObjC/severe-syntax-error.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/severe-syntax-error.m?rev=148074&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/severe-syntax-error.m (added)
+++ cfe/trunk/test/SemaObjC/severe-syntax-error.m Thu Jan 12 18:14:12 2012
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://10633434
+
+ at interface testClass
+ at end
+
+ at class NSArray;
+
+ at implementation testClass
+
+static NSArray* prefixArray[] = @"BEGIN:", @"END:", @"VERSION:", @"N:", @"FN:", @"TEL;", @"TEL:", nil; // expected-error {{array initializer must be an initializer list}} \
+ // expected-error {{expected identifier or '('}} \
+ // expected-error {{expected ';' after top level declarator}}
+
+static NSString* prefixArray1[] = @"BEGIN:", @"END:", @"VERSION:", @"N:", @"FN:", @"TEL;", @"TEL:", nil; // expected-error {{unknown type name 'NSString'}} \
+ // expected-error {{expected identifier or '('}} \
+ // expected-error {{expected ';' after top level declarator}}
+
+static char* cArray[] = "BEGIN:", "END"; // expected-error {{array initializer must be an initializer list}} \
+ // expected-error {{expected identifier or '('}} \
+ // expected-error {{expected ';' after top level declarator}}
+
+ at end
More information about the cfe-commits
mailing list