Commit fd33fd10 by Shujing Zhao Committed by Shujing Zhao

re PR c++/18249 (C++ parser i18n problems)

2010-05-25  Shujing Zhao  <pearly.zhao@oracle.com>

        PR c++/18249
        * parser.c: Remove inclusion of dyn-string.h.
        (non_integral_constant): New enum.
        (name_lookup_error): New enum.
        (required_token): New enum.
        (cp_parser_required_error): New function.
        (cp_parser_require): Change the type of variable token_desc to
        required_token and use cp_parser_required_error.
        (cp_parser_require_keyword): Likewise.
        (cp_parser_error): Use gmsgid as parameter.
        (cp_parser_name_lookup_error): Change the type of variable desired to
        name_lookup_error and put the diagnostic in the full sentences. Change
        caller.
        (cp_parser_non_integral_constant_expression): Change the type of the
        variable thing to non_integral_constant and put the diagnostics in
        full sentences. Change caller.

From-SVN: r159808
parent ee4e1706
2010-05-25 Shujing Zhao <pearly.zhao@oracle.com>
PR c++/18249
* parser.c: Remove inclusion of dyn-string.h.
(non_integral_constant): New enum.
(name_lookup_error): New enum.
(required_token): New enum.
(cp_parser_required_error): New function.
(cp_parser_require): Change the type of variable token_desc to
required_token and use cp_parser_required_error.
(cp_parser_require_keyword): Likewise.
(cp_parser_error): Use gmsgid as parameter.
(cp_parser_name_lookup_error): Change the type of variable desired to
name_lookup_error and put the diagnostic in the full sentences. Change
caller.
(cp_parser_non_integral_constant_expression): Change the type of the
variable thing to non_integral_constant and put the diagnostics in
full sentences. Change caller.
2010-05-24 Eric Botcazou <ebotcazou@adacore.com> 2010-05-24 Eric Botcazou <ebotcazou@adacore.com>
PR middle-end/44100 PR middle-end/44100
......
...@@ -23,7 +23,6 @@ along with GCC; see the file COPYING3. If not see ...@@ -23,7 +23,6 @@ along with GCC; see the file COPYING3. If not see
#include "system.h" #include "system.h"
#include "coretypes.h" #include "coretypes.h"
#include "tm.h" #include "tm.h"
#include "dyn-string.h"
#include "cpplib.h" #include "cpplib.h"
#include "tree.h" #include "tree.h"
#include "cp-tree.h" #include "cp-tree.h"
...@@ -149,6 +148,126 @@ typedef struct GTY(()) cp_token_cache { ...@@ -149,6 +148,126 @@ typedef struct GTY(()) cp_token_cache {
cp_token * GTY ((skip)) last; cp_token * GTY ((skip)) last;
} cp_token_cache; } cp_token_cache;
/* The various kinds of non integral constant we encounter. */
typedef enum non_integral_constant {
/* floating-point literal */
NIC_FLOAT,
/* %<this%> */
NIC_THIS,
/* %<__FUNCTION__%> */
NIC_FUNC_NAME,
/* %<__PRETTY_FUNCTION__%> */
NIC_PRETTY_FUNC,
/* %<__func__%> */
NIC_C99_FUNC,
/* "%<va_arg%> */
NIC_VA_ARG,
/* a cast */
NIC_CAST,
/* %<typeid%> operator */
NIC_TYPEID,
/* non-constant compound literals */
NIC_NCC,
/* a function call */
NIC_FUNC_CALL,
/* an increment */
NIC_INC,
/* an decrement */
NIC_DEC,
/* an array reference */
NIC_ARRAY_REF,
/* %<->%> */
NIC_ARROW,
/* %<.%> */
NIC_POINT,
/* the address of a label */
NIC_ADDR_LABEL,
/* %<*%> */
NIC_STAR,
/* %<&%> */
NIC_ADDR,
/* %<++%> */
NIC_PREINCREMENT,
/* %<--%> */
NIC_PREDECREMENT,
/* %<new%> */
NIC_NEW,
/* %<delete%> */
NIC_DEL,
/* calls to overloaded operators */
NIC_OVERLOADED,
/* an assignment */
NIC_ASSIGNMENT,
/* a comma operator */
NIC_COMMA,
/* a call to a constructor */
NIC_CONSTRUCTOR
} non_integral_constant;
/* The various kinds of errors about name-lookup failing. */
typedef enum name_lookup_error {
/* NULL */
NLE_NULL,
/* is not a type */
NLE_TYPE,
/* is not a class or namespace */
NLE_CXX98,
/* is not a class, namespace, or enumeration */
NLE_NOT_CXX98
} name_lookup_error;
/* The various kinds of required token */
typedef enum required_token {
RT_SEMICOLON = 1, /* ';' */
RT_OPEN_PAREN, /* '(' */
RT_CLOSE_BRACE, /* '}' */
RT_OPEN_BRACE, /* '{' */
RT_CLOSE_SQUARE, /* ']' */
RT_OPEN_SQUARE, /* '[' */
RT_COMMA, /* ',' */
RT_SCOPE, /* '::' */
RT_LESS, /* '<' */
RT_GREATER, /* '>' */
RT_EQ, /* '=' */
RT_ELLIPSIS, /* '...' */
RT_MULT, /* '*' */
RT_COMPL, /* '~' */
RT_COLON, /* ':' */
RT_COLON_SCOPE, /* ':' or '::' */
RT_CLOSE_PAREN, /* ')' */
RT_COMMA_CLOSE_PAREN, /* ',' or ')' */
RT_PRAGMA_EOL, /* end of line */
RT_NAME, /* identifier */
/* The type is CPP_KEYWORD */
RT_NEW, /* new */
RT_DELETE, /* delete */
RT_RETURN, /* return */
RT_WHILE, /* while */
RT_EXTERN, /* extern */
RT_STATIC_ASSERT, /* static_assert */
RT_DECLTYPE, /* decltype */
RT_OPERATOR, /* operator */
RT_CLASS, /* class */
RT_TEMPLATE, /* template */
RT_NAMESPACE, /* namespace */
RT_USING, /* using */
RT_ASM, /* asm */
RT_TRY, /* try */
RT_CATCH, /* catch */
RT_THROW, /* throw */
RT_LABEL, /* __label__ */
RT_AT_TRY, /* @try */
RT_AT_SYNCHRONIZED, /* @synchronized */
RT_AT_THROW, /* @throw */
RT_SELECT, /* selection-statement */
RT_INTERATION, /* iteration-statement */
RT_JUMP, /* jump-statement */
RT_CLASS_KEY, /* class-key */
RT_CLASS_TYPENAME_TEMPLATE /* class, typename, or template */
} required_token;
/* Prototypes. */ /* Prototypes. */
static cp_lexer *cp_lexer_new_main static cp_lexer *cp_lexer_new_main
...@@ -1972,10 +2091,12 @@ static void cp_parser_set_decl_spec_type ...@@ -1972,10 +2091,12 @@ static void cp_parser_set_decl_spec_type
(cp_decl_specifier_seq *, tree, location_t, bool); (cp_decl_specifier_seq *, tree, location_t, bool);
static bool cp_parser_friend_p static bool cp_parser_friend_p
(const cp_decl_specifier_seq *); (const cp_decl_specifier_seq *);
static void cp_parser_required_error
(cp_parser *, required_token, bool);
static cp_token *cp_parser_require static cp_token *cp_parser_require
(cp_parser *, enum cpp_ttype, const char *); (cp_parser *, enum cpp_ttype, required_token);
static cp_token *cp_parser_require_keyword static cp_token *cp_parser_require_keyword
(cp_parser *, enum rid, const char *); (cp_parser *, enum rid, required_token);
static bool cp_parser_token_starts_function_definition_p static bool cp_parser_token_starts_function_definition_p
(cp_token *); (cp_token *);
static bool cp_parser_next_token_starts_class_definition_p static bool cp_parser_next_token_starts_class_definition_p
...@@ -2011,7 +2132,7 @@ static bool cp_parser_uncommitted_to_tentative_parse_p ...@@ -2011,7 +2132,7 @@ static bool cp_parser_uncommitted_to_tentative_parse_p
static void cp_parser_error static void cp_parser_error
(cp_parser *, const char *); (cp_parser *, const char *);
static void cp_parser_name_lookup_error static void cp_parser_name_lookup_error
(cp_parser *, tree, tree, const char *, location_t); (cp_parser *, tree, tree, name_lookup_error, location_t);
static bool cp_parser_simulate_error static bool cp_parser_simulate_error
(cp_parser *); (cp_parser *);
static bool cp_parser_check_type_definition static bool cp_parser_check_type_definition
...@@ -2021,7 +2142,7 @@ static void cp_parser_check_for_definition_in_return_type ...@@ -2021,7 +2142,7 @@ static void cp_parser_check_for_definition_in_return_type
static void cp_parser_check_for_invalid_template_id static void cp_parser_check_for_invalid_template_id
(cp_parser *, tree, location_t location); (cp_parser *, tree, location_t location);
static bool cp_parser_non_integral_constant_expression static bool cp_parser_non_integral_constant_expression
(cp_parser *, const char *); (cp_parser *, non_integral_constant);
static void cp_parser_diagnose_invalid_type_name static void cp_parser_diagnose_invalid_type_name
(cp_parser *, tree, tree, location_t); (cp_parser *, tree, tree, location_t);
static bool cp_parser_parse_and_diagnose_invalid_type_name static bool cp_parser_parse_and_diagnose_invalid_type_name
...@@ -2088,7 +2209,7 @@ cp_parser_is_keyword (cp_token* token, enum rid keyword) ...@@ -2088,7 +2209,7 @@ cp_parser_is_keyword (cp_token* token, enum rid keyword)
OTHER-TOKEN". */ OTHER-TOKEN". */
static void static void
cp_parser_error (cp_parser* parser, const char* message) cp_parser_error (cp_parser* parser, const char* gmsgid)
{ {
if (!cp_parser_simulate_error (parser)) if (!cp_parser_simulate_error (parser))
{ {
...@@ -2105,7 +2226,7 @@ cp_parser_error (cp_parser* parser, const char* message) ...@@ -2105,7 +2226,7 @@ cp_parser_error (cp_parser* parser, const char* message)
return; return;
} }
c_parse_error (message, c_parse_error (gmsgid,
/* Because c_parser_error does not understand /* Because c_parser_error does not understand
CPP_KEYWORD, keywords are treated like CPP_KEYWORD, keywords are treated like
identifiers. */ identifiers. */
...@@ -2123,7 +2244,7 @@ static void ...@@ -2123,7 +2244,7 @@ static void
cp_parser_name_lookup_error (cp_parser* parser, cp_parser_name_lookup_error (cp_parser* parser,
tree name, tree name,
tree decl, tree decl,
const char* desired, name_lookup_error desired,
location_t location) location_t location)
{ {
/* If name lookup completely failed, tell the user that NAME was not /* If name lookup completely failed, tell the user that NAME was not
...@@ -2146,11 +2267,64 @@ cp_parser_name_lookup_error (cp_parser* parser, ...@@ -2146,11 +2267,64 @@ cp_parser_name_lookup_error (cp_parser* parser,
error_at (location, "%qE has not been declared", name); error_at (location, "%qE has not been declared", name);
} }
else if (parser->scope && parser->scope != global_namespace) else if (parser->scope && parser->scope != global_namespace)
error_at (location, "%<%E::%E%> %s", parser->scope, name, desired); {
switch (desired)
{
case NLE_TYPE:
error_at (location, "%<%E::%E%> is not a type",
parser->scope, name);
break;
case NLE_CXX98:
error_at (location, "%<%E::%E%> is not a class or namespace",
parser->scope, name);
break;
case NLE_NOT_CXX98:
error_at (location,
"%<%E::%E%> is not a class, namespace, or enumeration",
parser->scope, name);
break;
default:
gcc_unreachable ();
}
}
else if (parser->scope == global_namespace) else if (parser->scope == global_namespace)
error_at (location, "%<::%E%> %s", name, desired); {
switch (desired)
{
case NLE_TYPE:
error_at (location, "%<::%E%> is not a type", name);
break;
case NLE_CXX98:
error_at (location, "%<::%E%> is not a class or namespace", name);
break;
case NLE_NOT_CXX98:
error_at (location,
"%<::%E%> is not a class, namespace, or enumeration",
name);
break;
default:
gcc_unreachable ();
}
}
else else
error_at (location, "%qE %s", name, desired); {
switch (desired)
{
case NLE_TYPE:
error_at (location, "%qE is not a type", name);
break;
case NLE_CXX98:
error_at (location, "%qE is not a class or namespace", name);
break;
case NLE_NOT_CXX98:
error_at (location,
"%qE is not a class, namespace, or enumeration", name);
break;
default:
gcc_unreachable ();
}
}
} }
/* If we are parsing tentatively, remember that an error has occurred /* If we are parsing tentatively, remember that an error has occurred
...@@ -2302,20 +2476,112 @@ cp_parser_check_for_invalid_template_id (cp_parser* parser, ...@@ -2302,20 +2476,112 @@ cp_parser_check_for_invalid_template_id (cp_parser* parser,
static bool static bool
cp_parser_non_integral_constant_expression (cp_parser *parser, cp_parser_non_integral_constant_expression (cp_parser *parser,
const char *thing) non_integral_constant thing)
{ {
parser->non_integral_constant_expression_p = true; parser->non_integral_constant_expression_p = true;
if (parser->integral_constant_expression_p) if (parser->integral_constant_expression_p)
{ {
if (!parser->allow_non_integral_constant_expression_p) if (!parser->allow_non_integral_constant_expression_p)
{ {
/* Don't use `%s' to print THING, because quotations (`%<', `%>') const char *msg = NULL;
in the message need to be interpreted. */ switch (thing)
char *message = concat (thing, {
" cannot appear in a constant-expression", case NIC_FLOAT:
NULL); error ("floating-point literal "
error (message); "cannot appear in a constant-expression");
free (message); return true;
case NIC_CAST:
error ("a cast to a type other than an integral or "
"enumeration type cannot appear in a "
"constant-expression");
return true;
case NIC_TYPEID:
error ("%<typeid%> operator "
"cannot appear in a constant-expression");
return true;
case NIC_NCC:
error ("non-constant compound literals "
"cannot appear in a constant-expression");
return true;
case NIC_FUNC_CALL:
error ("a function call "
"cannot appear in a constant-expression");
return true;
case NIC_INC:
error ("an increment "
"cannot appear in a constant-expression");
return true;
case NIC_DEC:
error ("an decrement "
"cannot appear in a constant-expression");
return true;
case NIC_ARRAY_REF:
error ("an array reference "
"cannot appear in a constant-expression");
return true;
case NIC_ADDR_LABEL:
error ("the address of a label "
"cannot appear in a constant-expression");
return true;
case NIC_OVERLOADED:
error ("calls to overloaded operators "
"cannot appear in a constant-expression");
return true;
case NIC_ASSIGNMENT:
error ("an assignment cannot appear in a constant-expression");
return true;
case NIC_COMMA:
error ("a comma operator "
"cannot appear in a constant-expression");
return true;
case NIC_CONSTRUCTOR:
error ("a call to a constructor "
"cannot appear in a constant-expression");
return true;
case NIC_THIS:
msg = "this";
break;
case NIC_FUNC_NAME:
msg = "__FUNCTION__";
break;
case NIC_PRETTY_FUNC:
msg = "__PRETTY_FUNCTION__";
break;
case NIC_C99_FUNC:
msg = "__func__";
break;
case NIC_VA_ARG:
msg = "va_arg";
break;
case NIC_ARROW:
msg = "->";
break;
case NIC_POINT:
msg = ".";
break;
case NIC_STAR:
msg = "*";
break;
case NIC_ADDR:
msg = "&";
break;
case NIC_PREINCREMENT:
msg = "++";
break;
case NIC_PREDECREMENT:
msg = "--";
break;
case NIC_NEW:
msg = "new";
break;
case NIC_DEL:
msg = "delete";
break;
default:
gcc_unreachable ();
}
if (msg)
error ("%qs cannot appear in a constant-expression", msg);
return true; return true;
} }
} }
...@@ -2638,7 +2904,7 @@ static void ...@@ -2638,7 +2904,7 @@ static void
cp_parser_consume_semicolon_at_end_of_statement (cp_parser *parser) cp_parser_consume_semicolon_at_end_of_statement (cp_parser *parser)
{ {
/* Look for the trailing `;'. */ /* Look for the trailing `;'. */
if (!cp_parser_require (parser, CPP_SEMICOLON, "%<;%>")) if (!cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON))
{ {
/* If there is additional (erroneous) input, skip to the end of /* If there is additional (erroneous) input, skip to the end of
the statement. */ the statement. */
...@@ -2766,7 +3032,7 @@ static void ...@@ -2766,7 +3032,7 @@ static void
cp_parser_require_pragma_eol (cp_parser *parser, cp_token *pragma_tok) cp_parser_require_pragma_eol (cp_parser *parser, cp_token *pragma_tok)
{ {
parser->lexer->in_pragma = false; parser->lexer->in_pragma = false;
if (!cp_parser_require (parser, CPP_PRAGMA_EOL, "end of line")) if (!cp_parser_require (parser, CPP_PRAGMA_EOL, RT_PRAGMA_EOL))
cp_parser_skip_to_pragma_eol (parser, pragma_tok); cp_parser_skip_to_pragma_eol (parser, pragma_tok);
} }
...@@ -2934,7 +3200,7 @@ cp_parser_identifier (cp_parser* parser) ...@@ -2934,7 +3200,7 @@ cp_parser_identifier (cp_parser* parser)
cp_token *token; cp_token *token;
/* Look for the identifier. */ /* Look for the identifier. */
token = cp_parser_require (parser, CPP_NAME, "identifier"); token = cp_parser_require (parser, CPP_NAME, RT_NAME);
/* Return the value. */ /* Return the value. */
return token ? token->u.value : error_mark_node; return token ? token->u.value : error_mark_node;
} }
...@@ -3253,8 +3519,7 @@ cp_parser_primary_expression (cp_parser *parser, ...@@ -3253,8 +3519,7 @@ cp_parser_primary_expression (cp_parser *parser,
checked at that point. If we are not within a cast, then checked at that point. If we are not within a cast, then
this code is invalid. */ this code is invalid. */
if (!cast_p) if (!cast_p)
cp_parser_non_integral_constant_expression cp_parser_non_integral_constant_expression (parser, NIC_FLOAT);
(parser, "floating-point literal");
} }
return token->u.value; return token->u.value;
...@@ -3332,7 +3597,7 @@ cp_parser_primary_expression (cp_parser *parser, ...@@ -3332,7 +3597,7 @@ cp_parser_primary_expression (cp_parser *parser,
parser->greater_than_is_operator_p parser->greater_than_is_operator_p
= saved_greater_than_is_operator_p; = saved_greater_than_is_operator_p;
/* Consume the `)'. */ /* Consume the `)'. */
if (!cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>")) if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
cp_parser_skip_to_end_of_statement (parser); cp_parser_skip_to_end_of_statement (parser);
return expr; return expr;
...@@ -3383,7 +3648,7 @@ cp_parser_primary_expression (cp_parser *parser, ...@@ -3383,7 +3648,7 @@ cp_parser_primary_expression (cp_parser *parser,
return error_mark_node; return error_mark_node;
} }
/* Pointers cannot appear in constant-expressions. */ /* Pointers cannot appear in constant-expressions. */
if (cp_parser_non_integral_constant_expression (parser, "%<this%>")) if (cp_parser_non_integral_constant_expression (parser, NIC_THIS))
return error_mark_node; return error_mark_node;
return finish_this_expr (); return finish_this_expr ();
...@@ -3396,7 +3661,7 @@ cp_parser_primary_expression (cp_parser *parser, ...@@ -3396,7 +3661,7 @@ cp_parser_primary_expression (cp_parser *parser,
case RID_PRETTY_FUNCTION_NAME: case RID_PRETTY_FUNCTION_NAME:
case RID_C99_FUNCTION_NAME: case RID_C99_FUNCTION_NAME:
{ {
const char *name; non_integral_constant name;
/* The symbols __FUNCTION__, __PRETTY_FUNCTION__, and /* The symbols __FUNCTION__, __PRETTY_FUNCTION__, and
__func__ are the names of variables -- but they are __func__ are the names of variables -- but they are
...@@ -3410,13 +3675,13 @@ cp_parser_primary_expression (cp_parser *parser, ...@@ -3410,13 +3675,13 @@ cp_parser_primary_expression (cp_parser *parser,
switch (token->keyword) switch (token->keyword)
{ {
case RID_FUNCTION_NAME: case RID_FUNCTION_NAME:
name = "%<__FUNCTION__%>"; name = NIC_FUNC_NAME;
break; break;
case RID_PRETTY_FUNCTION_NAME: case RID_PRETTY_FUNCTION_NAME:
name = "%<__PRETTY_FUNCTION__%>"; name = NIC_PRETTY_FUNC;
break; break;
case RID_C99_FUNCTION_NAME: case RID_C99_FUNCTION_NAME:
name = "%<__func__%>"; name = NIC_C99_FUNC;
break; break;
default: default:
gcc_unreachable (); gcc_unreachable ();
...@@ -3438,20 +3703,19 @@ cp_parser_primary_expression (cp_parser *parser, ...@@ -3438,20 +3703,19 @@ cp_parser_primary_expression (cp_parser *parser,
`va_arg'. Consume the `__builtin_va_arg' token. */ `va_arg'. Consume the `__builtin_va_arg' token. */
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
/* Look for the opening `('. */ /* Look for the opening `('. */
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
/* Now, parse the assignment-expression. */ /* Now, parse the assignment-expression. */
expression = cp_parser_assignment_expression (parser, expression = cp_parser_assignment_expression (parser,
/*cast_p=*/false, NULL); /*cast_p=*/false, NULL);
/* Look for the `,'. */ /* Look for the `,'. */
cp_parser_require (parser, CPP_COMMA, "%<,%>"); cp_parser_require (parser, CPP_COMMA, RT_COMMA);
/* Parse the type-id. */ /* Parse the type-id. */
type = cp_parser_type_id (parser); type = cp_parser_type_id (parser);
/* Look for the closing `)'. */ /* Look for the closing `)'. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
/* Using `va_arg' in a constant-expression is not /* Using `va_arg' in a constant-expression is not
allowed. */ allowed. */
if (cp_parser_non_integral_constant_expression (parser, if (cp_parser_non_integral_constant_expression (parser,NIC_VA_ARG))
"%<va_arg%>"))
return error_mark_node; return error_mark_node;
return build_x_va_arg (expression, type); return build_x_va_arg (expression, type);
} }
...@@ -4204,7 +4468,7 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, ...@@ -4204,7 +4468,7 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser,
type_p, type_p,
is_declaration); is_declaration);
/* Look for the `::' token. */ /* Look for the `::' token. */
cp_parser_require (parser, CPP_SCOPE, "%<::%>"); cp_parser_require (parser, CPP_SCOPE, RT_SCOPE);
/* If we found what we wanted, we keep going; otherwise, we're /* If we found what we wanted, we keep going; otherwise, we're
done. */ done. */
...@@ -4257,12 +4521,14 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, ...@@ -4257,12 +4521,14 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser,
} }
else else
{ {
const char* msg = "is not a class or namespace";
if (cxx_dialect != cxx98) if (cxx_dialect != cxx98)
msg = "is not a class, namespace, or enumeration"; cp_parser_name_lookup_error
cp_parser_name_lookup_error (parser, token->u.value, decl, NLE_NOT_CXX98,
(parser, token->u.value, decl, msg,
token->location); token->location);
else
cp_parser_name_lookup_error
(parser, token->u.value, decl, NLE_CXX98,
token->location);
} }
} }
parser->scope = error_mark_node; parser->scope = error_mark_node;
...@@ -4560,26 +4826,23 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, ...@@ -4560,26 +4826,23 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
= G_("types may not be defined in casts"); = G_("types may not be defined in casts");
/* Look for the opening `<'. */ /* Look for the opening `<'. */
cp_parser_require (parser, CPP_LESS, "%<<%>"); cp_parser_require (parser, CPP_LESS, RT_LESS);
/* Parse the type to which we are casting. */ /* Parse the type to which we are casting. */
type = cp_parser_type_id (parser); type = cp_parser_type_id (parser);
/* Look for the closing `>'. */ /* Look for the closing `>'. */
cp_parser_require (parser, CPP_GREATER, "%<>%>"); cp_parser_require (parser, CPP_GREATER, RT_GREATER);
/* Restore the old message. */ /* Restore the old message. */
parser->type_definition_forbidden_message = saved_message; parser->type_definition_forbidden_message = saved_message;
/* And the expression which is being cast. */ /* And the expression which is being cast. */
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
expression = cp_parser_expression (parser, /*cast_p=*/true, & idk); expression = cp_parser_expression (parser, /*cast_p=*/true, & idk);
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
/* Only type conversions to integral or enumeration types /* Only type conversions to integral or enumeration types
can be used in constant-expressions. */ can be used in constant-expressions. */
if (!cast_valid_in_integral_constant_expression_p (type) if (!cast_valid_in_integral_constant_expression_p (type)
&& (cp_parser_non_integral_constant_expression && (cp_parser_non_integral_constant_expression (parser, NIC_CAST)))
(parser,
"a cast to a type other than an integral or "
"enumeration type")))
return error_mark_node; return error_mark_node;
switch (keyword) switch (keyword)
...@@ -4616,7 +4879,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, ...@@ -4616,7 +4879,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
/* Consume the `typeid' token. */ /* Consume the `typeid' token. */
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
/* Look for the `(' token. */ /* Look for the `(' token. */
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
/* Types cannot be defined in a `typeid' expression. */ /* Types cannot be defined in a `typeid' expression. */
saved_message = parser->type_definition_forbidden_message; saved_message = parser->type_definition_forbidden_message;
parser->type_definition_forbidden_message parser->type_definition_forbidden_message
...@@ -4632,7 +4895,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, ...@@ -4632,7 +4895,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
/* Look for the `)' token. Otherwise, we can't be sure that /* Look for the `)' token. Otherwise, we can't be sure that
we're not looking at an expression: consider `typeid (int we're not looking at an expression: consider `typeid (int
(3))', for example. */ (3))', for example. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
/* If all went well, simply lookup the type-id. */ /* If all went well, simply lookup the type-id. */
if (cp_parser_parse_definitely (parser)) if (cp_parser_parse_definitely (parser))
postfix_expression = get_typeid (type); postfix_expression = get_typeid (type);
...@@ -4646,13 +4909,12 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, ...@@ -4646,13 +4909,12 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
/* Compute its typeid. */ /* Compute its typeid. */
postfix_expression = build_typeid (expression); postfix_expression = build_typeid (expression);
/* Look for the `)' token. */ /* Look for the `)' token. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
} }
/* Restore the saved message. */ /* Restore the saved message. */
parser->type_definition_forbidden_message = saved_message; parser->type_definition_forbidden_message = saved_message;
/* `typeid' may not appear in an integral constant expression. */ /* `typeid' may not appear in an integral constant expression. */
if (cp_parser_non_integral_constant_expression(parser, if (cp_parser_non_integral_constant_expression(parser, NIC_TYPEID))
"%<typeid%> operator"))
return error_mark_node; return error_mark_node;
} }
break; break;
...@@ -4707,9 +4969,9 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, ...@@ -4707,9 +4969,9 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
type = cp_parser_type_id (parser); type = cp_parser_type_id (parser);
parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p; parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p;
/* Look for the `)'. */ /* Look for the `)'. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
/* Look for the `{'. */ /* Look for the `{'. */
cp_parser_require (parser, CPP_OPEN_BRACE, "%<{%>"); cp_parser_require (parser, CPP_OPEN_BRACE, RT_OPEN_BRACE);
/* If things aren't going well, there's no need to /* If things aren't going well, there's no need to
keep going. */ keep going. */
if (!cp_parser_error_occurred (parser)) if (!cp_parser_error_occurred (parser))
...@@ -4722,7 +4984,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, ...@@ -4722,7 +4984,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA)) if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA))
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
/* Look for the final `}'. */ /* Look for the final `}'. */
cp_parser_require (parser, CPP_CLOSE_BRACE, "%<}%>"); cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
} }
/* If that worked, we're definitely looking at a /* If that worked, we're definitely looking at a
compound-literal expression. */ compound-literal expression. */
...@@ -4740,8 +5002,8 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, ...@@ -4740,8 +5002,8 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
currently accepted programs. (Of course, as currently accepted programs. (Of course, as
compound literals are not part of ISO C++, the compound literals are not part of ISO C++, the
standard has nothing to say.) */ standard has nothing to say.) */
if (cp_parser_non_integral_constant_expression if (cp_parser_non_integral_constant_expression (parser,
(parser, "non-constant compound literals")) NIC_NCC))
{ {
postfix_expression = error_mark_node; postfix_expression = error_mark_node;
break; break;
...@@ -4833,7 +5095,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, ...@@ -4833,7 +5095,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
constant-expressions. */ constant-expressions. */
if (! builtin_valid_in_constant_expr_p (postfix_expression) if (! builtin_valid_in_constant_expr_p (postfix_expression)
&& cp_parser_non_integral_constant_expression (parser, && cp_parser_non_integral_constant_expression (parser,
"a function call")) NIC_FUNC_CALL))
{ {
postfix_expression = error_mark_node; postfix_expression = error_mark_node;
release_tree_vector (args); release_tree_vector (args);
...@@ -4971,8 +5233,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, ...@@ -4971,8 +5233,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
= finish_increment_expr (postfix_expression, = finish_increment_expr (postfix_expression,
POSTINCREMENT_EXPR); POSTINCREMENT_EXPR);
/* Increments may not appear in constant-expressions. */ /* Increments may not appear in constant-expressions. */
if (cp_parser_non_integral_constant_expression (parser, if (cp_parser_non_integral_constant_expression (parser, NIC_INC))
"an increment"))
postfix_expression = error_mark_node; postfix_expression = error_mark_node;
idk = CP_ID_KIND_NONE; idk = CP_ID_KIND_NONE;
is_member_access = false; is_member_access = false;
...@@ -4987,8 +5248,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, ...@@ -4987,8 +5248,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
= finish_increment_expr (postfix_expression, = finish_increment_expr (postfix_expression,
POSTDECREMENT_EXPR); POSTDECREMENT_EXPR);
/* Decrements may not appear in constant-expressions. */ /* Decrements may not appear in constant-expressions. */
if (cp_parser_non_integral_constant_expression (parser, if (cp_parser_non_integral_constant_expression (parser, NIC_DEC))
"a decrement"))
postfix_expression = error_mark_node; postfix_expression = error_mark_node;
idk = CP_ID_KIND_NONE; idk = CP_ID_KIND_NONE;
is_member_access = false; is_member_access = false;
...@@ -5041,7 +5301,7 @@ cp_parser_postfix_open_square_expression (cp_parser *parser, ...@@ -5041,7 +5301,7 @@ cp_parser_postfix_open_square_expression (cp_parser *parser,
index = cp_parser_expression (parser, /*cast_p=*/false, NULL); index = cp_parser_expression (parser, /*cast_p=*/false, NULL);
/* Look for the closing `]'. */ /* Look for the closing `]'. */
cp_parser_require (parser, CPP_CLOSE_SQUARE, "%<]%>"); cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
/* Build the ARRAY_REF. */ /* Build the ARRAY_REF. */
postfix_expression = grok_array_decl (postfix_expression, index); postfix_expression = grok_array_decl (postfix_expression, index);
...@@ -5049,8 +5309,7 @@ cp_parser_postfix_open_square_expression (cp_parser *parser, ...@@ -5049,8 +5309,7 @@ cp_parser_postfix_open_square_expression (cp_parser *parser,
/* When not doing offsetof, array references are not permitted in /* When not doing offsetof, array references are not permitted in
constant-expressions. */ constant-expressions. */
if (!for_offsetof if (!for_offsetof
&& (cp_parser_non_integral_constant_expression && (cp_parser_non_integral_constant_expression (parser, NIC_ARRAY_REF)))
(parser, "an array reference")))
postfix_expression = error_mark_node; postfix_expression = error_mark_node;
return postfix_expression; return postfix_expression;
...@@ -5225,7 +5484,7 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser, ...@@ -5225,7 +5484,7 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser,
constant-expressions. */ constant-expressions. */
if (!for_offsetof if (!for_offsetof
&& (cp_parser_non_integral_constant_expression && (cp_parser_non_integral_constant_expression
(parser, token_type == CPP_DEREF ? "%<->%>" : "%<.%>"))) (parser, token_type == CPP_DEREF ? NIC_ARROW : NIC_POINT)))
postfix_expression = error_mark_node; postfix_expression = error_mark_node;
return postfix_expression; return postfix_expression;
...@@ -5273,7 +5532,7 @@ cp_parser_parenthesized_expression_list (cp_parser* parser, ...@@ -5273,7 +5532,7 @@ cp_parser_parenthesized_expression_list (cp_parser* parser,
if (non_constant_p) if (non_constant_p)
*non_constant_p = false; *non_constant_p = false;
if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>")) if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
return NULL; return NULL;
expression_list = make_tree_vector (); expression_list = make_tree_vector ();
...@@ -5364,7 +5623,7 @@ cp_parser_parenthesized_expression_list (cp_parser* parser, ...@@ -5364,7 +5623,7 @@ cp_parser_parenthesized_expression_list (cp_parser* parser,
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
} }
if (!cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>")) if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
{ {
int ending; int ending;
...@@ -5439,7 +5698,7 @@ cp_parser_pseudo_destructor_name (cp_parser* parser, ...@@ -5439,7 +5698,7 @@ cp_parser_pseudo_destructor_name (cp_parser* parser,
/*check_dependency_p=*/false, /*check_dependency_p=*/false,
/*is_declaration=*/true); /*is_declaration=*/true);
/* Look for the `::' token. */ /* Look for the `::' token. */
cp_parser_require (parser, CPP_SCOPE, "%<::%>"); cp_parser_require (parser, CPP_SCOPE, RT_SCOPE);
} }
/* If the next token is not a `~', then there might be some /* If the next token is not a `~', then there might be some
additional qualification. */ additional qualification. */
...@@ -5465,13 +5724,13 @@ cp_parser_pseudo_destructor_name (cp_parser* parser, ...@@ -5465,13 +5724,13 @@ cp_parser_pseudo_destructor_name (cp_parser* parser,
return; return;
/* Look for the `::' token. */ /* Look for the `::' token. */
cp_parser_require (parser, CPP_SCOPE, "%<::%>"); cp_parser_require (parser, CPP_SCOPE, RT_SCOPE);
} }
else else
*scope = NULL_TREE; *scope = NULL_TREE;
/* Look for the `~'. */ /* Look for the `~'. */
cp_parser_require (parser, CPP_COMPL, "%<~%>"); cp_parser_require (parser, CPP_COMPL, RT_COMPL);
/* Look for the type-name again. We are not responsible for /* Look for the type-name again. We are not responsible for
checking that it matches the first type-name. */ checking that it matches the first type-name. */
*type = cp_parser_nonclass_name (parser); *type = cp_parser_nonclass_name (parser);
...@@ -5627,7 +5886,7 @@ cp_parser_unary_expression (cp_parser *parser, bool address_p, bool cast_p, ...@@ -5627,7 +5886,7 @@ cp_parser_unary_expression (cp_parser *parser, bool address_p, bool cast_p,
/* Create an expression representing the address. */ /* Create an expression representing the address. */
expression = finish_label_address_expr (identifier, loc); expression = finish_label_address_expr (identifier, loc);
if (cp_parser_non_integral_constant_expression (parser, if (cp_parser_non_integral_constant_expression (parser,
"the address of a label")) NIC_ADDR_LABEL))
expression = error_mark_node; expression = error_mark_node;
return expression; return expression;
} }
...@@ -5636,7 +5895,7 @@ cp_parser_unary_expression (cp_parser *parser, bool address_p, bool cast_p, ...@@ -5636,7 +5895,7 @@ cp_parser_unary_expression (cp_parser *parser, bool address_p, bool cast_p,
{ {
tree cast_expression; tree cast_expression;
tree expression = error_mark_node; tree expression = error_mark_node;
const char *non_constant_p = NULL; non_integral_constant non_constant_p = 0;
/* Consume the operator token. */ /* Consume the operator token. */
token = cp_lexer_consume_token (parser->lexer); token = cp_lexer_consume_token (parser->lexer);
...@@ -5649,13 +5908,13 @@ cp_parser_unary_expression (cp_parser *parser, bool address_p, bool cast_p, ...@@ -5649,13 +5908,13 @@ cp_parser_unary_expression (cp_parser *parser, bool address_p, bool cast_p,
switch (unary_operator) switch (unary_operator)
{ {
case INDIRECT_REF: case INDIRECT_REF:
non_constant_p = "%<*%>"; non_constant_p = NIC_STAR;
expression = build_x_indirect_ref (cast_expression, RO_UNARY_STAR, expression = build_x_indirect_ref (cast_expression, RO_UNARY_STAR,
tf_warning_or_error); tf_warning_or_error);
break; break;
case ADDR_EXPR: case ADDR_EXPR:
non_constant_p = "%<&%>"; non_constant_p = NIC_ADDR;
/* Fall through. */ /* Fall through. */
case BIT_NOT_EXPR: case BIT_NOT_EXPR:
expression = build_x_unary_op (unary_operator, cast_expression, expression = build_x_unary_op (unary_operator, cast_expression,
...@@ -5664,8 +5923,8 @@ cp_parser_unary_expression (cp_parser *parser, bool address_p, bool cast_p, ...@@ -5664,8 +5923,8 @@ cp_parser_unary_expression (cp_parser *parser, bool address_p, bool cast_p,
case PREINCREMENT_EXPR: case PREINCREMENT_EXPR:
case PREDECREMENT_EXPR: case PREDECREMENT_EXPR:
non_constant_p = (unary_operator == PREINCREMENT_EXPR non_constant_p = unary_operator == PREINCREMENT_EXPR
? "%<++%>" : "%<--%>"); ? NIC_PREINCREMENT : NIC_PREDECREMENT;
/* Fall through. */ /* Fall through. */
case UNARY_PLUS_EXPR: case UNARY_PLUS_EXPR:
case NEGATE_EXPR: case NEGATE_EXPR:
...@@ -5745,7 +6004,7 @@ cp_parser_new_expression (cp_parser* parser) ...@@ -5745,7 +6004,7 @@ cp_parser_new_expression (cp_parser* parser)
/*current_scope_valid_p=*/false) /*current_scope_valid_p=*/false)
!= NULL_TREE); != NULL_TREE);
/* Look for the `new' operator. */ /* Look for the `new' operator. */
cp_parser_require_keyword (parser, RID_NEW, "%<new%>"); cp_parser_require_keyword (parser, RID_NEW, RT_NEW);
/* There's no easy way to tell a new-placement from the /* There's no easy way to tell a new-placement from the
`( type-id )' construct. */ `( type-id )' construct. */
cp_parser_parse_tentatively (parser); cp_parser_parse_tentatively (parser);
...@@ -5769,7 +6028,7 @@ cp_parser_new_expression (cp_parser* parser) ...@@ -5769,7 +6028,7 @@ cp_parser_new_expression (cp_parser* parser)
/* Parse the type-id. */ /* Parse the type-id. */
type = cp_parser_type_id (parser); type = cp_parser_type_id (parser);
/* Look for the closing `)'. */ /* Look for the closing `)'. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
token = cp_lexer_peek_token (parser->lexer); token = cp_lexer_peek_token (parser->lexer);
/* There should not be a direct-new-declarator in this production, /* There should not be a direct-new-declarator in this production,
but GCC used to allowed this, so we check and emit a sensible error but GCC used to allowed this, so we check and emit a sensible error
...@@ -5797,7 +6056,7 @@ cp_parser_new_expression (cp_parser* parser) ...@@ -5797,7 +6056,7 @@ cp_parser_new_expression (cp_parser* parser)
/* A new-expression may not appear in an integral constant /* A new-expression may not appear in an integral constant
expression. */ expression. */
if (cp_parser_non_integral_constant_expression (parser, "%<new%>")) if (cp_parser_non_integral_constant_expression (parser, NIC_NEW))
ret = error_mark_node; ret = error_mark_node;
else else
{ {
...@@ -5963,7 +6222,7 @@ cp_parser_direct_new_declarator (cp_parser* parser) ...@@ -5963,7 +6222,7 @@ cp_parser_direct_new_declarator (cp_parser* parser)
tree expression; tree expression;
/* Look for the opening `['. */ /* Look for the opening `['. */
cp_parser_require (parser, CPP_OPEN_SQUARE, "%<[%>"); cp_parser_require (parser, CPP_OPEN_SQUARE, RT_OPEN_SQUARE);
/* The first expression is not required to be constant. */ /* The first expression is not required to be constant. */
if (!declarator) if (!declarator)
{ {
...@@ -5997,7 +6256,7 @@ cp_parser_direct_new_declarator (cp_parser* parser) ...@@ -5997,7 +6256,7 @@ cp_parser_direct_new_declarator (cp_parser* parser)
/*allow_non_constant=*/false, /*allow_non_constant=*/false,
NULL); NULL);
/* Look for the closing `]'. */ /* Look for the closing `]'. */
cp_parser_require (parser, CPP_CLOSE_SQUARE, "%<]%>"); cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
/* Add this bound to the declarator. */ /* Add this bound to the declarator. */
declarator = make_array_declarator (declarator, expression); declarator = make_array_declarator (declarator, expression);
...@@ -6063,14 +6322,14 @@ cp_parser_delete_expression (cp_parser* parser) ...@@ -6063,14 +6322,14 @@ cp_parser_delete_expression (cp_parser* parser)
/*current_scope_valid_p=*/false) /*current_scope_valid_p=*/false)
!= NULL_TREE); != NULL_TREE);
/* Look for the `delete' keyword. */ /* Look for the `delete' keyword. */
cp_parser_require_keyword (parser, RID_DELETE, "%<delete%>"); cp_parser_require_keyword (parser, RID_DELETE, RT_DELETE);
/* See if the array syntax is in use. */ /* See if the array syntax is in use. */
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_SQUARE)) if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_SQUARE))
{ {
/* Consume the `[' token. */ /* Consume the `[' token. */
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
/* Look for the `]' token. */ /* Look for the `]' token. */
cp_parser_require (parser, CPP_CLOSE_SQUARE, "%<]%>"); cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
/* Remember that this is the `[]' construct. */ /* Remember that this is the `[]' construct. */
array_p = true; array_p = true;
} }
...@@ -6082,7 +6341,7 @@ cp_parser_delete_expression (cp_parser* parser) ...@@ -6082,7 +6341,7 @@ cp_parser_delete_expression (cp_parser* parser)
/* A delete-expression may not appear in an integral constant /* A delete-expression may not appear in an integral constant
expression. */ expression. */
if (cp_parser_non_integral_constant_expression (parser, "%<delete%>")) if (cp_parser_non_integral_constant_expression (parser, NIC_DEL))
return error_mark_node; return error_mark_node;
return delete_sanity (expression, NULL_TREE, array_p, global_scope_p); return delete_sanity (expression, NULL_TREE, array_p, global_scope_p);
...@@ -6215,7 +6474,7 @@ cp_parser_cast_expression (cp_parser *parser, bool address_p, bool cast_p, ...@@ -6215,7 +6474,7 @@ cp_parser_cast_expression (cp_parser *parser, bool address_p, bool cast_p,
/* Look for the type-id. */ /* Look for the type-id. */
type = cp_parser_type_id (parser); type = cp_parser_type_id (parser);
/* Look for the closing `)'. */ /* Look for the closing `)'. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p; parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p;
} }
...@@ -6244,10 +6503,8 @@ cp_parser_cast_expression (cp_parser *parser, bool address_p, bool cast_p, ...@@ -6244,10 +6503,8 @@ cp_parser_cast_expression (cp_parser *parser, bool address_p, bool cast_p,
/* Only type conversions to integral or enumeration types /* Only type conversions to integral or enumeration types
can be used in constant-expressions. */ can be used in constant-expressions. */
if (!cast_valid_in_integral_constant_expression_p (type) if (!cast_valid_in_integral_constant_expression_p (type)
&& (cp_parser_non_integral_constant_expression && (cp_parser_non_integral_constant_expression (parser,
(parser, NIC_CAST)))
"a cast to a type other than an integral or "
"enumeration type")))
return error_mark_node; return error_mark_node;
/* Perform the cast. */ /* Perform the cast. */
...@@ -6482,8 +6739,8 @@ cp_parser_binary_expression (cp_parser* parser, bool cast_p, ...@@ -6482,8 +6739,8 @@ cp_parser_binary_expression (cp_parser* parser, bool cast_p,
least one of the operands is of enumeration type. */ least one of the operands is of enumeration type. */
if (overloaded_p if (overloaded_p
&& (cp_parser_non_integral_constant_expression && (cp_parser_non_integral_constant_expression (parser,
(parser, "calls to overloaded operators"))) NIC_OVERLOADED)))
return error_mark_node; return error_mark_node;
} }
...@@ -6530,7 +6787,7 @@ cp_parser_question_colon_clause (cp_parser* parser, tree logical_or_expr) ...@@ -6530,7 +6787,7 @@ cp_parser_question_colon_clause (cp_parser* parser, tree logical_or_expr)
} }
/* The next token should be a `:'. */ /* The next token should be a `:'. */
cp_parser_require (parser, CPP_COLON, "%<:%>"); cp_parser_require (parser, CPP_COLON, RT_COLON);
/* Parse the assignment-expression. */ /* Parse the assignment-expression. */
assignment_expr = cp_parser_assignment_expression (parser, /*cast_p=*/false, NULL); assignment_expr = cp_parser_assignment_expression (parser, /*cast_p=*/false, NULL);
c_inhibit_evaluation_warnings -= logical_or_expr == truthvalue_true_node; c_inhibit_evaluation_warnings -= logical_or_expr == truthvalue_true_node;
...@@ -6595,7 +6852,7 @@ cp_parser_assignment_expression (cp_parser* parser, bool cast_p, ...@@ -6595,7 +6852,7 @@ cp_parser_assignment_expression (cp_parser* parser, bool cast_p,
/* An assignment may not appear in a /* An assignment may not appear in a
constant-expression. */ constant-expression. */
if (cp_parser_non_integral_constant_expression (parser, if (cp_parser_non_integral_constant_expression (parser,
"an assignment")) NIC_ASSIGNMENT))
return error_mark_node; return error_mark_node;
/* Build the assignment expression. */ /* Build the assignment expression. */
expr = build_x_modify_expr (expr, expr = build_x_modify_expr (expr,
...@@ -6730,8 +6987,7 @@ cp_parser_expression (cp_parser* parser, bool cast_p, cp_id_kind * pidk) ...@@ -6730,8 +6987,7 @@ cp_parser_expression (cp_parser* parser, bool cast_p, cp_id_kind * pidk)
/* Consume the `,'. */ /* Consume the `,'. */
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
/* A comma operator cannot appear in a constant-expression. */ /* A comma operator cannot appear in a constant-expression. */
if (cp_parser_non_integral_constant_expression (parser, if (cp_parser_non_integral_constant_expression (parser, NIC_COMMA))
"a comma operator"))
expression = error_mark_node; expression = error_mark_node;
} }
...@@ -6837,11 +7093,11 @@ cp_parser_builtin_offsetof (cp_parser *parser) ...@@ -6837,11 +7093,11 @@ cp_parser_builtin_offsetof (cp_parser *parser)
/* Consume the "__builtin_offsetof" token. */ /* Consume the "__builtin_offsetof" token. */
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
/* Consume the opening `('. */ /* Consume the opening `('. */
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
/* Parse the type-id. */ /* Parse the type-id. */
type = cp_parser_type_id (parser); type = cp_parser_type_id (parser);
/* Look for the `,'. */ /* Look for the `,'. */
cp_parser_require (parser, CPP_COMMA, "%<,%>"); cp_parser_require (parser, CPP_COMMA, RT_COMMA);
token = cp_lexer_peek_token (parser->lexer); token = cp_lexer_peek_token (parser->lexer);
/* Build the (type *)null that begins the traditional offsetof macro. */ /* Build the (type *)null that begins the traditional offsetof macro. */
...@@ -6882,7 +7138,7 @@ cp_parser_builtin_offsetof (cp_parser *parser) ...@@ -6882,7 +7138,7 @@ cp_parser_builtin_offsetof (cp_parser *parser)
default: default:
/* Error. We know the following require will fail, but /* Error. We know the following require will fail, but
that gives the proper error message. */ that gives the proper error message. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
cp_parser_skip_to_closing_parenthesis (parser, true, false, true); cp_parser_skip_to_closing_parenthesis (parser, true, false, true);
expr = error_mark_node; expr = error_mark_node;
goto failure; goto failure;
...@@ -6982,7 +7238,7 @@ cp_parser_trait_expr (cp_parser* parser, enum rid keyword) ...@@ -6982,7 +7238,7 @@ cp_parser_trait_expr (cp_parser* parser, enum rid keyword)
/* Consume the token. */ /* Consume the token. */
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
type1 = cp_parser_type_id (parser); type1 = cp_parser_type_id (parser);
...@@ -6999,7 +7255,7 @@ cp_parser_trait_expr (cp_parser* parser, enum rid keyword) ...@@ -6999,7 +7255,7 @@ cp_parser_trait_expr (cp_parser* parser, enum rid keyword)
if (binary) if (binary)
{ {
cp_parser_require (parser, CPP_COMMA, "%<,%>"); cp_parser_require (parser, CPP_COMMA, RT_COMMA);
type2 = cp_parser_type_id (parser); type2 = cp_parser_type_id (parser);
...@@ -7015,7 +7271,7 @@ cp_parser_trait_expr (cp_parser* parser, enum rid keyword) ...@@ -7015,7 +7271,7 @@ cp_parser_trait_expr (cp_parser* parser, enum rid keyword)
/*initialized=*/0, /*attrlist=*/NULL); /*initialized=*/0, /*attrlist=*/NULL);
} }
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
/* Complete the trait expression, which may mean either processing /* Complete the trait expression, which may mean either processing
the trait expr now or saving it for template instantiation. */ the trait expr now or saving it for template instantiation. */
...@@ -7184,7 +7440,7 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr) ...@@ -7184,7 +7440,7 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr)
bool first = true; bool first = true;
/* Eat the leading `['. */ /* Eat the leading `['. */
cp_parser_require (parser, CPP_OPEN_SQUARE, "%<[%>"); cp_parser_require (parser, CPP_OPEN_SQUARE, RT_OPEN_SQUARE);
/* Record default capture mode. "[&" "[=" "[&," "[=," */ /* Record default capture mode. "[&" "[=" "[&," "[=," */
if (cp_lexer_next_token_is (parser->lexer, CPP_AND) if (cp_lexer_next_token_is (parser->lexer, CPP_AND)
...@@ -7223,7 +7479,7 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr) ...@@ -7223,7 +7479,7 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr)
if (first) if (first)
first = false; first = false;
else else
cp_parser_require (parser, CPP_COMMA, "%<,%>"); cp_parser_require (parser, CPP_COMMA, RT_COMMA);
/* Possibly capture `this'. */ /* Possibly capture `this'. */
if (cp_lexer_next_token_is_keyword (parser->lexer, RID_THIS)) if (cp_lexer_next_token_is_keyword (parser->lexer, RID_THIS))
...@@ -7318,7 +7574,7 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr) ...@@ -7318,7 +7574,7 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr)
explicit_init_p); explicit_init_p);
} }
cp_parser_require (parser, CPP_CLOSE_SQUARE, "%<]%>"); cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
} }
/* Parse the (optional) middle of a lambda expression. /* Parse the (optional) middle of a lambda expression.
...@@ -7363,7 +7619,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr) ...@@ -7363,7 +7619,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
pedwarn (DECL_SOURCE_LOCATION (TREE_VALUE (t)), OPT_pedantic, pedwarn (DECL_SOURCE_LOCATION (TREE_VALUE (t)), OPT_pedantic,
"default argument specified for lambda parameter"); "default argument specified for lambda parameter");
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
attributes = cp_parser_attributes_opt (parser); attributes = cp_parser_attributes_opt (parser);
...@@ -7497,13 +7753,13 @@ cp_parser_lambda_body (cp_parser* parser, tree lambda_expr) ...@@ -7497,13 +7753,13 @@ cp_parser_lambda_body (cp_parser* parser, tree lambda_expr)
statement. */ statement. */
cp_parser_parse_tentatively (parser); cp_parser_parse_tentatively (parser);
cp_parser_require (parser, CPP_OPEN_BRACE, "%<{%>"); cp_parser_require (parser, CPP_OPEN_BRACE, RT_OPEN_BRACE);
cp_parser_require_keyword (parser, RID_RETURN, "%<return%>"); cp_parser_require_keyword (parser, RID_RETURN, RT_RETURN);
expr = cp_parser_expression (parser, /*cast_p=*/false, &idk); expr = cp_parser_expression (parser, /*cast_p=*/false, &idk);
cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
cp_parser_require (parser, CPP_CLOSE_BRACE, "%<}%>"); cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
if (cp_parser_parse_definitely (parser)) if (cp_parser_parse_definitely (parser))
{ {
...@@ -7780,7 +8036,7 @@ cp_parser_label_for_labeled_statement (cp_parser* parser) ...@@ -7780,7 +8036,7 @@ cp_parser_label_for_labeled_statement (cp_parser* parser)
} }
/* Require the `:' token. */ /* Require the `:' token. */
cp_parser_require (parser, CPP_COLON, "%<:%>"); cp_parser_require (parser, CPP_COLON, RT_COLON);
/* An ordinary label may optionally be followed by attributes. /* An ordinary label may optionally be followed by attributes.
However, this is only permitted if the attributes are then However, this is only permitted if the attributes are then
...@@ -7884,7 +8140,7 @@ cp_parser_compound_statement (cp_parser *parser, tree in_statement_expr, ...@@ -7884,7 +8140,7 @@ cp_parser_compound_statement (cp_parser *parser, tree in_statement_expr,
tree compound_stmt; tree compound_stmt;
/* Consume the `{'. */ /* Consume the `{'. */
if (!cp_parser_require (parser, CPP_OPEN_BRACE, "%<{%>")) if (!cp_parser_require (parser, CPP_OPEN_BRACE, RT_OPEN_BRACE))
return error_mark_node; return error_mark_node;
/* Begin the compound-statement. */ /* Begin the compound-statement. */
compound_stmt = begin_compound_stmt (in_try ? BCS_TRY_BLOCK : 0); compound_stmt = begin_compound_stmt (in_try ? BCS_TRY_BLOCK : 0);
...@@ -7896,7 +8152,7 @@ cp_parser_compound_statement (cp_parser *parser, tree in_statement_expr, ...@@ -7896,7 +8152,7 @@ cp_parser_compound_statement (cp_parser *parser, tree in_statement_expr,
/* Finish the compound-statement. */ /* Finish the compound-statement. */
finish_compound_stmt (compound_stmt); finish_compound_stmt (compound_stmt);
/* Consume the `}'. */ /* Consume the `}'. */
cp_parser_require (parser, CPP_CLOSE_BRACE, "%<}%>"); cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
return compound_stmt; return compound_stmt;
} }
...@@ -7963,7 +8219,7 @@ cp_parser_selection_statement (cp_parser* parser, bool *if_p) ...@@ -7963,7 +8219,7 @@ cp_parser_selection_statement (cp_parser* parser, bool *if_p)
*if_p = false; *if_p = false;
/* Peek at the next token. */ /* Peek at the next token. */
token = cp_parser_require (parser, CPP_KEYWORD, "selection-statement"); token = cp_parser_require (parser, CPP_KEYWORD, RT_SELECT);
/* See what kind of keyword it is. */ /* See what kind of keyword it is. */
keyword = token->keyword; keyword = token->keyword;
...@@ -7976,7 +8232,7 @@ cp_parser_selection_statement (cp_parser* parser, bool *if_p) ...@@ -7976,7 +8232,7 @@ cp_parser_selection_statement (cp_parser* parser, bool *if_p)
tree condition; tree condition;
/* Look for the `('. */ /* Look for the `('. */
if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>")) if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
{ {
cp_parser_skip_to_end_of_statement (parser); cp_parser_skip_to_end_of_statement (parser);
return error_mark_node; return error_mark_node;
...@@ -7991,7 +8247,7 @@ cp_parser_selection_statement (cp_parser* parser, bool *if_p) ...@@ -7991,7 +8247,7 @@ cp_parser_selection_statement (cp_parser* parser, bool *if_p)
/* Parse the condition. */ /* Parse the condition. */
condition = cp_parser_condition (parser); condition = cp_parser_condition (parser);
/* Look for the `)'. */ /* Look for the `)'. */
if (!cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>")) if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
cp_parser_skip_to_closing_parenthesis (parser, true, false, cp_parser_skip_to_closing_parenthesis (parser, true, false,
/*consume_paren=*/true); /*consume_paren=*/true);
...@@ -8186,7 +8442,7 @@ cp_parser_condition (cp_parser* parser) ...@@ -8186,7 +8442,7 @@ cp_parser_condition (cp_parser* parser)
else else
{ {
/* Consume the `='. */ /* Consume the `='. */
cp_parser_require (parser, CPP_EQ, "%<=%>"); cp_parser_require (parser, CPP_EQ, RT_EQ);
initializer = cp_parser_initializer_clause (parser, &non_constant_p); initializer = cp_parser_initializer_clause (parser, &non_constant_p);
} }
if (BRACE_ENCLOSED_INITIALIZER_P (initializer)) if (BRACE_ENCLOSED_INITIALIZER_P (initializer))
...@@ -8235,7 +8491,7 @@ cp_parser_iteration_statement (cp_parser* parser) ...@@ -8235,7 +8491,7 @@ cp_parser_iteration_statement (cp_parser* parser)
unsigned char in_statement; unsigned char in_statement;
/* Peek at the next token. */ /* Peek at the next token. */
token = cp_parser_require (parser, CPP_KEYWORD, "iteration-statement"); token = cp_parser_require (parser, CPP_KEYWORD, RT_INTERATION);
if (!token) if (!token)
return error_mark_node; return error_mark_node;
...@@ -8254,12 +8510,12 @@ cp_parser_iteration_statement (cp_parser* parser) ...@@ -8254,12 +8510,12 @@ cp_parser_iteration_statement (cp_parser* parser)
/* Begin the while-statement. */ /* Begin the while-statement. */
statement = begin_while_stmt (); statement = begin_while_stmt ();
/* Look for the `('. */ /* Look for the `('. */
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
/* Parse the condition. */ /* Parse the condition. */
condition = cp_parser_condition (parser); condition = cp_parser_condition (parser);
finish_while_stmt_cond (condition, statement); finish_while_stmt_cond (condition, statement);
/* Look for the `)'. */ /* Look for the `)'. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
/* Parse the dependent statement. */ /* Parse the dependent statement. */
parser->in_statement = IN_ITERATION_STMT; parser->in_statement = IN_ITERATION_STMT;
cp_parser_already_scoped_statement (parser); cp_parser_already_scoped_statement (parser);
...@@ -8281,17 +8537,17 @@ cp_parser_iteration_statement (cp_parser* parser) ...@@ -8281,17 +8537,17 @@ cp_parser_iteration_statement (cp_parser* parser)
parser->in_statement = in_statement; parser->in_statement = in_statement;
finish_do_body (statement); finish_do_body (statement);
/* Look for the `while' keyword. */ /* Look for the `while' keyword. */
cp_parser_require_keyword (parser, RID_WHILE, "%<while%>"); cp_parser_require_keyword (parser, RID_WHILE, RT_WHILE);
/* Look for the `('. */ /* Look for the `('. */
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
/* Parse the expression. */ /* Parse the expression. */
expression = cp_parser_expression (parser, /*cast_p=*/false, NULL); expression = cp_parser_expression (parser, /*cast_p=*/false, NULL);
/* We're done with the do-statement. */ /* We're done with the do-statement. */
finish_do_stmt (expression, statement); finish_do_stmt (expression, statement);
/* Look for the `)'. */ /* Look for the `)'. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
/* Look for the `;'. */ /* Look for the `;'. */
cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
} }
break; break;
...@@ -8303,7 +8559,7 @@ cp_parser_iteration_statement (cp_parser* parser) ...@@ -8303,7 +8559,7 @@ cp_parser_iteration_statement (cp_parser* parser)
/* Begin the for-statement. */ /* Begin the for-statement. */
statement = begin_for_stmt (); statement = begin_for_stmt ();
/* Look for the `('. */ /* Look for the `('. */
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
/* Parse the initialization. */ /* Parse the initialization. */
cp_parser_for_init_statement (parser); cp_parser_for_init_statement (parser);
finish_for_init_stmt (statement); finish_for_init_stmt (statement);
...@@ -8313,14 +8569,14 @@ cp_parser_iteration_statement (cp_parser* parser) ...@@ -8313,14 +8569,14 @@ cp_parser_iteration_statement (cp_parser* parser)
condition = cp_parser_condition (parser); condition = cp_parser_condition (parser);
finish_for_cond (condition, statement); finish_for_cond (condition, statement);
/* Look for the `;'. */ /* Look for the `;'. */
cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
/* If there's an expression, process it. */ /* If there's an expression, process it. */
if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN)) if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN))
expression = cp_parser_expression (parser, /*cast_p=*/false, NULL); expression = cp_parser_expression (parser, /*cast_p=*/false, NULL);
finish_for_expr (expression, statement); finish_for_expr (expression, statement);
/* Look for the `)'. */ /* Look for the `)'. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
/* Parse the body of the for-statement. */ /* Parse the body of the for-statement. */
parser->in_statement = IN_ITERATION_STMT; parser->in_statement = IN_ITERATION_STMT;
...@@ -8398,7 +8654,7 @@ cp_parser_jump_statement (cp_parser* parser) ...@@ -8398,7 +8654,7 @@ cp_parser_jump_statement (cp_parser* parser)
unsigned char in_statement; unsigned char in_statement;
/* Peek at the next token. */ /* Peek at the next token. */
token = cp_parser_require (parser, CPP_KEYWORD, "jump-statement"); token = cp_parser_require (parser, CPP_KEYWORD, RT_JUMP);
if (!token) if (!token)
return error_mark_node; return error_mark_node;
...@@ -8425,7 +8681,7 @@ cp_parser_jump_statement (cp_parser* parser) ...@@ -8425,7 +8681,7 @@ cp_parser_jump_statement (cp_parser* parser)
error_at (token->location, "break statement used with OpenMP for loop"); error_at (token->location, "break statement used with OpenMP for loop");
break; break;
} }
cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
break; break;
case RID_CONTINUE: case RID_CONTINUE:
...@@ -8444,7 +8700,7 @@ cp_parser_jump_statement (cp_parser* parser) ...@@ -8444,7 +8700,7 @@ cp_parser_jump_statement (cp_parser* parser)
default: default:
gcc_unreachable (); gcc_unreachable ();
} }
cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
break; break;
case RID_RETURN: case RID_RETURN:
...@@ -8466,7 +8722,7 @@ cp_parser_jump_statement (cp_parser* parser) ...@@ -8466,7 +8722,7 @@ cp_parser_jump_statement (cp_parser* parser)
/* Build the return-statement. */ /* Build the return-statement. */
statement = finish_return_stmt (expr); statement = finish_return_stmt (expr);
/* Look for the final `;'. */ /* Look for the final `;'. */
cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
} }
break; break;
...@@ -8484,7 +8740,7 @@ cp_parser_jump_statement (cp_parser* parser) ...@@ -8484,7 +8740,7 @@ cp_parser_jump_statement (cp_parser* parser)
else else
finish_goto_stmt (cp_parser_identifier (parser)); finish_goto_stmt (cp_parser_identifier (parser));
/* Look for the final `;'. */ /* Look for the final `;'. */
cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
break; break;
default: default:
...@@ -8582,13 +8838,13 @@ cp_parser_already_scoped_statement (cp_parser* parser) ...@@ -8582,13 +8838,13 @@ cp_parser_already_scoped_statement (cp_parser* parser)
{ {
/* Avoid calling cp_parser_compound_statement, so that we /* Avoid calling cp_parser_compound_statement, so that we
don't create a new scope. Do everything else by hand. */ don't create a new scope. Do everything else by hand. */
cp_parser_require (parser, CPP_OPEN_BRACE, "%<{%>"); cp_parser_require (parser, CPP_OPEN_BRACE, RT_OPEN_BRACE);
/* If the next keyword is `__label__' we have a label declaration. */ /* If the next keyword is `__label__' we have a label declaration. */
while (cp_lexer_next_token_is_keyword (parser->lexer, RID_LABEL)) while (cp_lexer_next_token_is_keyword (parser->lexer, RID_LABEL))
cp_parser_label_declaration (parser); cp_parser_label_declaration (parser);
/* Parse an (optional) statement-seq. */ /* Parse an (optional) statement-seq. */
cp_parser_statement_seq_opt (parser, NULL_TREE); cp_parser_statement_seq_opt (parser, NULL_TREE);
cp_parser_require (parser, CPP_CLOSE_BRACE, "%<}%>"); cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
} }
} }
...@@ -9033,7 +9289,7 @@ cp_parser_simple_declaration (cp_parser* parser, ...@@ -9033,7 +9289,7 @@ cp_parser_simple_declaration (cp_parser* parser,
} }
/* Consume the `;'. */ /* Consume the `;'. */
cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
done: done:
pop_deferring_access_checks (); pop_deferring_access_checks ();
...@@ -9400,7 +9656,7 @@ cp_parser_linkage_specification (cp_parser* parser) ...@@ -9400,7 +9656,7 @@ cp_parser_linkage_specification (cp_parser* parser)
tree linkage; tree linkage;
/* Look for the `extern' keyword. */ /* Look for the `extern' keyword. */
cp_parser_require_keyword (parser, RID_EXTERN, "%<extern%>"); cp_parser_require_keyword (parser, RID_EXTERN, RT_EXTERN);
/* Look for the string-literal. */ /* Look for the string-literal. */
linkage = cp_parser_string_literal (parser, false, false); linkage = cp_parser_string_literal (parser, false, false);
...@@ -9430,7 +9686,7 @@ cp_parser_linkage_specification (cp_parser* parser) ...@@ -9430,7 +9686,7 @@ cp_parser_linkage_specification (cp_parser* parser)
/* Parse the declarations. */ /* Parse the declarations. */
cp_parser_declaration_seq_opt (parser); cp_parser_declaration_seq_opt (parser);
/* Look for the closing `}'. */ /* Look for the closing `}'. */
cp_parser_require (parser, CPP_CLOSE_BRACE, "%<}%>"); cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
} }
/* Otherwise, there's just one declaration. */ /* Otherwise, there's just one declaration. */
else else
...@@ -9471,7 +9727,7 @@ cp_parser_static_assert(cp_parser *parser, bool member_p) ...@@ -9471,7 +9727,7 @@ cp_parser_static_assert(cp_parser *parser, bool member_p)
/* Look for the `static_assert' keyword. */ /* Look for the `static_assert' keyword. */
if (!cp_parser_require_keyword (parser, RID_STATIC_ASSERT, if (!cp_parser_require_keyword (parser, RID_STATIC_ASSERT,
"%<static_assert%>")) RT_STATIC_ASSERT))
return; return;
/* We know we are in a static assertion; commit to any tentative /* We know we are in a static assertion; commit to any tentative
...@@ -9480,7 +9736,7 @@ cp_parser_static_assert(cp_parser *parser, bool member_p) ...@@ -9480,7 +9736,7 @@ cp_parser_static_assert(cp_parser *parser, bool member_p)
cp_parser_commit_to_tentative_parse (parser); cp_parser_commit_to_tentative_parse (parser);
/* Parse the `(' starting the static assertion condition. */ /* Parse the `(' starting the static assertion condition. */
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
/* Parse the constant-expression. */ /* Parse the constant-expression. */
condition = condition =
...@@ -9489,7 +9745,7 @@ cp_parser_static_assert(cp_parser *parser, bool member_p) ...@@ -9489,7 +9745,7 @@ cp_parser_static_assert(cp_parser *parser, bool member_p)
/*non_constant_p=*/NULL); /*non_constant_p=*/NULL);
/* Parse the separating `,'. */ /* Parse the separating `,'. */
cp_parser_require (parser, CPP_COMMA, "%<,%>"); cp_parser_require (parser, CPP_COMMA, RT_COMMA);
/* Parse the string-literal message. */ /* Parse the string-literal message. */
message = cp_parser_string_literal (parser, message = cp_parser_string_literal (parser,
...@@ -9497,14 +9753,14 @@ cp_parser_static_assert(cp_parser *parser, bool member_p) ...@@ -9497,14 +9753,14 @@ cp_parser_static_assert(cp_parser *parser, bool member_p)
/*wide_ok=*/true); /*wide_ok=*/true);
/* A `)' completes the static assertion. */ /* A `)' completes the static assertion. */
if (!cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>")) if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
cp_parser_skip_to_closing_parenthesis (parser, cp_parser_skip_to_closing_parenthesis (parser,
/*recovering=*/true, /*recovering=*/true,
/*or_comma=*/false, /*or_comma=*/false,
/*consume_paren=*/true); /*consume_paren=*/true);
/* A semicolon terminates the declaration. */ /* A semicolon terminates the declaration. */
cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
/* Complete the static assertion, which may mean either processing /* Complete the static assertion, which may mean either processing
the static assert now or saving it for template instantiation. */ the static assert now or saving it for template instantiation. */
...@@ -9527,7 +9783,7 @@ cp_parser_decltype (cp_parser *parser) ...@@ -9527,7 +9783,7 @@ cp_parser_decltype (cp_parser *parser)
cp_token *id_expr_start_token; cp_token *id_expr_start_token;
/* Look for the `decltype' token. */ /* Look for the `decltype' token. */
if (!cp_parser_require_keyword (parser, RID_DECLTYPE, "%<decltype%>")) if (!cp_parser_require_keyword (parser, RID_DECLTYPE, RT_DECLTYPE))
return error_mark_node; return error_mark_node;
/* Types cannot be defined in a `decltype' expression. Save away the /* Types cannot be defined in a `decltype' expression. Save away the
...@@ -9553,7 +9809,7 @@ cp_parser_decltype (cp_parser *parser) ...@@ -9553,7 +9809,7 @@ cp_parser_decltype (cp_parser *parser)
++c_inhibit_evaluation_warnings; ++c_inhibit_evaluation_warnings;
/* Parse the opening `('. */ /* Parse the opening `('. */
if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>")) if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
return error_mark_node; return error_mark_node;
/* First, try parsing an id-expression. */ /* First, try parsing an id-expression. */
...@@ -9687,7 +9943,7 @@ cp_parser_decltype (cp_parser *parser) ...@@ -9687,7 +9943,7 @@ cp_parser_decltype (cp_parser *parser)
} }
/* Parse to the closing `)'. */ /* Parse to the closing `)'. */
if (!cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>")) if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
{ {
cp_parser_skip_to_closing_parenthesis (parser, true, false, cp_parser_skip_to_closing_parenthesis (parser, true, false,
/*consume_paren=*/true); /*consume_paren=*/true);
...@@ -9716,7 +9972,7 @@ cp_parser_conversion_function_id (cp_parser* parser) ...@@ -9716,7 +9972,7 @@ cp_parser_conversion_function_id (cp_parser* parser)
tree pushed_scope = NULL_TREE; tree pushed_scope = NULL_TREE;
/* Look for the `operator' token. */ /* Look for the `operator' token. */
if (!cp_parser_require_keyword (parser, RID_OPERATOR, "%<operator%>")) if (!cp_parser_require_keyword (parser, RID_OPERATOR, RT_OPERATOR))
return error_mark_node; return error_mark_node;
/* When we parse the conversion-type-id, the current scope will be /* When we parse the conversion-type-id, the current scope will be
reset. However, we need that information in able to look up the reset. However, we need that information in able to look up the
...@@ -10092,7 +10348,7 @@ static tree ...@@ -10092,7 +10348,7 @@ static tree
cp_parser_operator_function_id (cp_parser* parser) cp_parser_operator_function_id (cp_parser* parser)
{ {
/* Look for the `operator' keyword. */ /* Look for the `operator' keyword. */
if (!cp_parser_require_keyword (parser, RID_OPERATOR, "%<operator%>")) if (!cp_parser_require_keyword (parser, RID_OPERATOR, RT_OPERATOR))
return error_mark_node; return error_mark_node;
/* And then the name of the operator itself. */ /* And then the name of the operator itself. */
return cp_parser_operator (parser); return cp_parser_operator (parser);
...@@ -10148,7 +10404,7 @@ cp_parser_operator (cp_parser* parser) ...@@ -10148,7 +10404,7 @@ cp_parser_operator (cp_parser* parser)
/* Consume the `[' token. */ /* Consume the `[' token. */
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
/* Look for the `]' token. */ /* Look for the `]' token. */
cp_parser_require (parser, CPP_CLOSE_SQUARE, "%<]%>"); cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
id = ansi_opname (op == NEW_EXPR id = ansi_opname (op == NEW_EXPR
? VEC_NEW_EXPR : VEC_DELETE_EXPR); ? VEC_NEW_EXPR : VEC_DELETE_EXPR);
} }
...@@ -10307,14 +10563,14 @@ cp_parser_operator (cp_parser* parser) ...@@ -10307,14 +10563,14 @@ cp_parser_operator (cp_parser* parser)
/* Consume the `('. */ /* Consume the `('. */
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
/* Look for the matching `)'. */ /* Look for the matching `)'. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
return ansi_opname (CALL_EXPR); return ansi_opname (CALL_EXPR);
case CPP_OPEN_SQUARE: case CPP_OPEN_SQUARE:
/* Consume the `['. */ /* Consume the `['. */
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
/* Look for the matching `]'. */ /* Look for the matching `]'. */
cp_parser_require (parser, CPP_CLOSE_SQUARE, "%<]%>"); cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
return ansi_opname (ARRAY_REF); return ansi_opname (ARRAY_REF);
default: default:
...@@ -10602,8 +10858,7 @@ cp_parser_type_parameter (cp_parser* parser, bool *is_parameter_pack) ...@@ -10602,8 +10858,7 @@ cp_parser_type_parameter (cp_parser* parser, bool *is_parameter_pack)
tree parameter; tree parameter;
/* Look for a keyword to tell us what kind of parameter this is. */ /* Look for a keyword to tell us what kind of parameter this is. */
token = cp_parser_require (parser, CPP_KEYWORD, token = cp_parser_require (parser, CPP_KEYWORD, RT_CLASS_TYPENAME_TEMPLATE);
"%<class%>, %<typename%>, or %<template%>");
if (!token) if (!token)
return error_mark_node; return error_mark_node;
...@@ -10676,13 +10931,13 @@ cp_parser_type_parameter (cp_parser* parser, bool *is_parameter_pack) ...@@ -10676,13 +10931,13 @@ cp_parser_type_parameter (cp_parser* parser, bool *is_parameter_pack)
tree default_argument; tree default_argument;
/* Look for the `<'. */ /* Look for the `<'. */
cp_parser_require (parser, CPP_LESS, "%<<%>"); cp_parser_require (parser, CPP_LESS, RT_LESS);
/* Parse the template-parameter-list. */ /* Parse the template-parameter-list. */
cp_parser_template_parameter_list (parser); cp_parser_template_parameter_list (parser);
/* Look for the `>'. */ /* Look for the `>'. */
cp_parser_require (parser, CPP_GREATER, "%<>%>"); cp_parser_require (parser, CPP_GREATER, RT_GREATER);
/* Look for the `class' keyword. */ /* Look for the `class' keyword. */
cp_parser_require_keyword (parser, RID_CLASS, "%<class%>"); cp_parser_require_keyword (parser, RID_CLASS, RT_CLASS);
/* If the next token is an ellipsis, we have a template /* If the next token is an ellipsis, we have a template
argument pack. */ argument pack. */
if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS)) if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS))
...@@ -10919,7 +11174,7 @@ cp_parser_template_id (cp_parser *parser, ...@@ -10919,7 +11174,7 @@ cp_parser_template_id (cp_parser *parser,
else else
{ {
/* Look for the `<' that starts the template-argument-list. */ /* Look for the `<' that starts the template-argument-list. */
if (!cp_parser_require (parser, CPP_LESS, "%<<%>")) if (!cp_parser_require (parser, CPP_LESS, RT_LESS))
{ {
pop_deferring_access_checks (); pop_deferring_access_checks ();
return error_mark_node; return error_mark_node;
...@@ -11553,7 +11808,7 @@ cp_parser_explicit_instantiation (cp_parser* parser) ...@@ -11553,7 +11808,7 @@ cp_parser_explicit_instantiation (cp_parser* parser)
} }
/* Look for the `template' keyword. */ /* Look for the `template' keyword. */
cp_parser_require_keyword (parser, RID_TEMPLATE, "%<template%>"); cp_parser_require_keyword (parser, RID_TEMPLATE, RT_TEMPLATE);
/* Let the front end know that we are processing an explicit /* Let the front end know that we are processing an explicit
instantiation. */ instantiation. */
begin_explicit_instantiation (); begin_explicit_instantiation ();
...@@ -11638,11 +11893,11 @@ cp_parser_explicit_specialization (cp_parser* parser) ...@@ -11638,11 +11893,11 @@ cp_parser_explicit_specialization (cp_parser* parser)
cp_token *token = cp_lexer_peek_token (parser->lexer); cp_token *token = cp_lexer_peek_token (parser->lexer);
/* Look for the `template' keyword. */ /* Look for the `template' keyword. */
cp_parser_require_keyword (parser, RID_TEMPLATE, "%<template%>"); cp_parser_require_keyword (parser, RID_TEMPLATE, RT_TEMPLATE);
/* Look for the `<'. */ /* Look for the `<'. */
cp_parser_require (parser, CPP_LESS, "%<<%>"); cp_parser_require (parser, CPP_LESS, RT_LESS);
/* Look for the `>'. */ /* Look for the `>'. */
cp_parser_require (parser, CPP_GREATER, "%<>%>"); cp_parser_require (parser, CPP_GREATER, RT_GREATER);
/* We have processed another parameter list. */ /* We have processed another parameter list. */
++parser->num_template_parameter_lists; ++parser->num_template_parameter_lists;
/* [temp] /* [temp]
...@@ -12219,7 +12474,7 @@ cp_parser_nonclass_name (cp_parser* parser) ...@@ -12219,7 +12474,7 @@ cp_parser_nonclass_name (cp_parser* parser)
{ {
if (!cp_parser_simulate_error (parser)) if (!cp_parser_simulate_error (parser))
cp_parser_name_lookup_error (parser, identifier, type_decl, cp_parser_name_lookup_error (parser, identifier, type_decl,
"is not a type", token->location); NLE_TYPE, token->location);
return error_mark_node; return error_mark_node;
} }
/* Remember that the name was used in the definition of the /* Remember that the name was used in the definition of the
...@@ -12703,7 +12958,7 @@ cp_parser_enum_specifier (cp_parser* parser) ...@@ -12703,7 +12958,7 @@ cp_parser_enum_specifier (cp_parser* parser)
cp_parser_enumerator_list (parser, type); cp_parser_enumerator_list (parser, type);
/* Consume the final '}'. */ /* Consume the final '}'. */
cp_parser_require (parser, CPP_CLOSE_BRACE, "%<}%>"); cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
/* Look for trailing attributes to apply to this enumeration, and /* Look for trailing attributes to apply to this enumeration, and
apply them if appropriate. */ apply them if appropriate. */
...@@ -12890,7 +13145,7 @@ cp_parser_namespace_definition (cp_parser* parser) ...@@ -12890,7 +13145,7 @@ cp_parser_namespace_definition (cp_parser* parser)
is_inline = false; is_inline = false;
/* Look for the `namespace' keyword. */ /* Look for the `namespace' keyword. */
cp_parser_require_keyword (parser, RID_NAMESPACE, "%<namespace%>"); cp_parser_require_keyword (parser, RID_NAMESPACE, RT_NAMESPACE);
/* Get the name of the namespace. We do not attempt to distinguish /* Get the name of the namespace. We do not attempt to distinguish
between an original-namespace-definition and an between an original-namespace-definition and an
...@@ -12905,7 +13160,7 @@ cp_parser_namespace_definition (cp_parser* parser) ...@@ -12905,7 +13160,7 @@ cp_parser_namespace_definition (cp_parser* parser)
attribs = cp_parser_attributes_opt (parser); attribs = cp_parser_attributes_opt (parser);
/* Look for the `{' to start the namespace. */ /* Look for the `{' to start the namespace. */
cp_parser_require (parser, CPP_OPEN_BRACE, "%<{%>"); cp_parser_require (parser, CPP_OPEN_BRACE, RT_OPEN_BRACE);
/* Start the namespace. */ /* Start the namespace. */
push_namespace (identifier); push_namespace (identifier);
...@@ -12937,7 +13192,7 @@ cp_parser_namespace_definition (cp_parser* parser) ...@@ -12937,7 +13192,7 @@ cp_parser_namespace_definition (cp_parser* parser)
/* Finish the namespace. */ /* Finish the namespace. */
pop_namespace (); pop_namespace ();
/* Look for the final `}'. */ /* Look for the final `}'. */
cp_parser_require (parser, CPP_CLOSE_BRACE, "%<}%>"); cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
} }
/* Parse a namespace-body. /* Parse a namespace-body.
...@@ -12965,7 +13220,7 @@ cp_parser_namespace_alias_definition (cp_parser* parser) ...@@ -12965,7 +13220,7 @@ cp_parser_namespace_alias_definition (cp_parser* parser)
cp_token *token = cp_lexer_peek_token (parser->lexer); cp_token *token = cp_lexer_peek_token (parser->lexer);
/* Look for the `namespace' keyword. */ /* Look for the `namespace' keyword. */
cp_parser_require_keyword (parser, RID_NAMESPACE, "%<namespace%>"); cp_parser_require_keyword (parser, RID_NAMESPACE, RT_NAMESPACE);
/* Look for the identifier. */ /* Look for the identifier. */
identifier = cp_parser_identifier (parser); identifier = cp_parser_identifier (parser);
if (identifier == error_mark_node) if (identifier == error_mark_node)
...@@ -12981,12 +13236,12 @@ cp_parser_namespace_alias_definition (cp_parser* parser) ...@@ -12981,12 +13236,12 @@ cp_parser_namespace_alias_definition (cp_parser* parser)
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
return; return;
} }
cp_parser_require (parser, CPP_EQ, "%<=%>"); cp_parser_require (parser, CPP_EQ, RT_EQ);
/* Look for the qualified-namespace-specifier. */ /* Look for the qualified-namespace-specifier. */
namespace_specifier namespace_specifier
= cp_parser_qualified_namespace_specifier (parser); = cp_parser_qualified_namespace_specifier (parser);
/* Look for the `;' token. */ /* Look for the `;' token. */
cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
/* Register the alias in the symbol table. */ /* Register the alias in the symbol table. */
do_namespace_alias (identifier, namespace_specifier); do_namespace_alias (identifier, namespace_specifier);
...@@ -13045,7 +13300,7 @@ cp_parser_using_declaration (cp_parser* parser, ...@@ -13045,7 +13300,7 @@ cp_parser_using_declaration (cp_parser* parser,
else else
{ {
/* Look for the `using' keyword. */ /* Look for the `using' keyword. */
cp_parser_require_keyword (parser, RID_USING, "%<using%>"); cp_parser_require_keyword (parser, RID_USING, RT_USING);
/* Peek at the next token. */ /* Peek at the next token. */
token = cp_lexer_peek_token (parser->lexer); token = cp_lexer_peek_token (parser->lexer);
...@@ -13136,7 +13391,7 @@ cp_parser_using_declaration (cp_parser* parser, ...@@ -13136,7 +13391,7 @@ cp_parser_using_declaration (cp_parser* parser,
token->location); token->location);
if (decl == error_mark_node) if (decl == error_mark_node)
cp_parser_name_lookup_error (parser, identifier, cp_parser_name_lookup_error (parser, identifier,
decl, NULL, decl, NLE_NULL,
token->location); token->location);
else if (check_for_bare_parameter_packs (decl)) else if (check_for_bare_parameter_packs (decl))
return false; return false;
...@@ -13148,7 +13403,7 @@ cp_parser_using_declaration (cp_parser* parser, ...@@ -13148,7 +13403,7 @@ cp_parser_using_declaration (cp_parser* parser,
} }
/* Look for the final `;'. */ /* Look for the final `;'. */
cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
return true; return true;
} }
...@@ -13166,9 +13421,9 @@ cp_parser_using_directive (cp_parser* parser) ...@@ -13166,9 +13421,9 @@ cp_parser_using_directive (cp_parser* parser)
tree attribs; tree attribs;
/* Look for the `using' keyword. */ /* Look for the `using' keyword. */
cp_parser_require_keyword (parser, RID_USING, "%<using%>"); cp_parser_require_keyword (parser, RID_USING, RT_USING);
/* And the `namespace' keyword. */ /* And the `namespace' keyword. */
cp_parser_require_keyword (parser, RID_NAMESPACE, "%<namespace%>"); cp_parser_require_keyword (parser, RID_NAMESPACE, RT_NAMESPACE);
/* Look for the optional `::' operator. */ /* Look for the optional `::' operator. */
cp_parser_global_scope_opt (parser, /*current_scope_valid_p=*/false); cp_parser_global_scope_opt (parser, /*current_scope_valid_p=*/false);
/* And the optional nested-name-specifier. */ /* And the optional nested-name-specifier. */
...@@ -13184,7 +13439,7 @@ cp_parser_using_directive (cp_parser* parser) ...@@ -13184,7 +13439,7 @@ cp_parser_using_directive (cp_parser* parser)
/* Update the symbol table. */ /* Update the symbol table. */
parse_using_directive (namespace_decl, attribs); parse_using_directive (namespace_decl, attribs);
/* Look for the final `;'. */ /* Look for the final `;'. */
cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
} }
/* Parse an asm-definition. /* Parse an asm-definition.
...@@ -13220,10 +13475,10 @@ cp_parser_asm_definition (cp_parser* parser) ...@@ -13220,10 +13475,10 @@ cp_parser_asm_definition (cp_parser* parser)
bool invalid_inputs_p = false; bool invalid_inputs_p = false;
bool invalid_outputs_p = false; bool invalid_outputs_p = false;
bool goto_p = false; bool goto_p = false;
const char *missing = NULL; required_token missing = 0;
/* Look for the `asm' keyword. */ /* Look for the `asm' keyword. */
cp_parser_require_keyword (parser, RID_ASM, "%<asm%>"); cp_parser_require_keyword (parser, RID_ASM, RT_ASM);
/* See if the next token is `volatile'. */ /* See if the next token is `volatile'. */
if (cp_parser_allow_gnu_extensions_p (parser) if (cp_parser_allow_gnu_extensions_p (parser)
&& cp_lexer_next_token_is_keyword (parser->lexer, RID_VOLATILE)) && cp_lexer_next_token_is_keyword (parser->lexer, RID_VOLATILE))
...@@ -13243,7 +13498,7 @@ cp_parser_asm_definition (cp_parser* parser) ...@@ -13243,7 +13498,7 @@ cp_parser_asm_definition (cp_parser* parser)
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
} }
/* Look for the opening `('. */ /* Look for the opening `('. */
if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>")) if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
return; return;
/* Look for the string. */ /* Look for the string. */
string = cp_parser_string_literal (parser, false, false); string = cp_parser_string_literal (parser, false, false);
...@@ -13348,17 +13603,17 @@ cp_parser_asm_definition (cp_parser* parser) ...@@ -13348,17 +13603,17 @@ cp_parser_asm_definition (cp_parser* parser)
} }
if (goto_p && !labels_p) if (goto_p && !labels_p)
missing = clobbers_p ? "%<:%>" : "%<:%> or %<::%>"; missing = clobbers_p ? RT_COLON : RT_COLON_SCOPE;
} }
else if (goto_p) else if (goto_p)
missing = "%<:%> or %<::%>"; missing = RT_COLON_SCOPE;
/* Look for the closing `)'. */ /* Look for the closing `)'. */
if (!cp_parser_require (parser, missing ? CPP_COLON : CPP_CLOSE_PAREN, if (!cp_parser_require (parser, missing ? CPP_COLON : CPP_CLOSE_PAREN,
missing ? missing : "%<)%>")) missing ? missing : RT_CLOSE_PAREN))
cp_parser_skip_to_closing_parenthesis (parser, true, false, cp_parser_skip_to_closing_parenthesis (parser, true, false,
/*consume_paren=*/true); /*consume_paren=*/true);
cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
if (!invalid_inputs_p && !invalid_outputs_p) if (!invalid_inputs_p && !invalid_outputs_p)
{ {
...@@ -14027,7 +14282,7 @@ cp_parser_direct_declarator (cp_parser* parser, ...@@ -14027,7 +14282,7 @@ cp_parser_direct_declarator (cp_parser* parser,
*ctor_dtor_or_conv_p = *ctor_dtor_or_conv_p < 0; *ctor_dtor_or_conv_p = *ctor_dtor_or_conv_p < 0;
first = false; first = false;
/* Consume the `)'. */ /* Consume the `)'. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
/* Parse the cv-qualifier-seq. */ /* Parse the cv-qualifier-seq. */
cv_quals = cp_parser_cv_qualifier_seq_opt (parser); cv_quals = cp_parser_cv_qualifier_seq_opt (parser);
...@@ -14081,7 +14336,7 @@ cp_parser_direct_declarator (cp_parser* parser, ...@@ -14081,7 +14336,7 @@ cp_parser_direct_declarator (cp_parser* parser,
parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p; parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p;
first = false; first = false;
/* Expect a `)'. */ /* Expect a `)'. */
if (!cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>")) if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
declarator = cp_error_declarator; declarator = cp_error_declarator;
if (declarator == cp_error_declarator) if (declarator == cp_error_declarator)
break; break;
...@@ -14141,7 +14396,7 @@ cp_parser_direct_declarator (cp_parser* parser, ...@@ -14141,7 +14396,7 @@ cp_parser_direct_declarator (cp_parser* parser,
else else
bounds = NULL_TREE; bounds = NULL_TREE;
/* Look for the closing `]'. */ /* Look for the closing `]'. */
if (!cp_parser_require (parser, CPP_CLOSE_SQUARE, "%<]%>")) if (!cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE))
{ {
declarator = cp_error_declarator; declarator = cp_error_declarator;
break; break;
...@@ -14455,7 +14710,7 @@ cp_parser_ptr_operator (cp_parser* parser, ...@@ -14455,7 +14710,7 @@ cp_parser_ptr_operator (cp_parser* parser,
/* If we found it, and the next token is a `*', then we are /* If we found it, and the next token is a `*', then we are
indeed looking at a pointer-to-member operator. */ indeed looking at a pointer-to-member operator. */
if (!cp_parser_error_occurred (parser) if (!cp_parser_error_occurred (parser)
&& cp_parser_require (parser, CPP_MULT, "%<*%>")) && cp_parser_require (parser, CPP_MULT, RT_MULT))
{ {
/* Indicate that the `*' operator was used. */ /* Indicate that the `*' operator was used. */
code = INDIRECT_REF; code = INDIRECT_REF;
...@@ -14851,7 +15106,7 @@ cp_parser_parameter_declaration_clause (cp_parser* parser) ...@@ -14851,7 +15106,7 @@ cp_parser_parameter_declaration_clause (cp_parser* parser)
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
/* Expect an ellipsis. */ /* Expect an ellipsis. */
ellipsis_p ellipsis_p
= (cp_parser_require (parser, CPP_ELLIPSIS, "%<...%>") != NULL); = (cp_parser_require (parser, CPP_ELLIPSIS, RT_ELLIPSIS) != NULL);
} }
/* It might also be `...' if the optional trailing `,' was /* It might also be `...' if the optional trailing `,' was
omitted. */ omitted. */
...@@ -15559,7 +15814,7 @@ cp_parser_braced_list (cp_parser* parser, bool* non_constant_p) ...@@ -15559,7 +15814,7 @@ cp_parser_braced_list (cp_parser* parser, bool* non_constant_p)
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
} }
/* Now, there should be a trailing `}'. */ /* Now, there should be a trailing `}'. */
cp_parser_require (parser, CPP_CLOSE_BRACE, "%<}%>"); cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
TREE_TYPE (initializer) = init_list_type_node; TREE_TYPE (initializer) = init_list_type_node;
return initializer; return initializer;
} }
...@@ -15855,7 +16110,7 @@ cp_parser_class_specifier (cp_parser* parser) ...@@ -15855,7 +16110,7 @@ cp_parser_class_specifier (cp_parser* parser)
} }
/* Look for the `{'. */ /* Look for the `{'. */
if (!cp_parser_require (parser, CPP_OPEN_BRACE, "%<{%>")) if (!cp_parser_require (parser, CPP_OPEN_BRACE, RT_OPEN_BRACE))
{ {
pop_deferring_access_checks (); pop_deferring_access_checks ();
return error_mark_node; return error_mark_node;
...@@ -15906,7 +16161,7 @@ cp_parser_class_specifier (cp_parser* parser) ...@@ -15906,7 +16161,7 @@ cp_parser_class_specifier (cp_parser* parser)
cp_parser_member_specification_opt (parser); cp_parser_member_specification_opt (parser);
/* Look for the trailing `}'. */ /* Look for the trailing `}'. */
cp_parser_require (parser, CPP_CLOSE_BRACE, "%<}%>"); cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
/* Look for trailing attributes to apply to this class. */ /* Look for trailing attributes to apply to this class. */
if (cp_parser_allow_gnu_extensions_p (parser)) if (cp_parser_allow_gnu_extensions_p (parser))
attributes = cp_parser_attributes_opt (parser); attributes = cp_parser_attributes_opt (parser);
...@@ -16433,7 +16688,7 @@ cp_parser_class_key (cp_parser* parser) ...@@ -16433,7 +16688,7 @@ cp_parser_class_key (cp_parser* parser)
enum tag_types tag_type; enum tag_types tag_type;
/* Look for the class-key. */ /* Look for the class-key. */
token = cp_parser_require (parser, CPP_KEYWORD, "class-key"); token = cp_parser_require (parser, CPP_KEYWORD, RT_CLASS_KEY);
if (!token) if (!token)
return none_type; return none_type;
...@@ -16478,7 +16733,7 @@ cp_parser_member_specification_opt (cp_parser* parser) ...@@ -16478,7 +16733,7 @@ cp_parser_member_specification_opt (cp_parser* parser)
/* Remember which access-specifier is active. */ /* Remember which access-specifier is active. */
current_access_specifier = token->u.value; current_access_specifier = token->u.value;
/* Look for the `:'. */ /* Look for the `:'. */
cp_parser_require (parser, CPP_COLON, "%<:%>"); cp_parser_require (parser, CPP_COLON, RT_COLON);
break; break;
default: default:
...@@ -16909,7 +17164,7 @@ cp_parser_member_declaration (cp_parser* parser) ...@@ -16909,7 +17164,7 @@ cp_parser_member_declaration (cp_parser* parser)
} }
} }
cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
} }
/* Parse a pure-specifier. /* Parse a pure-specifier.
...@@ -16926,7 +17181,7 @@ cp_parser_pure_specifier (cp_parser* parser) ...@@ -16926,7 +17181,7 @@ cp_parser_pure_specifier (cp_parser* parser)
cp_token *token; cp_token *token;
/* Look for the `=' token. */ /* Look for the `=' token. */
if (!cp_parser_require (parser, CPP_EQ, "%<=%>")) if (!cp_parser_require (parser, CPP_EQ, RT_EQ))
return error_mark_node; return error_mark_node;
/* Look for the `0' token. */ /* Look for the `0' token. */
token = cp_lexer_peek_token (parser->lexer); token = cp_lexer_peek_token (parser->lexer);
...@@ -16973,7 +17228,7 @@ static tree ...@@ -16973,7 +17228,7 @@ static tree
cp_parser_constant_initializer (cp_parser* parser) cp_parser_constant_initializer (cp_parser* parser)
{ {
/* Look for the `=' token. */ /* Look for the `=' token. */
if (!cp_parser_require (parser, CPP_EQ, "%<=%>")) if (!cp_parser_require (parser, CPP_EQ, RT_EQ))
return error_mark_node; return error_mark_node;
/* It is invalid to write: /* It is invalid to write:
...@@ -16990,7 +17245,7 @@ cp_parser_constant_initializer (cp_parser* parser) ...@@ -16990,7 +17245,7 @@ cp_parser_constant_initializer (cp_parser* parser)
/* Skip the initializer. */ /* Skip the initializer. */
cp_parser_skip_to_closing_brace (parser); cp_parser_skip_to_closing_brace (parser);
/* Look for the trailing `}'. */ /* Look for the trailing `}'. */
cp_parser_require (parser, CPP_CLOSE_BRACE, "%<}%>"); cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
return error_mark_node; return error_mark_node;
} }
...@@ -17024,7 +17279,7 @@ cp_parser_base_clause (cp_parser* parser) ...@@ -17024,7 +17279,7 @@ cp_parser_base_clause (cp_parser* parser)
tree bases = NULL_TREE; tree bases = NULL_TREE;
/* Look for the `:' that begins the list. */ /* Look for the `:' that begins the list. */
cp_parser_require (parser, CPP_COLON, "%<:%>"); cp_parser_require (parser, CPP_COLON, RT_COLON);
/* Scan the base-specifier-list. */ /* Scan the base-specifier-list. */
while (true) while (true)
...@@ -17233,7 +17488,7 @@ cp_parser_exception_specification_opt (cp_parser* parser) ...@@ -17233,7 +17488,7 @@ cp_parser_exception_specification_opt (cp_parser* parser)
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
/* Look for the `('. */ /* Look for the `('. */
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
/* Peek at the next token. */ /* Peek at the next token. */
token = cp_lexer_peek_token (parser->lexer); token = cp_lexer_peek_token (parser->lexer);
...@@ -17255,7 +17510,7 @@ cp_parser_exception_specification_opt (cp_parser* parser) ...@@ -17255,7 +17510,7 @@ cp_parser_exception_specification_opt (cp_parser* parser)
type_id_list = empty_except_spec; type_id_list = empty_except_spec;
/* Look for the `)'. */ /* Look for the `)'. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
return type_id_list; return type_id_list;
} }
...@@ -17314,7 +17569,7 @@ cp_parser_try_block (cp_parser* parser) ...@@ -17314,7 +17569,7 @@ cp_parser_try_block (cp_parser* parser)
{ {
tree try_block; tree try_block;
cp_parser_require_keyword (parser, RID_TRY, "%<try%>"); cp_parser_require_keyword (parser, RID_TRY, RT_TRY);
try_block = begin_try_block (); try_block = begin_try_block ();
cp_parser_compound_statement (parser, NULL, true); cp_parser_compound_statement (parser, NULL, true);
finish_try_block (try_block); finish_try_block (try_block);
...@@ -17337,7 +17592,7 @@ cp_parser_function_try_block (cp_parser* parser) ...@@ -17337,7 +17592,7 @@ cp_parser_function_try_block (cp_parser* parser)
bool ctor_initializer_p; bool ctor_initializer_p;
/* Look for the `try' keyword. */ /* Look for the `try' keyword. */
if (!cp_parser_require_keyword (parser, RID_TRY, "%<try%>")) if (!cp_parser_require_keyword (parser, RID_TRY, RT_TRY))
return false; return false;
/* Let the rest of the front end know where we are. */ /* Let the rest of the front end know where we are. */
try_block = begin_function_try_block (&compound_stmt); try_block = begin_function_try_block (&compound_stmt);
...@@ -17387,12 +17642,12 @@ cp_parser_handler (cp_parser* parser) ...@@ -17387,12 +17642,12 @@ cp_parser_handler (cp_parser* parser)
tree handler; tree handler;
tree declaration; tree declaration;
cp_parser_require_keyword (parser, RID_CATCH, "%<catch%>"); cp_parser_require_keyword (parser, RID_CATCH, RT_CATCH);
handler = begin_handler (); handler = begin_handler ();
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
declaration = cp_parser_exception_declaration (parser); declaration = cp_parser_exception_declaration (parser);
finish_handler_parms (declaration, handler); finish_handler_parms (declaration, handler);
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
cp_parser_compound_statement (parser, NULL, false); cp_parser_compound_statement (parser, NULL, false);
finish_handler (handler); finish_handler (handler);
} }
...@@ -17463,7 +17718,7 @@ cp_parser_throw_expression (cp_parser* parser) ...@@ -17463,7 +17718,7 @@ cp_parser_throw_expression (cp_parser* parser)
tree expression; tree expression;
cp_token* token; cp_token* token;
cp_parser_require_keyword (parser, RID_THROW, "%<throw%>"); cp_parser_require_keyword (parser, RID_THROW, RT_THROW);
token = cp_lexer_peek_token (parser->lexer); token = cp_lexer_peek_token (parser->lexer);
/* Figure out whether or not there is an assignment-expression /* Figure out whether or not there is an assignment-expression
following the "throw" keyword. */ following the "throw" keyword. */
...@@ -17508,13 +17763,13 @@ cp_parser_asm_specification_opt (cp_parser* parser) ...@@ -17508,13 +17763,13 @@ cp_parser_asm_specification_opt (cp_parser* parser)
/* Consume the `asm' token. */ /* Consume the `asm' token. */
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
/* Look for the `('. */ /* Look for the `('. */
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
/* Look for the string-literal. */ /* Look for the string-literal. */
asm_specification = cp_parser_string_literal (parser, false, false); asm_specification = cp_parser_string_literal (parser, false, false);
/* Look for the `)'. */ /* Look for the `)'. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
return asm_specification; return asm_specification;
} }
...@@ -17558,7 +17813,7 @@ cp_parser_asm_operand_list (cp_parser* parser) ...@@ -17558,7 +17813,7 @@ cp_parser_asm_operand_list (cp_parser* parser)
name = build_string (IDENTIFIER_LENGTH (name), name = build_string (IDENTIFIER_LENGTH (name),
IDENTIFIER_POINTER (name)); IDENTIFIER_POINTER (name));
/* Look for the closing `]'. */ /* Look for the closing `]'. */
cp_parser_require (parser, CPP_CLOSE_SQUARE, "%<]%>"); cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
} }
else else
name = NULL_TREE; name = NULL_TREE;
...@@ -17566,11 +17821,11 @@ cp_parser_asm_operand_list (cp_parser* parser) ...@@ -17566,11 +17821,11 @@ cp_parser_asm_operand_list (cp_parser* parser)
string_literal = cp_parser_string_literal (parser, false, false); string_literal = cp_parser_string_literal (parser, false, false);
/* Look for the `('. */ /* Look for the `('. */
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
/* Parse the expression. */ /* Parse the expression. */
expression = cp_parser_expression (parser, /*cast_p=*/false, NULL); expression = cp_parser_expression (parser, /*cast_p=*/false, NULL);
/* Look for the `)'. */ /* Look for the `)'. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
if (name == error_mark_node if (name == error_mark_node
|| string_literal == error_mark_node || string_literal == error_mark_node
...@@ -17697,8 +17952,8 @@ cp_parser_attributes_opt (cp_parser* parser) ...@@ -17697,8 +17952,8 @@ cp_parser_attributes_opt (cp_parser* parser)
/* Consume the `__attribute__' keyword. */ /* Consume the `__attribute__' keyword. */
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
/* Look for the two `(' tokens. */ /* Look for the two `(' tokens. */
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
/* Peek at the next token. */ /* Peek at the next token. */
token = cp_lexer_peek_token (parser->lexer); token = cp_lexer_peek_token (parser->lexer);
...@@ -17711,8 +17966,8 @@ cp_parser_attributes_opt (cp_parser* parser) ...@@ -17711,8 +17966,8 @@ cp_parser_attributes_opt (cp_parser* parser)
attribute_list = NULL; attribute_list = NULL;
/* Look for the two `)' tokens. */ /* Look for the two `)' tokens. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
/* Add these new attributes to the list. */ /* Add these new attributes to the list. */
attributes = chainon (attributes, attribute_list); attributes = chainon (attributes, attribute_list);
...@@ -17857,7 +18112,7 @@ static void ...@@ -17857,7 +18112,7 @@ static void
cp_parser_label_declaration (cp_parser* parser) cp_parser_label_declaration (cp_parser* parser)
{ {
/* Look for the `__label__' keyword. */ /* Look for the `__label__' keyword. */
cp_parser_require_keyword (parser, RID_LABEL, "%<__label__%>"); cp_parser_require_keyword (parser, RID_LABEL, RT_LABEL);
while (true) while (true)
{ {
...@@ -17874,11 +18129,11 @@ cp_parser_label_declaration (cp_parser* parser) ...@@ -17874,11 +18129,11 @@ cp_parser_label_declaration (cp_parser* parser)
if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON)) if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
break; break;
/* Look for the `,' separating the label declarations. */ /* Look for the `,' separating the label declarations. */
cp_parser_require (parser, CPP_COMMA, "%<,%>"); cp_parser_require (parser, CPP_COMMA, RT_COMMA);
} }
/* Look for the final `;'. */ /* Look for the final `;'. */
cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
} }
/* Support Functions */ /* Support Functions */
...@@ -18475,7 +18730,7 @@ cp_parser_constructor_declarator_p (cp_parser *parser, bool friend_p) ...@@ -18475,7 +18730,7 @@ cp_parser_constructor_declarator_p (cp_parser *parser, bool friend_p)
takes one parameter (of type `int') and returns a value of type takes one parameter (of type `int') and returns a value of type
`S'. */ `S'. */
if (constructor_p if (constructor_p
&& !cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>")) && !cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
constructor_p = false; constructor_p = false;
if (constructor_p if (constructor_p
...@@ -18693,11 +18948,11 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p) ...@@ -18693,11 +18948,11 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p)
/* Look for the `template' keyword. */ /* Look for the `template' keyword. */
token = cp_lexer_peek_token (parser->lexer); token = cp_lexer_peek_token (parser->lexer);
if (!cp_parser_require_keyword (parser, RID_TEMPLATE, "%<template%>")) if (!cp_parser_require_keyword (parser, RID_TEMPLATE, RT_TEMPLATE))
return; return;
/* And the `<'. */ /* And the `<'. */
if (!cp_parser_require (parser, CPP_LESS, "%<<%>")) if (!cp_parser_require (parser, CPP_LESS, RT_LESS))
return; return;
if (at_class_scope_p () && current_function_decl) if (at_class_scope_p () && current_function_decl)
{ {
...@@ -18946,7 +19201,7 @@ cp_parser_single_declaration (cp_parser* parser, ...@@ -18946,7 +19201,7 @@ cp_parser_single_declaration (cp_parser* parser,
/* Look for a trailing `;' after the declaration. */ /* Look for a trailing `;' after the declaration. */
if (!function_definition_p if (!function_definition_p
&& (decl == error_mark_node && (decl == error_mark_node
|| !cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"))) || !cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON)))
cp_parser_skip_to_end_of_block_or_statement (parser); cp_parser_skip_to_end_of_block_or_statement (parser);
return decl; return decl;
...@@ -19003,8 +19258,8 @@ cp_parser_functional_cast (cp_parser* parser, tree type) ...@@ -19003,8 +19258,8 @@ cp_parser_functional_cast (cp_parser* parser, tree type)
type = TREE_TYPE (type); type = TREE_TYPE (type);
if (cast != error_mark_node if (cast != error_mark_node
&& !cast_valid_in_integral_constant_expression_p (type) && !cast_valid_in_integral_constant_expression_p (type)
&& (cp_parser_non_integral_constant_expression && (cp_parser_non_integral_constant_expression (parser,
(parser, "a call to a constructor"))) NIC_CONSTRUCTOR)))
return error_mark_node; return error_mark_node;
return cast; return cast;
} }
...@@ -19443,7 +19698,7 @@ cp_parser_sizeof_operand (cp_parser* parser, enum rid keyword) ...@@ -19443,7 +19698,7 @@ cp_parser_sizeof_operand (cp_parser* parser, enum rid keyword)
type = cp_parser_type_id (parser); type = cp_parser_type_id (parser);
parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p; parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p;
/* Now, look for the trailing `)'. */ /* Now, look for the trailing `)'. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
/* If all went well, then we're done. */ /* If all went well, then we're done. */
if (cp_parser_parse_definitely (parser)) if (cp_parser_parse_definitely (parser))
{ {
...@@ -19616,6 +19871,171 @@ cp_parser_friend_p (const cp_decl_specifier_seq *decl_specifiers) ...@@ -19616,6 +19871,171 @@ cp_parser_friend_p (const cp_decl_specifier_seq *decl_specifiers)
return decl_specifiers->specs[(int) ds_friend] != 0; return decl_specifiers->specs[(int) ds_friend] != 0;
} }
/* Issue an error message indicating that TOKEN_DESC was expected.
If KEYWORD is true, it indicated this function is called by
cp_parser_require_keword and the required token can only be
a indicated keyword. */
static void
cp_parser_required_error (cp_parser *parser,
required_token token_desc,
bool keyword)
{
switch (token_desc)
{
case RT_NEW:
cp_parser_error (parser, "expected %<new%>");
return;
case RT_DELETE:
cp_parser_error (parser, "expected %<delete%>");
return;
case RT_RETURN:
cp_parser_error (parser, "expected %<return%>");
return;
case RT_WHILE:
cp_parser_error (parser, "expected %<while%>");
return;
case RT_EXTERN:
cp_parser_error (parser, "expected %<extern%>");
return;
case RT_STATIC_ASSERT:
cp_parser_error (parser, "expected %<static_assert%>");
return;
case RT_DECLTYPE:
cp_parser_error (parser, "expected %<decltype%>");
return;
case RT_OPERATOR:
cp_parser_error (parser, "expected %<operator%>");
return;
case RT_CLASS:
cp_parser_error (parser, "expected %<class%>");
return;
case RT_TEMPLATE:
cp_parser_error (parser, "expected %<template%>");
return;
case RT_NAMESPACE:
cp_parser_error (parser, "expected %<namespace%>");
return;
case RT_USING:
cp_parser_error (parser, "expected %<using%>");
return;
case RT_ASM:
cp_parser_error (parser, "expected %<asm%>");
return;
case RT_TRY:
cp_parser_error (parser, "expected %<try%>");
return;
case RT_CATCH:
cp_parser_error (parser, "expected %<catch%>");
return;
case RT_THROW:
cp_parser_error (parser, "expected %<throw%>");
return;
case RT_LABEL:
cp_parser_error (parser, "expected %<__label__%>");
return;
case RT_AT_TRY:
cp_parser_error (parser, "expected %<@try%>");
return;
case RT_AT_SYNCHRONIZED:
cp_parser_error (parser, "expected %<@synchronized%>");
return;
case RT_AT_THROW:
cp_parser_error (parser, "expected %<@throw%>");
return;
default:
break;
}
if (!keyword)
{
switch (token_desc)
{
case RT_SEMICOLON:
cp_parser_error (parser, "expected %<;%>");
return;
case RT_OPEN_PAREN:
cp_parser_error (parser, "expected %<(%>");
return;
case RT_CLOSE_BRACE:
cp_parser_error (parser, "expected %<}%>");
return;
case RT_OPEN_BRACE:
cp_parser_error (parser, "expected %<{%>");
return;
case RT_CLOSE_SQUARE:
cp_parser_error (parser, "expected %<]%>");
return;
case RT_OPEN_SQUARE:
cp_parser_error (parser, "expected %<[%>");
return;
case RT_COMMA:
cp_parser_error (parser, "expected %<,%>");
return;
case RT_SCOPE:
cp_parser_error (parser, "expected %<::%>");
return;
case RT_LESS:
cp_parser_error (parser, "expected %<<%>");
return;
case RT_GREATER:
cp_parser_error (parser, "expected %<>%>");
return;
case RT_EQ:
cp_parser_error (parser, "expected %<=%>");
return;
case RT_ELLIPSIS:
cp_parser_error (parser, "expected %<...%>");
return;
case RT_MULT:
cp_parser_error (parser, "expected %<*%>");
return;
case RT_COMPL:
cp_parser_error (parser, "expected %<~%>");
return;
case RT_COLON:
cp_parser_error (parser, "expected %<:%>");
return;
case RT_COLON_SCOPE:
cp_parser_error (parser, "expected %<:%> or %<::%>");
return;
case RT_CLOSE_PAREN:
cp_parser_error (parser, "expected %<)%>");
return;
case RT_COMMA_CLOSE_PAREN:
cp_parser_error (parser, "expected %<,%> or %<)%>");
return;
case RT_PRAGMA_EOL:
cp_parser_error (parser, "expected end of line");
return;
case RT_NAME:
cp_parser_error (parser, "expected identifier");
return;
case RT_SELECT:
cp_parser_error (parser, "expected selection-statement");
return;
case RT_INTERATION:
cp_parser_error (parser, "expected iteration-statement");
return;
case RT_JUMP:
cp_parser_error (parser, "expected jump-statement");
return;
case RT_CLASS_KEY:
cp_parser_error (parser, "expected class-key");
return;
case RT_CLASS_TYPENAME_TEMPLATE:
cp_parser_error (parser,
"expected %<class%>, %<typename%>, or %<template%>");
return;
default:
gcc_unreachable ();
}
}
else
gcc_unreachable ();
}
/* If the next token is of the indicated TYPE, consume it. Otherwise, /* If the next token is of the indicated TYPE, consume it. Otherwise,
issue an error message indicating that TOKEN_DESC was expected. issue an error message indicating that TOKEN_DESC was expected.
...@@ -19625,7 +20045,7 @@ cp_parser_friend_p (const cp_decl_specifier_seq *decl_specifiers) ...@@ -19625,7 +20045,7 @@ cp_parser_friend_p (const cp_decl_specifier_seq *decl_specifiers)
static cp_token * static cp_token *
cp_parser_require (cp_parser* parser, cp_parser_require (cp_parser* parser,
enum cpp_ttype type, enum cpp_ttype type,
const char* token_desc) required_token token_desc)
{ {
if (cp_lexer_next_token_is (parser->lexer, type)) if (cp_lexer_next_token_is (parser->lexer, type))
return cp_lexer_consume_token (parser->lexer); return cp_lexer_consume_token (parser->lexer);
...@@ -19633,11 +20053,7 @@ cp_parser_require (cp_parser* parser, ...@@ -19633,11 +20053,7 @@ cp_parser_require (cp_parser* parser,
{ {
/* Output the MESSAGE -- unless we're parsing tentatively. */ /* Output the MESSAGE -- unless we're parsing tentatively. */
if (!cp_parser_simulate_error (parser)) if (!cp_parser_simulate_error (parser))
{ cp_parser_required_error (parser, token_desc, /*keyword=*/false);
char *message = concat ("expected ", token_desc, NULL);
cp_parser_error (parser, message);
free (message);
}
return NULL; return NULL;
} }
} }
...@@ -19655,7 +20071,7 @@ cp_parser_skip_to_end_of_template_parameter_list (cp_parser* parser) ...@@ -19655,7 +20071,7 @@ cp_parser_skip_to_end_of_template_parameter_list (cp_parser* parser)
unsigned nesting_depth = 0; unsigned nesting_depth = 0;
/* Are we ready, yet? If not, issue error message. */ /* Are we ready, yet? If not, issue error message. */
if (cp_parser_require (parser, CPP_GREATER, "%<>%>")) if (cp_parser_require (parser, CPP_GREATER, RT_GREATER))
return; return;
/* Skip tokens until the desired token is found. */ /* Skip tokens until the desired token is found. */
...@@ -19732,20 +20148,13 @@ cp_parser_skip_to_end_of_template_parameter_list (cp_parser* parser) ...@@ -19732,20 +20148,13 @@ cp_parser_skip_to_end_of_template_parameter_list (cp_parser* parser)
static cp_token * static cp_token *
cp_parser_require_keyword (cp_parser* parser, cp_parser_require_keyword (cp_parser* parser,
enum rid keyword, enum rid keyword,
const char* token_desc) required_token token_desc)
{ {
cp_token *token = cp_parser_require (parser, CPP_KEYWORD, token_desc); cp_token *token = cp_parser_require (parser, CPP_KEYWORD, token_desc);
if (token && token->keyword != keyword) if (token && token->keyword != keyword)
{ {
dyn_string_t error_msg; cp_parser_required_error (parser, token_desc, /*keyword=*/true);
/* Format the error message. */
error_msg = dyn_string_new (0);
dyn_string_append_cstr (error_msg, "expected ");
dyn_string_append_cstr (error_msg, token_desc);
cp_parser_error (parser, error_msg->s);
dyn_string_delete (error_msg);
return NULL; return NULL;
} }
...@@ -20176,7 +20585,7 @@ cp_parser_objc_message_expression (cp_parser* parser) ...@@ -20176,7 +20585,7 @@ cp_parser_objc_message_expression (cp_parser* parser)
cp_lexer_consume_token (parser->lexer); /* Eat '['. */ cp_lexer_consume_token (parser->lexer); /* Eat '['. */
receiver = cp_parser_objc_message_receiver (parser); receiver = cp_parser_objc_message_receiver (parser);
messageargs = cp_parser_objc_message_args (parser); messageargs = cp_parser_objc_message_args (parser);
cp_parser_require (parser, CPP_CLOSE_SQUARE, "%<]%>"); cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
return objc_build_message_expr (build_tree_list (receiver, messageargs)); return objc_build_message_expr (build_tree_list (receiver, messageargs));
} }
...@@ -20248,7 +20657,7 @@ cp_parser_objc_message_args (cp_parser* parser) ...@@ -20248,7 +20657,7 @@ cp_parser_objc_message_args (cp_parser* parser)
return build_tree_list (selector, NULL_TREE); return build_tree_list (selector, NULL_TREE);
maybe_unary_selector_p = false; maybe_unary_selector_p = false;
cp_parser_require (parser, CPP_COLON, "%<:%>"); cp_parser_require (parser, CPP_COLON, RT_COLON);
arg = cp_parser_assignment_expression (parser, false, NULL); arg = cp_parser_assignment_expression (parser, false, NULL);
sel_args sel_args
...@@ -20290,10 +20699,10 @@ cp_parser_objc_encode_expression (cp_parser* parser) ...@@ -20290,10 +20699,10 @@ cp_parser_objc_encode_expression (cp_parser* parser)
cp_token *token; cp_token *token;
cp_lexer_consume_token (parser->lexer); /* Eat '@encode'. */ cp_lexer_consume_token (parser->lexer); /* Eat '@encode'. */
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
token = cp_lexer_peek_token (parser->lexer); token = cp_lexer_peek_token (parser->lexer);
type = complete_type (cp_parser_type_id (parser)); type = complete_type (cp_parser_type_id (parser));
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
if (!type) if (!type)
{ {
...@@ -20313,9 +20722,9 @@ cp_parser_objc_defs_expression (cp_parser *parser) ...@@ -20313,9 +20722,9 @@ cp_parser_objc_defs_expression (cp_parser *parser)
tree name; tree name;
cp_lexer_consume_token (parser->lexer); /* Eat '@defs'. */ cp_lexer_consume_token (parser->lexer); /* Eat '@defs'. */
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
name = cp_parser_identifier (parser); name = cp_parser_identifier (parser);
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
return objc_get_class_ivars (name); return objc_get_class_ivars (name);
} }
...@@ -20333,9 +20742,9 @@ cp_parser_objc_protocol_expression (cp_parser* parser) ...@@ -20333,9 +20742,9 @@ cp_parser_objc_protocol_expression (cp_parser* parser)
tree proto; tree proto;
cp_lexer_consume_token (parser->lexer); /* Eat '@protocol'. */ cp_lexer_consume_token (parser->lexer); /* Eat '@protocol'. */
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
proto = cp_parser_identifier (parser); proto = cp_parser_identifier (parser);
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
return objc_build_protocol_expr (proto); return objc_build_protocol_expr (proto);
} }
...@@ -20364,7 +20773,7 @@ cp_parser_objc_selector_expression (cp_parser* parser) ...@@ -20364,7 +20773,7 @@ cp_parser_objc_selector_expression (cp_parser* parser)
location_t loc = cp_lexer_peek_token (parser->lexer)->location; location_t loc = cp_lexer_peek_token (parser->lexer)->location;
cp_lexer_consume_token (parser->lexer); /* Eat '@selector'. */ cp_lexer_consume_token (parser->lexer); /* Eat '@selector'. */
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
token = cp_lexer_peek_token (parser->lexer); token = cp_lexer_peek_token (parser->lexer);
while (cp_parser_objc_selector_p (token->type) || token->type == CPP_COLON while (cp_parser_objc_selector_p (token->type) || token->type == CPP_COLON
...@@ -20411,7 +20820,7 @@ cp_parser_objc_selector_expression (cp_parser* parser) ...@@ -20411,7 +20820,7 @@ cp_parser_objc_selector_expression (cp_parser* parser)
} }
finish_selector: finish_selector:
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
return objc_build_selector_expr (loc, sel_seq); return objc_build_selector_expr (loc, sel_seq);
} }
...@@ -20497,7 +20906,7 @@ cp_parser_objc_protocol_refs_opt (cp_parser* parser) ...@@ -20497,7 +20906,7 @@ cp_parser_objc_protocol_refs_opt (cp_parser* parser)
{ {
cp_lexer_consume_token (parser->lexer); /* Eat '<'. */ cp_lexer_consume_token (parser->lexer); /* Eat '<'. */
protorefs = cp_parser_objc_identifier_list (parser); protorefs = cp_parser_objc_identifier_list (parser);
cp_parser_require (parser, CPP_GREATER, "%<>%>"); cp_parser_require (parser, CPP_GREATER, RT_GREATER);
} }
return protorefs; return protorefs;
...@@ -20586,7 +20995,7 @@ cp_parser_objc_typename (cp_parser* parser) ...@@ -20586,7 +20995,7 @@ cp_parser_objc_typename (cp_parser* parser)
if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN)) if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN))
cp_type = cp_parser_type_id (parser); cp_type = cp_parser_type_id (parser);
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
type_name = build_tree_list (proto_quals, cp_type); type_name = build_tree_list (proto_quals, cp_type);
} }
...@@ -20658,7 +21067,7 @@ cp_parser_objc_method_keyword_params (cp_parser* parser) ...@@ -20658,7 +21067,7 @@ cp_parser_objc_method_keyword_params (cp_parser* parser)
return selector; return selector;
maybe_unary_selector_p = false; maybe_unary_selector_p = false;
cp_parser_require (parser, CPP_COLON, "%<:%>"); cp_parser_require (parser, CPP_COLON, RT_COLON);
type_name = cp_parser_objc_typename (parser); type_name = cp_parser_objc_typename (parser);
identifier = cp_parser_identifier (parser); identifier = cp_parser_identifier (parser);
...@@ -20988,7 +21397,7 @@ cp_parser_objc_superclass_or_category (cp_parser *parser, tree *super, ...@@ -20988,7 +21397,7 @@ cp_parser_objc_superclass_or_category (cp_parser *parser, tree *super,
{ {
cp_lexer_consume_token (parser->lexer); /* Eat '('. */ cp_lexer_consume_token (parser->lexer); /* Eat '('. */
*categ = cp_parser_identifier (parser); *categ = cp_parser_identifier (parser);
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
} }
} }
...@@ -21109,7 +21518,7 @@ cp_parser_objc_try_catch_finally_statement (cp_parser *parser) { ...@@ -21109,7 +21518,7 @@ cp_parser_objc_try_catch_finally_statement (cp_parser *parser) {
location_t location; location_t location;
tree stmt; tree stmt;
cp_parser_require_keyword (parser, RID_AT_TRY, "%<@try%>"); cp_parser_require_keyword (parser, RID_AT_TRY, RT_AT_TRY);
location = cp_lexer_peek_token (parser->lexer)->location; location = cp_lexer_peek_token (parser->lexer)->location;
/* NB: The @try block needs to be wrapped in its own STATEMENT_LIST /* NB: The @try block needs to be wrapped in its own STATEMENT_LIST
node, lest it get absorbed into the surrounding block. */ node, lest it get absorbed into the surrounding block. */
...@@ -21123,13 +21532,13 @@ cp_parser_objc_try_catch_finally_statement (cp_parser *parser) { ...@@ -21123,13 +21532,13 @@ cp_parser_objc_try_catch_finally_statement (cp_parser *parser) {
tree parm; tree parm;
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
parmdecl = cp_parser_parameter_declaration (parser, false, NULL); parmdecl = cp_parser_parameter_declaration (parser, false, NULL);
parm = grokdeclarator (parmdecl->declarator, parm = grokdeclarator (parmdecl->declarator,
&parmdecl->decl_specifiers, &parmdecl->decl_specifiers,
PARM, /*initialized=*/0, PARM, /*initialized=*/0,
/*attrlist=*/NULL); /*attrlist=*/NULL);
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
objc_begin_catch_clause (parm); objc_begin_catch_clause (parm);
cp_parser_compound_statement (parser, NULL, false); cp_parser_compound_statement (parser, NULL, false);
objc_finish_catch_clause (); objc_finish_catch_clause ();
...@@ -21161,12 +21570,12 @@ cp_parser_objc_synchronized_statement (cp_parser *parser) { ...@@ -21161,12 +21570,12 @@ cp_parser_objc_synchronized_statement (cp_parser *parser) {
location_t location; location_t location;
tree lock, stmt; tree lock, stmt;
cp_parser_require_keyword (parser, RID_AT_SYNCHRONIZED, "%<@synchronized%>"); cp_parser_require_keyword (parser, RID_AT_SYNCHRONIZED, RT_AT_SYNCHRONIZED);
location = cp_lexer_peek_token (parser->lexer)->location; location = cp_lexer_peek_token (parser->lexer)->location;
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
lock = cp_parser_expression (parser, false, NULL); lock = cp_parser_expression (parser, false, NULL);
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
/* NB: The @synchronized block needs to be wrapped in its own STATEMENT_LIST /* NB: The @synchronized block needs to be wrapped in its own STATEMENT_LIST
node, lest it get absorbed into the surrounding block. */ node, lest it get absorbed into the surrounding block. */
...@@ -21188,7 +21597,7 @@ cp_parser_objc_throw_statement (cp_parser *parser) { ...@@ -21188,7 +21597,7 @@ cp_parser_objc_throw_statement (cp_parser *parser) {
tree expr = NULL_TREE; tree expr = NULL_TREE;
location_t loc = cp_lexer_peek_token (parser->lexer)->location; location_t loc = cp_lexer_peek_token (parser->lexer)->location;
cp_parser_require_keyword (parser, RID_AT_THROW, "%<@throw%>"); cp_parser_require_keyword (parser, RID_AT_THROW, RT_AT_THROW);
if (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON)) if (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON))
expr = cp_parser_assignment_expression (parser, false, NULL); expr = cp_parser_assignment_expression (parser, false, NULL);
...@@ -21346,7 +21755,8 @@ cp_parser_omp_var_list_no_open (cp_parser *parser, enum omp_clause_code kind, ...@@ -21346,7 +21755,8 @@ cp_parser_omp_var_list_no_open (cp_parser *parser, enum omp_clause_code kind,
decl = cp_parser_lookup_name_simple (parser, name, token->location); decl = cp_parser_lookup_name_simple (parser, name, token->location);
if (decl == error_mark_node) if (decl == error_mark_node)
cp_parser_name_lookup_error (parser, name, decl, NULL, token->location); cp_parser_name_lookup_error (parser, name, decl, NLE_NULL,
token->location);
else if (kind != 0) else if (kind != 0)
{ {
tree u = build_omp_clause (token->location, kind); tree u = build_omp_clause (token->location, kind);
...@@ -21363,7 +21773,7 @@ cp_parser_omp_var_list_no_open (cp_parser *parser, enum omp_clause_code kind, ...@@ -21363,7 +21773,7 @@ cp_parser_omp_var_list_no_open (cp_parser *parser, enum omp_clause_code kind,
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
} }
if (!cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>")) if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
{ {
int ending; int ending;
...@@ -21387,7 +21797,7 @@ cp_parser_omp_var_list_no_open (cp_parser *parser, enum omp_clause_code kind, ...@@ -21387,7 +21797,7 @@ cp_parser_omp_var_list_no_open (cp_parser *parser, enum omp_clause_code kind,
static tree static tree
cp_parser_omp_var_list (cp_parser *parser, enum omp_clause_code kind, tree list) cp_parser_omp_var_list (cp_parser *parser, enum omp_clause_code kind, tree list)
{ {
if (cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>")) if (cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
return cp_parser_omp_var_list_no_open (parser, kind, list); return cp_parser_omp_var_list_no_open (parser, kind, list);
return list; return list;
} }
...@@ -21403,12 +21813,12 @@ cp_parser_omp_clause_collapse (cp_parser *parser, tree list, location_t location ...@@ -21403,12 +21813,12 @@ cp_parser_omp_clause_collapse (cp_parser *parser, tree list, location_t location
HOST_WIDE_INT n; HOST_WIDE_INT n;
loc = cp_lexer_peek_token (parser->lexer)->location; loc = cp_lexer_peek_token (parser->lexer)->location;
if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>")) if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
return list; return list;
num = cp_parser_constant_expression (parser, false, NULL); num = cp_parser_constant_expression (parser, false, NULL);
if (!cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>")) if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true, cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true,
/*or_comma=*/false, /*or_comma=*/false,
/*consume_paren=*/true); /*consume_paren=*/true);
...@@ -21442,7 +21852,7 @@ cp_parser_omp_clause_default (cp_parser *parser, tree list, location_t location) ...@@ -21442,7 +21852,7 @@ cp_parser_omp_clause_default (cp_parser *parser, tree list, location_t location)
enum omp_clause_default_kind kind = OMP_CLAUSE_DEFAULT_UNSPECIFIED; enum omp_clause_default_kind kind = OMP_CLAUSE_DEFAULT_UNSPECIFIED;
tree c; tree c;
if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>")) if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
return list; return list;
if (cp_lexer_next_token_is (parser->lexer, CPP_NAME)) if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
{ {
...@@ -21475,7 +21885,7 @@ cp_parser_omp_clause_default (cp_parser *parser, tree list, location_t location) ...@@ -21475,7 +21885,7 @@ cp_parser_omp_clause_default (cp_parser *parser, tree list, location_t location)
cp_parser_error (parser, "expected %<none%> or %<shared%>"); cp_parser_error (parser, "expected %<none%> or %<shared%>");
} }
if (!cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>")) if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true, cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true,
/*or_comma=*/false, /*or_comma=*/false,
/*consume_paren=*/true); /*consume_paren=*/true);
...@@ -21499,13 +21909,13 @@ cp_parser_omp_clause_if (cp_parser *parser, tree list, location_t location) ...@@ -21499,13 +21909,13 @@ cp_parser_omp_clause_if (cp_parser *parser, tree list, location_t location)
{ {
tree t, c; tree t, c;
if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>")) if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
return list; return list;
t = cp_parser_condition (parser); t = cp_parser_condition (parser);
if (t == error_mark_node if (t == error_mark_node
|| !cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>")) || !cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true, cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true,
/*or_comma=*/false, /*or_comma=*/false,
/*consume_paren=*/true); /*consume_paren=*/true);
...@@ -21544,13 +21954,13 @@ cp_parser_omp_clause_num_threads (cp_parser *parser, tree list, ...@@ -21544,13 +21954,13 @@ cp_parser_omp_clause_num_threads (cp_parser *parser, tree list,
{ {
tree t, c; tree t, c;
if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>")) if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
return list; return list;
t = cp_parser_expression (parser, false, NULL); t = cp_parser_expression (parser, false, NULL);
if (t == error_mark_node if (t == error_mark_node
|| !cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>")) || !cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true, cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true,
/*or_comma=*/false, /*or_comma=*/false,
/*consume_paren=*/true); /*consume_paren=*/true);
...@@ -21594,7 +22004,7 @@ cp_parser_omp_clause_reduction (cp_parser *parser, tree list) ...@@ -21594,7 +22004,7 @@ cp_parser_omp_clause_reduction (cp_parser *parser, tree list)
enum tree_code code; enum tree_code code;
tree nlist, c; tree nlist, c;
if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>")) if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
return list; return list;
switch (cp_lexer_peek_token (parser->lexer)->type) switch (cp_lexer_peek_token (parser->lexer)->type)
...@@ -21634,7 +22044,7 @@ cp_parser_omp_clause_reduction (cp_parser *parser, tree list) ...@@ -21634,7 +22044,7 @@ cp_parser_omp_clause_reduction (cp_parser *parser, tree list)
} }
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
if (!cp_parser_require (parser, CPP_COLON, "%<:%>")) if (!cp_parser_require (parser, CPP_COLON, RT_COLON))
goto resync_fail; goto resync_fail;
nlist = cp_parser_omp_var_list_no_open (parser, OMP_CLAUSE_REDUCTION, list); nlist = cp_parser_omp_var_list_no_open (parser, OMP_CLAUSE_REDUCTION, list);
...@@ -21656,7 +22066,7 @@ cp_parser_omp_clause_schedule (cp_parser *parser, tree list, location_t location ...@@ -21656,7 +22066,7 @@ cp_parser_omp_clause_schedule (cp_parser *parser, tree list, location_t location
{ {
tree c, t; tree c, t;
if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>")) if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
return list; return list;
c = build_omp_clause (location, OMP_CLAUSE_SCHEDULE); c = build_omp_clause (location, OMP_CLAUSE_SCHEDULE);
...@@ -21717,10 +22127,10 @@ cp_parser_omp_clause_schedule (cp_parser *parser, tree list, location_t location ...@@ -21717,10 +22127,10 @@ cp_parser_omp_clause_schedule (cp_parser *parser, tree list, location_t location
else else
OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (c) = t; OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (c) = t;
if (!cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>")) if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
goto resync_fail; goto resync_fail;
} }
else if (!cp_parser_require (parser, CPP_CLOSE_PAREN, "%<,%> or %<)%>")) else if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_COMMA_CLOSE_PAREN))
goto resync_fail; goto resync_fail;
check_no_duplicate_clause (list, OMP_CLAUSE_SCHEDULE, "schedule", location); check_no_duplicate_clause (list, OMP_CLAUSE_SCHEDULE, "schedule", location);
...@@ -22030,7 +22440,7 @@ cp_parser_omp_critical (cp_parser *parser, cp_token *pragma_tok) ...@@ -22030,7 +22440,7 @@ cp_parser_omp_critical (cp_parser *parser, cp_token *pragma_tok)
name = cp_parser_identifier (parser); name = cp_parser_identifier (parser);
if (name == error_mark_node if (name == error_mark_node
|| !cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>")) || !cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true, cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true,
/*or_comma=*/false, /*or_comma=*/false,
/*consume_paren=*/true); /*consume_paren=*/true);
...@@ -22228,7 +22638,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) ...@@ -22228,7 +22638,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
} }
loc = cp_lexer_consume_token (parser->lexer)->location; loc = cp_lexer_consume_token (parser->lexer)->location;
if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>")) if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
return NULL; return NULL;
init = decl = real_decl = NULL; init = decl = real_decl = NULL;
...@@ -22288,7 +22698,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) ...@@ -22288,7 +22698,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
"OpenMP %<for%> loop"); "OpenMP %<for%> loop");
else else
/* Trigger an error. */ /* Trigger an error. */
cp_parser_require (parser, CPP_EQ, "%<=%>"); cp_parser_require (parser, CPP_EQ, RT_EQ);
init = error_mark_node; init = error_mark_node;
cp_parser_skip_to_end_of_statement (parser); cp_parser_skip_to_end_of_statement (parser);
...@@ -22363,7 +22773,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) ...@@ -22363,7 +22773,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
tree rhs; tree rhs;
cp_parser_parse_definitely (parser); cp_parser_parse_definitely (parser);
cp_parser_require (parser, CPP_EQ, "%<=%>"); cp_parser_require (parser, CPP_EQ, RT_EQ);
rhs = cp_parser_assignment_expression (parser, false, NULL); rhs = cp_parser_assignment_expression (parser, false, NULL);
finish_expr_stmt (build_x_modify_expr (decl, NOP_EXPR, finish_expr_stmt (build_x_modify_expr (decl, NOP_EXPR,
rhs, rhs,
...@@ -22384,7 +22794,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) ...@@ -22384,7 +22794,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
} }
} }
} }
cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
if (this_pre_body) if (this_pre_body)
{ {
this_pre_body = pop_stmt_list (this_pre_body); this_pre_body = pop_stmt_list (this_pre_body);
...@@ -22471,7 +22881,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) ...@@ -22471,7 +22881,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
cond = NULL; cond = NULL;
if (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON)) if (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON))
cond = cp_parser_omp_for_cond (parser, decl); cond = cp_parser_omp_for_cond (parser, decl);
cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
incr = NULL; incr = NULL;
if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN)) if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN))
...@@ -22486,7 +22896,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) ...@@ -22486,7 +22896,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
incr = cp_parser_expression (parser, false, NULL); incr = cp_parser_expression (parser, false, NULL);
} }
if (!cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>")) if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true, cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true,
/*or_comma=*/false, /*or_comma=*/false,
/*consume_paren=*/true); /*consume_paren=*/true);
...@@ -22657,7 +23067,7 @@ cp_parser_omp_sections_scope (cp_parser *parser) ...@@ -22657,7 +23067,7 @@ cp_parser_omp_sections_scope (cp_parser *parser)
bool error_suppress = false; bool error_suppress = false;
cp_token *tok; cp_token *tok;
if (!cp_parser_require (parser, CPP_OPEN_BRACE, "%<{%>")) if (!cp_parser_require (parser, CPP_OPEN_BRACE, RT_OPEN_BRACE))
return NULL_TREE; return NULL_TREE;
stmt = push_stmt_list (); stmt = push_stmt_list ();
...@@ -22712,7 +23122,7 @@ cp_parser_omp_sections_scope (cp_parser *parser) ...@@ -22712,7 +23122,7 @@ cp_parser_omp_sections_scope (cp_parser *parser)
substmt = build1 (OMP_SECTION, void_type_node, substmt); substmt = build1 (OMP_SECTION, void_type_node, substmt);
add_stmt (substmt); add_stmt (substmt);
} }
cp_parser_require (parser, CPP_CLOSE_BRACE, "%<}%>"); cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
substmt = pop_stmt_list (stmt); substmt = pop_stmt_list (stmt);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment