]> granicus.if.org Git - clang/commitdiff
Use Parser::ExpectAndConsume() uniformly to eat semicolons after
authorDouglas Gregor <dgregor@apple.com>
Wed, 5 Jan 2011 01:10:06 +0000 (01:10 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 5 Jan 2011 01:10:06 +0000 (01:10 +0000)
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!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122855 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseObjc.cpp
test/Parser/objc-property-syntax.m
test/Parser/objc-quirks.m

index e1c36e8eaacfa1a760ca84c5325f034962f0ece4..2d293c5aebafd90ee84a64d1180f8b8b7d79cd50 100644 (file)
@@ -1398,10 +1398,8 @@ Decl *Parser::ParseObjCAtAliasDeclaration(SourceLocation atLoc) {
   }
   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 @@ Decl *Parser::ParseObjCPropertySynthesize(SourceLocation atLoc) {
       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 @@ Decl *Parser::ParseObjCPropertyDynamic(SourceLocation atLoc) {
       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;
 }
 
index 064a2090b005a8fb1ef7bf32f8149a45e2922bbf..6ef2ad7c527d986ba1b31993ace1d4aa2660d701 100644 (file)
@@ -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 ':'}}
+
+@property int prop;
 @end
 
 @implementation MyClass
-@dynamic ab_defaultToolbarItems;
+@dynamic ab_defaultToolbarItems // expected-error{{expected ';' after @dynamic}}
+@synthesize prop // expected-error{{expected ';' after @synthesize}}
 @end
 
index b6671d1cf94772a7673019983f104f3de2b1fa73..591bca222a934a9c44fd891436f864719ecff1f5 100644 (file)
@@ -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 @@ int @"s" = 5;  // expected-error {{prefix attribute must be}}
 
 // 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 @@ int @"s" = 5;  // expected-error {{prefix attribute must be}}
   [(super) a];  // expected-error {{use of undeclared identifier 'super'}}
 }
 @end
+
+@compatibility_alias A3 A2;