aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-10-20 07:37:22 +0000
committerChris Lattner <sabre@nondot.org>2008-10-20 07:37:22 +0000
commit156b061e4918a5e7ecd8eb317975de0e6be2688b (patch)
tree72459b405a9742a6d64ef0107f38ed9bf0c559a4
parent8f5421a2cfaff0b5ef93a4116f697ed98ce08828 (diff)
more simplifications to error recovery in ParseObjCPropertyAttribute
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57815 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Parse/ParseObjc.cpp46
1 files changed, 18 insertions, 28 deletions
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index 652a6a4be7..4b3ecbc89a 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -390,20 +390,18 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS) {
return;
}
+ SourceLocation AttrName = ConsumeToken(); // consume last attribute name
+
// getter/setter require extra treatment.
if (II == ObjCPropertyAttrs[objc_getter] ||
II == ObjCPropertyAttrs[objc_setter]) {
- // skip getter/setter part.
- SourceLocation loc = ConsumeToken();
- if (Tok.isNot(tok::equal)) {
- Diag(loc, diag::err_objc_expected_equal);
- SkipUntil(tok::r_paren);
+
+ if (ExpectAndConsume(tok::equal, diag::err_objc_expected_equal, "",
+ tok::r_paren))
return;
- }
-
- loc = ConsumeToken();
+
if (Tok.isNot(tok::identifier)) {
- Diag(loc, diag::err_expected_ident);
+ Diag(Tok.getLocation(), diag::err_expected_ident);
SkipUntil(tok::r_paren);
return;
}
@@ -411,15 +409,15 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS) {
if (II == ObjCPropertyAttrs[objc_setter]) {
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_setter);
DS.setSetterName(Tok.getIdentifierInfo());
- loc = ConsumeToken(); // consume method name
- if (Tok.isNot(tok::colon)) {
- Diag(loc, diag::err_expected_colon);
- SkipUntil(tok::r_paren);
+ ConsumeToken(); // consume method name
+
+ if (ExpectAndConsume(tok::colon, diag::err_expected_colon, "",
+ tok::r_paren))
return;
- }
} else {
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_getter);
DS.setGetterName(Tok.getIdentifierInfo());
+ ConsumeToken(); // consume method name
}
} else if (II == ObjCPropertyAttrs[objc_readonly])
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_readonly);
@@ -434,26 +432,18 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS) {
else if (II == ObjCPropertyAttrs[objc_nonatomic])
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_nonatomic);
else {
- Diag(Tok.getLocation(), diag::err_objc_expected_property_attr,
- II->getName());
+ Diag(AttrName, diag::err_objc_expected_property_attr, II->getName());
SkipUntil(tok::r_paren);
return;
}
- ConsumeToken(); // consume last attribute token
- if (Tok.is(tok::comma)) {
- ConsumeToken();
- continue;
- }
-
- if (Tok.is(tok::r_paren)) {
- ConsumeParen();
- return;
- }
+ if (Tok.isNot(tok::comma))
+ break;
- MatchRHSPunctuation(tok::r_paren, LHSLoc);
- return;
+ ConsumeToken();
}
+
+ MatchRHSPunctuation(tok::r_paren, LHSLoc);
}
/// objc-method-proto: