|
@@ -107,7 +107,7 @@ Parser::ParseObjCAtClassDeclaration(SourceLocation atLoc) {
|
|
|
while (1) {
|
|
|
MaybeSkipAttributes(tok::objc_class);
|
|
|
if (Tok.isNot(tok::identifier)) {
|
|
|
- Diag(Tok, diag::err_expected_ident);
|
|
|
+ Diag(Tok, diag::err_expected) << tok::identifier;
|
|
|
SkipUntil(tok::semi);
|
|
|
return Actions.ConvertDeclToDeclGroup(0);
|
|
|
}
|
|
@@ -195,7 +195,8 @@ Decl *Parser::ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
|
|
|
MaybeSkipAttributes(tok::objc_interface);
|
|
|
|
|
|
if (Tok.isNot(tok::identifier)) {
|
|
|
- Diag(Tok, diag::err_expected_ident); // missing class or category name.
|
|
|
+ Diag(Tok, diag::err_expected)
|
|
|
+ << tok::identifier; // missing class or category name.
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -222,7 +223,8 @@ Decl *Parser::ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
|
|
|
categoryLoc = ConsumeToken();
|
|
|
}
|
|
|
else if (!getLangOpts().ObjC2) {
|
|
|
- Diag(Tok, diag::err_expected_ident); // missing category name.
|
|
|
+ Diag(Tok, diag::err_expected)
|
|
|
+ << tok::identifier; // missing category name.
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -274,7 +276,8 @@ Decl *Parser::ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
|
|
|
}
|
|
|
|
|
|
if (Tok.isNot(tok::identifier)) {
|
|
|
- Diag(Tok, diag::err_expected_ident); // missing super class name.
|
|
|
+ Diag(Tok, diag::err_expected)
|
|
|
+ << tok::identifier; // missing super class name.
|
|
|
return 0;
|
|
|
}
|
|
|
superClassId = Tok.getIdentifierInfo();
|
|
@@ -1086,7 +1089,8 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
|
|
|
}
|
|
|
|
|
|
if (Tok.isNot(tok::identifier)) {
|
|
|
- Diag(Tok, diag::err_expected_ident); // missing argument name.
|
|
|
+ Diag(Tok, diag::err_expected)
|
|
|
+ << tok::identifier; // missing argument name.
|
|
|
break;
|
|
|
}
|
|
|
|
|
@@ -1198,7 +1202,7 @@ ParseObjCProtocolReferences(SmallVectorImpl<Decl *> &Protocols,
|
|
|
}
|
|
|
|
|
|
if (Tok.isNot(tok::identifier)) {
|
|
|
- Diag(Tok, diag::err_expected_ident);
|
|
|
+ Diag(Tok, diag::err_expected) << tok::identifier;
|
|
|
SkipUntil(tok::greater, StopAtSemi);
|
|
|
return true;
|
|
|
}
|
|
@@ -1412,7 +1416,7 @@ Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc,
|
|
|
MaybeSkipAttributes(tok::objc_protocol);
|
|
|
|
|
|
if (Tok.isNot(tok::identifier)) {
|
|
|
- Diag(Tok, diag::err_expected_ident); // missing protocol name.
|
|
|
+ Diag(Tok, diag::err_expected) << tok::identifier; // missing protocol name.
|
|
|
return DeclGroupPtrTy();
|
|
|
}
|
|
|
// Save the protocol name, then consume it.
|
|
@@ -1436,7 +1440,7 @@ Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc,
|
|
|
while (1) {
|
|
|
ConsumeToken(); // the ','
|
|
|
if (Tok.isNot(tok::identifier)) {
|
|
|
- Diag(Tok, diag::err_expected_ident);
|
|
|
+ Diag(Tok, diag::err_expected) << tok::identifier;
|
|
|
SkipUntil(tok::semi);
|
|
|
return DeclGroupPtrTy();
|
|
|
}
|
|
@@ -1505,7 +1509,8 @@ Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc) {
|
|
|
MaybeSkipAttributes(tok::objc_implementation);
|
|
|
|
|
|
if (Tok.isNot(tok::identifier)) {
|
|
|
- Diag(Tok, diag::err_expected_ident); // missing class or category name.
|
|
|
+ Diag(Tok, diag::err_expected)
|
|
|
+ << tok::identifier; // missing class or category name.
|
|
|
return DeclGroupPtrTy();
|
|
|
}
|
|
|
// We have a class or category name - consume it.
|
|
@@ -1529,11 +1534,12 @@ Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc) {
|
|
|
categoryId = Tok.getIdentifierInfo();
|
|
|
categoryLoc = ConsumeToken();
|
|
|
} else {
|
|
|
- Diag(Tok, diag::err_expected_ident); // missing category name.
|
|
|
+ Diag(Tok, diag::err_expected)
|
|
|
+ << tok::identifier; // missing category name.
|
|
|
return DeclGroupPtrTy();
|
|
|
}
|
|
|
if (Tok.isNot(tok::r_paren)) {
|
|
|
- Diag(Tok, diag::err_expected_rparen);
|
|
|
+ Diag(Tok, diag::err_expected) << tok::r_paren;
|
|
|
SkipUntil(tok::r_paren); // don't stop at ';'
|
|
|
return DeclGroupPtrTy();
|
|
|
}
|
|
@@ -1556,7 +1562,8 @@ Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc) {
|
|
|
// We have a super class
|
|
|
ConsumeToken();
|
|
|
if (Tok.isNot(tok::identifier)) {
|
|
|
- Diag(Tok, diag::err_expected_ident); // missing super class name.
|
|
|
+ Diag(Tok, diag::err_expected)
|
|
|
+ << tok::identifier; // missing super class name.
|
|
|
return DeclGroupPtrTy();
|
|
|
}
|
|
|
superClassId = Tok.getIdentifierInfo();
|
|
@@ -1655,13 +1662,13 @@ Decl *Parser::ParseObjCAtAliasDeclaration(SourceLocation atLoc) {
|
|
|
"ParseObjCAtAliasDeclaration(): Expected @compatibility_alias");
|
|
|
ConsumeToken(); // consume compatibility_alias
|
|
|
if (Tok.isNot(tok::identifier)) {
|
|
|
- Diag(Tok, diag::err_expected_ident);
|
|
|
+ Diag(Tok, diag::err_expected) << tok::identifier;
|
|
|
return 0;
|
|
|
}
|
|
|
IdentifierInfo *aliasId = Tok.getIdentifierInfo();
|
|
|
SourceLocation aliasLoc = ConsumeToken(); // consume alias-name
|
|
|
if (Tok.isNot(tok::identifier)) {
|
|
|
- Diag(Tok, diag::err_expected_ident);
|
|
|
+ Diag(Tok, diag::err_expected) << tok::identifier;
|
|
|
return 0;
|
|
|
}
|
|
|
IdentifierInfo *classId = Tok.getIdentifierInfo();
|
|
@@ -1716,7 +1723,7 @@ Decl *Parser::ParseObjCPropertySynthesize(SourceLocation atLoc) {
|
|
|
}
|
|
|
|
|
|
if (Tok.isNot(tok::identifier)) {
|
|
|
- Diag(Tok, diag::err_expected_ident);
|
|
|
+ Diag(Tok, diag::err_expected) << tok::identifier;
|
|
|
break;
|
|
|
}
|
|
|
propertyIvar = Tok.getIdentifierInfo();
|
|
@@ -1751,7 +1758,7 @@ Decl *Parser::ParseObjCPropertyDynamic(SourceLocation atLoc) {
|
|
|
}
|
|
|
|
|
|
if (Tok.isNot(tok::identifier)) {
|
|
|
- Diag(Tok, diag::err_expected_ident);
|
|
|
+ Diag(Tok, diag::err_expected) << tok::identifier;
|
|
|
SkipUntil(tok::semi);
|
|
|
return 0;
|
|
|
}
|
|
@@ -1806,7 +1813,7 @@ Parser::ParseObjCSynchronizedStmt(SourceLocation atLoc) {
|
|
|
ConsumeParen(); // ')'
|
|
|
} else {
|
|
|
if (!operand.isInvalid())
|
|
|
- Diag(Tok, diag::err_expected_rparen);
|
|
|
+ Diag(Tok, diag::err_expected) << tok::r_paren;
|
|
|
|
|
|
// Skip forward until we see a left brace, but don't consume it.
|
|
|
SkipUntil(tok::l_brace, StopAtSemi | StopBeforeMatch);
|
|
@@ -1815,7 +1822,7 @@ Parser::ParseObjCSynchronizedStmt(SourceLocation atLoc) {
|
|
|
// Require a compound statement.
|
|
|
if (Tok.isNot(tok::l_brace)) {
|
|
|
if (!operand.isInvalid())
|
|
|
- Diag(Tok, diag::err_expected_lbrace);
|
|
|
+ Diag(Tok, diag::err_expected) << tok::l_brace;
|
|
|
return StmtError();
|
|
|
}
|
|
|
|
|
@@ -1855,7 +1862,7 @@ StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
|
|
|
|
|
|
ConsumeToken(); // consume try
|
|
|
if (Tok.isNot(tok::l_brace)) {
|
|
|
- Diag(Tok, diag::err_expected_lbrace);
|
|
|
+ Diag(Tok, diag::err_expected) << tok::l_brace;
|
|
|
return StmtError();
|
|
|
}
|
|
|
StmtVector CatchStmts;
|
|
@@ -1905,7 +1912,7 @@ StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
|
|
|
if (Tok.is(tok::l_brace))
|
|
|
CatchBody = ParseCompoundStatementBody();
|
|
|
else
|
|
|
- Diag(Tok, diag::err_expected_lbrace);
|
|
|
+ Diag(Tok, diag::err_expected) << tok::l_brace;
|
|
|
if (CatchBody.isInvalid())
|
|
|
CatchBody = Actions.ActOnNullStmt(Tok.getLocation());
|
|
|
|
|
@@ -1931,7 +1938,7 @@ StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
|
|
|
if (Tok.is(tok::l_brace))
|
|
|
FinallyBody = ParseCompoundStatementBody();
|
|
|
else
|
|
|
- Diag(Tok, diag::err_expected_lbrace);
|
|
|
+ Diag(Tok, diag::err_expected) << tok::l_brace;
|
|
|
if (FinallyBody.isInvalid())
|
|
|
FinallyBody = Actions.ActOnNullStmt(Tok.getLocation());
|
|
|
FinallyStmt = Actions.ActOnObjCAtFinallyStmt(AtCatchFinallyLoc,
|
|
@@ -1957,7 +1964,7 @@ StmtResult
|
|
|
Parser::ParseObjCAutoreleasePoolStmt(SourceLocation atLoc) {
|
|
|
ConsumeToken(); // consume autoreleasepool
|
|
|
if (Tok.isNot(tok::l_brace)) {
|
|
|
- Diag(Tok, diag::err_expected_lbrace);
|
|
|
+ Diag(Tok, diag::err_expected) << tok::l_brace;
|
|
|
return StmtError();
|
|
|
}
|
|
|
// Enter a scope to hold everything within the compound stmt. Compound
|
|
@@ -2572,7 +2579,7 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc,
|
|
|
KeyExprs.push_back(Res.release());
|
|
|
}
|
|
|
} else if (!selIdent) {
|
|
|
- Diag(Tok, diag::err_expected_ident); // missing selector name.
|
|
|
+ Diag(Tok, diag::err_expected) << tok::identifier; // missing selector name.
|
|
|
|
|
|
// We must manually skip to a ']', otherwise the expression skipper will
|
|
|
// stop at the ']' when it skips to the ';'. We want it to skip beyond
|
|
@@ -2730,7 +2737,8 @@ ExprResult Parser::ParseObjCArrayLiteral(SourceLocation AtLoc) {
|
|
|
if (Tok.is(tok::comma))
|
|
|
ConsumeToken(); // Eat the ','.
|
|
|
else if (Tok.isNot(tok::r_square))
|
|
|
- return ExprError(Diag(Tok, diag::err_expected_rsquare_or_comma));
|
|
|
+ return ExprError(Diag(Tok, diag::err_expected_either) << tok::r_square
|
|
|
+ << tok::comma);
|
|
|
}
|
|
|
SourceLocation EndLoc = ConsumeBracket(); // location of ']'
|
|
|
MultiExprArg Args(ElementExprs);
|
|
@@ -2755,10 +2763,8 @@ ExprResult Parser::ParseObjCDictionaryLiteral(SourceLocation AtLoc) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (Tok.is(tok::colon)) {
|
|
|
- ConsumeToken();
|
|
|
- } else {
|
|
|
- Diag(Tok, diag::err_expected_colon);
|
|
|
+ if (!TryConsumeToken(tok::colon)) {
|
|
|
+ Diag(Tok, diag::err_expected) << tok::colon;
|
|
|
SkipUntil(tok::r_brace, StopAtSemi);
|
|
|
return ExprError();
|
|
|
}
|
|
@@ -2774,9 +2780,9 @@ ExprResult Parser::ParseObjCDictionaryLiteral(SourceLocation AtLoc) {
|
|
|
|
|
|
// Parse the ellipsis that designates this as a pack expansion.
|
|
|
SourceLocation EllipsisLoc;
|
|
|
- if (Tok.is(tok::ellipsis) && getLangOpts().CPlusPlus)
|
|
|
- EllipsisLoc = ConsumeToken();
|
|
|
-
|
|
|
+ if (getLangOpts().CPlusPlus)
|
|
|
+ TryConsumeToken(tok::ellipsis, EllipsisLoc);
|
|
|
+
|
|
|
// We have a valid expression. Collect it in a vector so we can
|
|
|
// build the argument list.
|
|
|
ObjCDictionaryElement Element = {
|
|
@@ -2787,7 +2793,8 @@ ExprResult Parser::ParseObjCDictionaryLiteral(SourceLocation AtLoc) {
|
|
|
if (Tok.is(tok::comma))
|
|
|
ConsumeToken(); // Eat the ','.
|
|
|
else if (Tok.isNot(tok::r_brace))
|
|
|
- return ExprError(Diag(Tok, diag::err_expected_rbrace_or_comma));
|
|
|
+ return ExprError(Diag(Tok, diag::err_expected_either) << tok::r_brace
|
|
|
+ << tok::comma);
|
|
|
}
|
|
|
SourceLocation EndLoc = ConsumeBrace();
|
|
|
|
|
@@ -2834,7 +2841,7 @@ Parser::ParseObjCProtocolExpression(SourceLocation AtLoc) {
|
|
|
T.consumeOpen();
|
|
|
|
|
|
if (Tok.isNot(tok::identifier))
|
|
|
- return ExprError(Diag(Tok, diag::err_expected_ident));
|
|
|
+ return ExprError(Diag(Tok, diag::err_expected) << tok::identifier);
|
|
|
|
|
|
IdentifierInfo *protocolId = Tok.getIdentifierInfo();
|
|
|
SourceLocation ProtoIdLoc = ConsumeToken();
|
|
@@ -2869,7 +2876,7 @@ ExprResult Parser::ParseObjCSelectorExpression(SourceLocation AtLoc) {
|
|
|
IdentifierInfo *SelIdent = ParseObjCSelectorPiece(sLoc);
|
|
|
if (!SelIdent && // missing selector name.
|
|
|
Tok.isNot(tok::colon) && Tok.isNot(tok::coloncolon))
|
|
|
- return ExprError(Diag(Tok, diag::err_expected_ident));
|
|
|
+ return ExprError(Diag(Tok, diag::err_expected) << tok::identifier);
|
|
|
|
|
|
KeyIdents.push_back(SelIdent);
|
|
|
unsigned nColons = 0;
|