]> granicus.if.org Git - clang/commitdiff
Improve diagnostics and recovery when parsing @synthesized definitions
authorDouglas Gregor <dgregor@apple.com>
Wed, 18 Nov 2009 19:45:45 +0000 (19:45 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 18 Nov 2009 19:45:45 +0000 (19:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89227 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticParseKinds.td
lib/Parse/ParseObjc.cpp

index 28c46cd2d7071fb3131a13326f2fba9c7c8ce7a3..23d49fe75b7d8013aa5192c9b7e231f40072d4c6 100644 (file)
@@ -201,6 +201,8 @@ def warn_expected_implementation : Warning<
   "@end must appear in an @implementation context">;
 def error_property_ivar_decl : Error<
   "property synthesize requires specification of an ivar">;
+def err_synthesized_property_name : Error<
+  "expected a property name in @synthesize">;
 def warn_semicolon_before_method_body : Warning<
   "semicolon before method body is ignored">,
   InGroup<DiagGroup<"semicolon-before-method-body">>, DefaultIgnore;
index e1f045bd8e2abda91a58f32b1e086b6ffffc691a..8d6fd209c613dcf7626236693236604a2b350ce5 100644 (file)
@@ -1236,7 +1236,13 @@ Parser::DeclPtrTy Parser::ParseObjCPropertySynthesize(SourceLocation atLoc) {
     return DeclPtrTy();
   }
 
-  while (Tok.is(tok::identifier)) {
+  while (true) {
+    if (Tok.isNot(tok::identifier)) {
+      Diag(Tok, diag::err_synthesized_property_name);
+      SkipUntil(tok::semi);
+      return DeclPtrTy();
+    }
+    
     IdentifierInfo *propertyIvar = 0;
     IdentifierInfo *propertyId = Tok.getIdentifierInfo();
     SourceLocation propertyLoc = ConsumeToken(); // consume property name
@@ -1256,8 +1262,10 @@ Parser::DeclPtrTy Parser::ParseObjCPropertySynthesize(SourceLocation atLoc) {
       break;
     ConsumeToken(); // consume ','
   }
-  if (Tok.isNot(tok::semi))
+  if (Tok.isNot(tok::semi)) {
     Diag(Tok, diag::err_expected_semi_after) << "@synthesize";
+    SkipUntil(tok::semi);
+  }
   else
     ConsumeToken(); // consume ';'
   return DeclPtrTy();