]> granicus.if.org Git - clang/commitdiff
Assert that Parser::MaybeParseOperatorFunctionId is called when token is kw_operator...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 7 Nov 2008 15:54:02 +0000 (15:54 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 7 Nov 2008 15:54:02 +0000 (15:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58855 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticKinds.def
lib/Parse/ParseExprCXX.cpp

index b091e2062e309f20e3b8f1dc7f2f97b78cff377f..64afc4683f6dcaf9145d340a99f7422adfda932c 100644 (file)
@@ -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,
index fcb229b36211d9b3a85541a880463558e4db375e..3134ff87b60b4a59536df1d6f88e508c843b443d 100644 (file)
@@ -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);
   }