aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-11-18 19:45:45 +0000
committerDouglas Gregor <dgregor@apple.com>2009-11-18 19:45:45 +0000
commitb328c4251a9d2db704b3bd46ec04884dc8e56332 (patch)
treec83b7fa44000e5df7a0022da1ee4d7f2dca7bff4
parent832b710f597d7d02bcfc83f7c1c1726209f28c50 (diff)
Improve diagnostics and recovery when parsing @synthesized definitions
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89227 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticParseKinds.td2
-rw-r--r--lib/Parse/ParseObjc.cpp12
2 files changed, 12 insertions, 2 deletions
diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td
index 28c46cd2d7..23d49fe75b 100644
--- a/include/clang/Basic/DiagnosticParseKinds.td
+++ b/include/clang/Basic/DiagnosticParseKinds.td
@@ -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;
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index e1f045bd8e..8d6fd209c6 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -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();