From 56fa31bc8796226fd0e8829951d9e3daa6c8def6 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Fri, 7 Nov 2008 15:54:02 +0000 Subject: [PATCH] Assert that Parser::MaybeParseOperatorFunctionId is called when token is kw_operator, and replace ExpectAndConsume for the 'operator' token with a ConsumeToken. llvm-svn: 58855 --- clang/include/clang/Basic/DiagnosticKinds.def | 2 -- clang/lib/Parse/ParseExprCXX.cpp | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticKinds.def b/clang/include/clang/Basic/DiagnosticKinds.def index b091e2062e30..64afc4683f6d 100644 --- a/clang/include/clang/Basic/DiagnosticKinds.def +++ b/clang/include/clang/Basic/DiagnosticKinds.def @@ -1291,8 +1291,6 @@ DIAG(err_ambiguous_derived_to_base_conv, ERROR, "ambiguous conversion from derived class '%0' to base class '%1':%2") // C++ operator overloading -DIAG(err_expected_operator, ERROR, - "expected 'operator' keyword") DIAG(err_operator_overload_needs_class_or_enum, ERROR, "non-member overloaded operator '%0' must have at least one parameter of class or enumeration type (or reference thereof)") DIAG(err_operator_overload_variadic, ERROR, diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index fcb229b36211..3134ff87b60b 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -308,8 +308,7 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) { /// <= >= && || ++ -- , ->* -> /// () [] IdentifierInfo *Parser::MaybeParseOperatorFunctionId() { - if (Tok.isNot(tok::kw_operator)) - return 0; + assert(Tok.is(tok::kw_operator) && "Expected 'operator' keyword"); OverloadedOperatorKind Op = OO_None; switch (NextToken().getKind()) { @@ -361,7 +360,7 @@ IdentifierInfo *Parser::MaybeParseOperatorFunctionId() { if (Op == OO_None) return 0; else { - ExpectAndConsume(tok::kw_operator, diag::err_expected_operator); + ConsumeToken(); // 'operator' ConsumeAnyToken(); // the operator itself return &PP.getIdentifierTable().getOverloadedOperator(Op); }