SourceLocation nameLoc = ConsumeToken();
if (Tok.is(tok::l_paren) &&
!isKnownToBeTypeSpecifier(GetLookAheadToken(1))) { // we have a category.
- // TODO(dgregor): Use the return value from the next line to provide better
- // recovery.
- ConsumeParen();
+ SourceLocation LParenLoc = ConsumeParen();
SourceLocation categoryLoc, rparenLoc;
IdentifierInfo *categoryId = 0;
if (Tok.is(tok::code_completion)) {
Diag(Tok, diag::err_expected_ident); // missing category name.
return 0;
}
- if (Tok.isNot(tok::r_paren)) {
- Diag(Tok, diag::err_expected_rparen);
- SkipUntil(tok::r_paren, false); // don't stop at ';'
+
+ rparenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
+ if (rparenLoc.isInvalid())
return 0;
+
+ if (!attrs.empty()) { // categories don't support attributes.
+ Diag(nameLoc, diag::err_objc_no_attributes_on_category);
+ attrs.clear();
}
- rparenLoc = ConsumeParen();
+
// Next, we need to check for any protocol references.
SourceLocation LAngleLoc, EndProtoLoc;
SmallVector<Decl *, 8> ProtocolRefs;
LAngleLoc, EndProtoLoc))
return 0;
- if (!attrs.empty()) // categories don't support attributes.
- Diag(Tok, diag::err_objc_no_attributes_on_category);
-
Decl *CategoryType =
Actions.ActOnStartCategoryInterface(atLoc,
nameId, nameLoc,