[cfe-commits] r122855 - in /cfe/trunk: lib/Parse/ParseObjc.cpp test/Parser/objc-property-syntax.m test/Parser/objc-quirks.m

Douglas Gregor dgregor at apple.com
Tue Jan 4 17:10:06 PST 2011


Author: dgregor
Date: Tue Jan  4 19:10:06 2011
New Revision: 122855

URL: http://llvm.org/viewvc/llvm-project?rev=122855&view=rev
Log:
Use Parser::ExpectAndConsume() uniformly to eat semicolons after
Objective-C declarations and statements. Fixes
<rdar://problem/8814576> (wrong source line for diagnostics about
missing ';'), and now we actually consume the ';' at the end of a
@compatibility_alias directive!

Modified:
    cfe/trunk/lib/Parse/ParseObjc.cpp
    cfe/trunk/test/Parser/objc-property-syntax.m
    cfe/trunk/test/Parser/objc-quirks.m

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=122855&r1=122854&r2=122855&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Tue Jan  4 19:10:06 2011
@@ -1398,10 +1398,8 @@
   }
   IdentifierInfo *classId = Tok.getIdentifierInfo();
   SourceLocation classLoc = ConsumeToken(); // consume class-name;
-  if (Tok.isNot(tok::semi)) {
-    Diag(Tok, diag::err_expected_semi_after) << "@compatibility_alias";
-    return 0;
-  }
+  ExpectAndConsume(tok::semi, diag::err_expected_semi_after, 
+                   "@compatibility_alias");
   return Actions.ActOnCompatiblityAlias(atLoc, aliasId, aliasLoc,
                                         classId, classLoc);
 }
@@ -1461,12 +1459,7 @@
       break;
     ConsumeToken(); // consume ','
   }
-  if (Tok.isNot(tok::semi)) {
-    Diag(Tok, diag::err_expected_semi_after) << "@synthesize";
-    SkipUntil(tok::semi);
-  }
-  else
-    ConsumeToken(); // consume ';'
+  ExpectAndConsume(tok::semi, diag::err_expected_semi_after, "@synthesize");
   return 0;
 }
 
@@ -1502,12 +1495,7 @@
       break;
     ConsumeToken(); // consume ','
   }
-  if (Tok.isNot(tok::semi)) {
-    Diag(Tok, diag::err_expected_semi_after) << "@dynamic";
-    SkipUntil(tok::semi);
-  }
-  else
-    ConsumeToken(); // consume ';'
+  ExpectAndConsume(tok::semi, diag::err_expected_semi_after, "@dynamic");
   return 0;
 }
 

Modified: cfe/trunk/test/Parser/objc-property-syntax.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-property-syntax.m?rev=122855&r1=122854&r2=122855&view=diff
==============================================================================
--- cfe/trunk/test/Parser/objc-property-syntax.m (original)
+++ cfe/trunk/test/Parser/objc-property-syntax.m Tue Jan  4 19:10:06 2011
@@ -1,14 +1,17 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
 @interface MyClass {
-
+  int prop;
 };
 @property unsigned char bufferedUTF8Bytes[4];  // expected-error {{property cannot have array or function type}}
 @property unsigned char bufferedUTFBytes:1;    // expected-error {{property name cannot be a bitfield}}
 @property(nonatomic, retain, setter=ab_setDefaultToolbarItems) MyClass *ab_defaultToolbarItems; // expected-error {{method name referenced in property setter attribute must end with ':'}}
+
+ at property int prop;
 @end
 
 @implementation MyClass
- at dynamic ab_defaultToolbarItems;
+ at dynamic ab_defaultToolbarItems // expected-error{{expected ';' after @dynamic}}
+ at synthesize prop // expected-error{{expected ';' after @synthesize}}
 @end
 

Modified: cfe/trunk/test/Parser/objc-quirks.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-quirks.m?rev=122855&r1=122854&r2=122855&view=diff
==============================================================================
--- cfe/trunk/test/Parser/objc-quirks.m (original)
+++ cfe/trunk/test/Parser/objc-quirks.m Tue Jan  4 19:10:06 2011
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
 
 // FIXME: This is a horrible error message here. Fix.
 int @"s" = 5;  // expected-error {{prefix attribute must be}}
@@ -6,7 +6,9 @@
 
 // rdar://6480479
 @interface A
-}; // expected-error {{missing @end}} expected-error {{expected external declaration}}
+}; // expected-error {{missing @end}} \
+// expected-error {{expected external declaration}} \
+// expected-warning{{extra ';' outside of a function}}
 
 
 
@@ -26,3 +28,5 @@
   [(super) a];  // expected-error {{use of undeclared identifier 'super'}}
 }
 @end
+
+ at compatibility_alias A3 A2;





More information about the cfe-commits mailing list