[cfe-commits] r160789 - in /cfe/trunk: lib/Parse/ParseObjc.cpp test/Parser/missing-selector-name.mm
Fariborz Jahanian
fjahanian at apple.com
Thu Jul 26 10:32:28 PDT 2012
Author: fjahanian
Date: Thu Jul 26 12:32:28 2012
New Revision: 160789
URL: http://llvm.org/viewvc/llvm-project?rev=160789&view=rev
Log:
objective-c parsing. Don't crash when selector name
is missing in method prototype. // rdar://11939584
Added:
cfe/trunk/test/Parser/missing-selector-name.mm
Modified:
cfe/trunk/lib/Parse/ParseObjc.cpp
Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=160789&r1=160788&r2=160789&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Jul 26 12:32:28 2012
@@ -375,9 +375,9 @@
while (1) {
// If this is a method prototype, parse it.
if (Tok.is(tok::minus) || Tok.is(tok::plus)) {
- Decl *methodPrototype =
- ParseObjCMethodPrototype(MethodImplKind, false);
- allMethods.push_back(methodPrototype);
+ if (Decl *methodPrototype =
+ ParseObjCMethodPrototype(MethodImplKind, false))
+ allMethods.push_back(methodPrototype);
// Consume the ';' here, since ParseObjCMethodPrototype() is re-used for
// method definitions.
if (ExpectAndConsumeSemi(diag::err_expected_semi_after_method_proto)) {
@@ -1001,8 +1001,8 @@
if (!SelIdent && Tok.isNot(tok::colon)) { // missing selector name.
Diag(Tok, diag::err_expected_selector_for_method)
<< SourceRange(mLoc, Tok.getLocation());
- // Skip until we get a ; or {}.
- SkipUntil(tok::r_brace);
+ // Skip until we get a ; or @.
+ SkipUntil(tok::at, true /*StopAtSemi*/, true /*don't consume*/);
return 0;
}
Added: cfe/trunk/test/Parser/missing-selector-name.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/missing-selector-name.mm?rev=160789&view=auto
==============================================================================
--- cfe/trunk/test/Parser/missing-selector-name.mm (added)
+++ cfe/trunk/test/Parser/missing-selector-name.mm Thu Jul 26 12:32:28 2012
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://11939584
+
+ at interface PodiumWalkerController
+ at property (assign) id PROP;
+- (void) // expected-error {{expected ';' after method prototype}}
+ at end // expected-error {{expected selector for Objective-C method}}
+
+
+id GVAR;
+
+id StopProgressAnimation()
+{
+
+ PodiumWalkerController *controller;
+ return controller.PROP;
+}
+
+ at interface P1
+ at property (assign) id PROP;
+- (void); // expected-error {{expected selector for Objective-C method}}
+ at end
+
+id GG=0;
+
+id Stop1()
+{
+
+ PodiumWalkerController *controller;
+ return controller.PROP;
+}
+
+ at interface P2
+ at property (assign) id PROP;
+- (void)Meth {} // expected-error {{expected ';' after method prototype}}
+ at end
+
+ at interface P3
+ at property (assign) id PROP;
+- (void)
+- (void)Meth {} // expected-error {{expected selector for Objective-C method}} \
+ // expected-error {{expected ';' after method prototype}}
+ at end
+
+id HH=0;
+
+id Stop2()
+{
+
+ PodiumWalkerController *controller;
+ return controller.PROP;
+}
More information about the cfe-commits
mailing list