This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, C] PR18249


On 05/20/2010 11:59 PM, Joseph S. Myers wrote:
On Thu, 20 May 2010, Shujing Zhao wrote:

+      switch (desired)
+	{
+	  case NLE_NULL:
+	    break;

As I understand it, the previous code would have crashed in the cases that now pass NLE_NULL - so those cases should never reach this part of the function, and a call to gcc_unreachable () would be better than silently continuing.
Yes, you are right. I just found if (decl != error_mark_node), the desired would never be NULL.
+	      case CPP_COLON:
+		if (strcmp (token_desc, "%<:%> or %<::%>") == 0)
+		  cp_parser_error (parser, "expected %<:%> or %<::%>");
+		else
+		  cp_parser_error (parser, "expected %<:%>");
+		break;

I don't like this approach of checking for magic strings in a description parameter. Better to change that parameter to an enum. In the generic cases
Ok, I originally thought an enum can maybe be avoided :). To clear the messages, An enum required_token is added this time. A new function cp_parser_required_error is added to handle the required message.

if you use an explicit cp_parser_error call for each case then you can keep using %< and %> and so get consistent English quotes. (Actually, you could get consistent quotes anyway by using %%< and %%> instead of '' in the asprintf format string, as the result of asprintf gets passed through the GCC format interpretation by cp_parser_error. But the double interpretation isn't going to be obvious to translators, which itself is a reason to avoid building up format strings with asprintf.)
Thanks

Tested on i686-pc-linux-gnu with no regression. Is it ok?

Thanks
Pearly


2010-05-19  Shujing Zhao  <pearly.zhao@oracle.com>
	
	PR c++/18249
	* parser.c (non_integral_constant): New enum.
	(name_lookup_error): New enum.
	(required_token): New enum.
	(cp_parser_required_error): New function.
	(cp_parser_require): Use it.
	(cp_parser_require_keyword): Use it.
	(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.

Index: parser.c
===================================================================
--- parser.c	(revision 159555)
+++ parser.c	(working copy)
@@ -149,6 +149,126 @@ typedef struct GTY(()) cp_token_cache {
   cp_token * GTY ((skip)) last;
 } 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.  */
 
 static cp_lexer *cp_lexer_new_main
@@ -1972,10 +2092,12 @@ static void cp_parser_set_decl_spec_type
   (cp_decl_specifier_seq *, tree, location_t, bool);
 static bool cp_parser_friend_p
   (const cp_decl_specifier_seq *);
+static void cp_parser_required_error
+  (cp_parser, required_token, bool)
 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
-  (cp_parser *, enum rid, const char *);
+  (cp_parser *, enum rid, required_token);
 static bool cp_parser_token_starts_function_definition_p
   (cp_token *);
 static bool cp_parser_next_token_starts_class_definition_p
@@ -2011,7 +2133,7 @@ static bool cp_parser_uncommitted_to_ten
 static void cp_parser_error
   (cp_parser *, const char *);
 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
   (cp_parser *);
 static bool cp_parser_check_type_definition
@@ -2021,7 +2143,7 @@ static void cp_parser_check_for_definiti
 static void cp_parser_check_for_invalid_template_id
   (cp_parser *, tree, location_t location);
 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
   (cp_parser *, tree, tree, location_t);
 static bool cp_parser_parse_and_diagnose_invalid_type_name
@@ -2088,7 +2210,7 @@ cp_parser_is_keyword (cp_token* token, e
    OTHER-TOKEN".  */
 
 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))
     {
@@ -2105,7 +2227,7 @@ cp_parser_error (cp_parser* parser, cons
 	  return;
 	}
 
-      c_parse_error (message,
+      c_parse_error (gmsgid,
 		     /* Because c_parser_error does not understand
 			CPP_KEYWORD, keywords are treated like
 			identifiers.  */
@@ -2123,7 +2245,7 @@ static void
 cp_parser_name_lookup_error (cp_parser* parser,
 			     tree name,
 			     tree decl,
-			     const char* desired,
+			     name_lookup_error desired,
 			     location_t location)
 {
   /* If name lookup completely failed, tell the user that NAME was not
@@ -2146,11 +2268,64 @@ cp_parser_name_lookup_error (cp_parser* 
 	error_at (location, "%qE has not been declared", name);
     }
   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)
-    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
-    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
@@ -2302,20 +2477,112 @@ cp_parser_check_for_invalid_template_id 
 
 static bool
 cp_parser_non_integral_constant_expression (cp_parser  *parser,
-					    const char *thing)
+					    non_integral_constant thing)
 {
   parser->non_integral_constant_expression_p = true;
   if (parser->integral_constant_expression_p)
     {
       if (!parser->allow_non_integral_constant_expression_p)
 	{
-	  /* Don't use `%s' to print THING, because quotations (`%<', `%>')
-	     in the message need to be interpreted.  */
-	  char *message = concat (thing,
-				  " cannot appear in a constant-expression",
-				  NULL);
-	  error (message);
-	  free (message);
+	  const char *msg = NULL;
+	  switch (thing)
+	    {
+  	      case NIC_FLOAT:
+	        error ("floating-point literal "
+		       "cannot appear in a constant-expression");
+		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;
 	}
     }
@@ -2638,7 +2905,7 @@ static void
 cp_parser_consume_semicolon_at_end_of_statement (cp_parser *parser)
 {
   /* 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
 	 the statement.  */
@@ -2766,7 +3033,7 @@ static void
 cp_parser_require_pragma_eol (cp_parser *parser, cp_token *pragma_tok)
 {
   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);
 }
 
@@ -2934,7 +3201,7 @@ cp_parser_identifier (cp_parser* parser)
   cp_token *token;
 
   /* 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 token ? token->u.value : error_mark_node;
 }
@@ -3253,8 +3520,7 @@ cp_parser_primary_expression (cp_parser 
 	     checked at that point.  If we are not within a cast, then
 	     this code is invalid.  */
 	  if (!cast_p)
-	    cp_parser_non_integral_constant_expression
-	      (parser, "floating-point literal");
+	    cp_parser_non_integral_constant_expression (parser, NIC_FLOAT);
 	}
       return token->u.value;
 
@@ -3332,7 +3598,7 @@ cp_parser_primary_expression (cp_parser 
 	parser->greater_than_is_operator_p
 	  = saved_greater_than_is_operator_p;
 	/* 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);
 
 	return expr;
@@ -3383,7 +3649,7 @@ cp_parser_primary_expression (cp_parser 
 	      return error_mark_node;
 	    }
 	  /* 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 finish_this_expr ();
 
@@ -3396,7 +3662,7 @@ cp_parser_primary_expression (cp_parser 
 	case RID_PRETTY_FUNCTION_NAME:
 	case RID_C99_FUNCTION_NAME:
 	  {
-	    const char *name;
+	    non_integral_constant name;
 
 	    /* The symbols __FUNCTION__, __PRETTY_FUNCTION__, and
 	       __func__ are the names of variables -- but they are
@@ -3410,13 +3676,13 @@ cp_parser_primary_expression (cp_parser 
 	    switch (token->keyword)
 	      {
 	      case RID_FUNCTION_NAME:
-		name = "%<__FUNCTION__%>";
+		name = NIC_FUNC_NAME;
 		break;
 	      case RID_PRETTY_FUNCTION_NAME:
-		name = "%<__PRETTY_FUNCTION__%>";
+		name = NIC_PRETTY_FUNC;
 		break;
 	      case RID_C99_FUNCTION_NAME:
-		name = "%<__func__%>";
+		name = NIC_C99_FUNC;
 		break;
 	      default:
 		gcc_unreachable ();
@@ -3438,20 +3704,19 @@ cp_parser_primary_expression (cp_parser 
 	       `va_arg'.  Consume the `__builtin_va_arg' token.  */
 	    cp_lexer_consume_token (parser->lexer);
 	    /* 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.  */
 	    expression = cp_parser_assignment_expression (parser,
 							  /*cast_p=*/false, NULL);
 	    /* Look for the `,'.  */
-	    cp_parser_require (parser, CPP_COMMA, "%<,%>");
+	    cp_parser_require (parser, CPP_COMMA, RT_COMMA);
 	    /* Parse the type-id.  */
 	    type = cp_parser_type_id (parser);
 	    /* 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
 	       allowed.  */
-	    if (cp_parser_non_integral_constant_expression (parser,
-							    "%<va_arg%>"))
+	    if (cp_parser_non_integral_constant_expression (parser,NIC_VA_ARG))
 	      return error_mark_node;
 	    return build_x_va_arg (expression, type);
 	  }
@@ -4204,7 +4469,7 @@ cp_parser_nested_name_specifier_opt (cp_
                                        type_p,
                                        is_declaration);
       /* 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
 	 done.  */
@@ -4257,12 +4522,14 @@ cp_parser_nested_name_specifier_opt (cp_
 			}
 		      else
                         {
-                          const char* msg = "is not a class or namespace";
                           if (cxx_dialect != cxx98)
-                            msg = "is not a class, namespace, or enumeration";
-                          cp_parser_name_lookup_error
-                            (parser, token->u.value, decl, msg,
+                            cp_parser_name_lookup_error
+                            (parser, token->u.value, decl, NLE_NOT_CXX98,
 	  		     token->location);
+			  else
+			    cp_parser_name_lookup_error
+			    (parser, token->u.value, decl, NLE_CXX98,
+			     token->location);
                         }
 		    }
 		  parser->scope = error_mark_node;
@@ -4560,26 +4827,23 @@ cp_parser_postfix_expression (cp_parser 
 	  = G_("types may not be defined in casts");
 
 	/* 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.  */
 	type = cp_parser_type_id (parser);
 	/* Look for the closing `>'.  */
-	cp_parser_require (parser, CPP_GREATER, "%<>%>");
+	cp_parser_require (parser, CPP_GREATER, RT_GREATER);
 	/* Restore the old message.  */
 	parser->type_definition_forbidden_message = saved_message;
 
 	/* 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);
-	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
 	   can be used in constant-expressions.  */
 	if (!cast_valid_in_integral_constant_expression_p (type)
-	    && (cp_parser_non_integral_constant_expression
-		(parser,
-		 "a cast to a type other than an integral or "
-		 "enumeration type")))
+	    && (cp_parser_non_integral_constant_expression (parser, NIC_CAST)))
 	  return error_mark_node;
 
 	switch (keyword)
@@ -4616,7 +4880,7 @@ cp_parser_postfix_expression (cp_parser 
 	/* Consume the `typeid' token.  */
 	cp_lexer_consume_token (parser->lexer);
 	/* 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.  */
 	saved_message = parser->type_definition_forbidden_message;
 	parser->type_definition_forbidden_message
@@ -4632,7 +4896,7 @@ cp_parser_postfix_expression (cp_parser 
 	/* Look for the `)' token.  Otherwise, we can't be sure that
 	   we're not looking at an expression: consider `typeid (int
 	   (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 (cp_parser_parse_definitely (parser))
 	  postfix_expression = get_typeid (type);
@@ -4646,13 +4910,12 @@ cp_parser_postfix_expression (cp_parser 
 	    /* Compute its typeid.  */
 	    postfix_expression = build_typeid (expression);
 	    /* 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.  */
 	parser->type_definition_forbidden_message = saved_message;
 	/* `typeid' may not appear in an integral constant expression.  */
-	if (cp_parser_non_integral_constant_expression(parser,
-						       "%<typeid%> operator"))
+	if (cp_parser_non_integral_constant_expression(parser, NIC_TYPEID))
 	  return error_mark_node;
       }
       break;
@@ -4707,9 +4970,9 @@ cp_parser_postfix_expression (cp_parser 
 	    type = cp_parser_type_id (parser);
 	    parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p;
 	    /* Look for the `)'.  */
-	    cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>");
+	    cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
 	    /* 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
 	       keep going.  */
 	    if (!cp_parser_error_occurred (parser))
@@ -4722,7 +4985,7 @@ cp_parser_postfix_expression (cp_parser 
 		if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA))
 		  cp_lexer_consume_token (parser->lexer);
 		/* 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
 	       compound-literal expression.  */
@@ -4740,8 +5003,8 @@ cp_parser_postfix_expression (cp_parser 
 		   currently accepted programs.  (Of course, as
 		   compound literals are not part of ISO C++, the
 		   standard has nothing to say.)  */
-		if (cp_parser_non_integral_constant_expression 
-		    (parser, "non-constant compound literals"))
+		if (cp_parser_non_integral_constant_expression (parser,
+								NIC_NCC))
 		  {
 		    postfix_expression = error_mark_node;
 		    break;
@@ -4833,7 +5096,7 @@ cp_parser_postfix_expression (cp_parser 
 	       constant-expressions.  */
 	    if (! builtin_valid_in_constant_expr_p (postfix_expression)
 		&& cp_parser_non_integral_constant_expression (parser,
-							       "a function call"))
+							       NIC_FUNC_CALL))
 	      {
 		postfix_expression = error_mark_node;
 		release_tree_vector (args);
@@ -4971,8 +5234,7 @@ cp_parser_postfix_expression (cp_parser 
 	    = finish_increment_expr (postfix_expression,
 				     POSTINCREMENT_EXPR);
 	  /* Increments may not appear in constant-expressions.  */
-	  if (cp_parser_non_integral_constant_expression (parser,
-							  "an increment"))
+	  if (cp_parser_non_integral_constant_expression (parser, NIC_INC))
 	    postfix_expression = error_mark_node;
 	  idk = CP_ID_KIND_NONE;
           is_member_access = false;
@@ -4987,8 +5249,7 @@ cp_parser_postfix_expression (cp_parser 
 	    = finish_increment_expr (postfix_expression,
 				     POSTDECREMENT_EXPR);
 	  /* Decrements may not appear in constant-expressions.  */
-	  if (cp_parser_non_integral_constant_expression (parser,
-							  "a decrement"))
+	  if (cp_parser_non_integral_constant_expression (parser, NIC_DEC))
 	    postfix_expression = error_mark_node;
 	  idk = CP_ID_KIND_NONE;
           is_member_access = false;
@@ -5041,7 +5302,7 @@ cp_parser_postfix_open_square_expression
     index = cp_parser_expression (parser, /*cast_p=*/false, NULL);
 
   /* 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.  */
   postfix_expression = grok_array_decl (postfix_expression, index);
@@ -5049,8 +5310,7 @@ cp_parser_postfix_open_square_expression
   /* When not doing offsetof, array references are not permitted in
      constant-expressions.  */
   if (!for_offsetof
-      && (cp_parser_non_integral_constant_expression
-	  (parser, "an array reference")))
+      && (cp_parser_non_integral_constant_expression (parser, NIC_ARRAY_REF)))
     postfix_expression = error_mark_node;
 
   return postfix_expression;
@@ -5225,7 +5485,7 @@ cp_parser_postfix_dot_deref_expression (
      constant-expressions.  */
   if (!for_offsetof
       && (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;
 
   return postfix_expression;
@@ -5273,7 +5533,7 @@ cp_parser_parenthesized_expression_list 
   if (non_constant_p)
     *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;
 
   expression_list = make_tree_vector ();
@@ -5364,7 +5624,7 @@ cp_parser_parenthesized_expression_list 
 	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;
 
@@ -5439,7 +5699,7 @@ cp_parser_pseudo_destructor_name (cp_par
 			     /*check_dependency_p=*/false,
 			     /*is_declaration=*/true);
       /* 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
      additional qualification.  */
@@ -5465,13 +5725,13 @@ cp_parser_pseudo_destructor_name (cp_par
 	return;
 
       /* Look for the `::' token.  */
-      cp_parser_require (parser, CPP_SCOPE, "%<::%>");
+      cp_parser_require (parser, CPP_SCOPE, RT_SCOPE);
     }
   else
     *scope = NULL_TREE;
 
   /* 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
      checking that it matches the first type-name.  */
   *type = cp_parser_nonclass_name (parser);
@@ -5627,7 +5887,7 @@ cp_parser_unary_expression (cp_parser *p
 	  /* Create an expression representing the address.  */
 	  expression = finish_label_address_expr (identifier, loc);
 	  if (cp_parser_non_integral_constant_expression (parser,
-						"the address of a label"))
+							  NIC_ADDR_LABEL))
 	    expression = error_mark_node;
 	  return expression;
 	}
@@ -5636,7 +5896,7 @@ cp_parser_unary_expression (cp_parser *p
     {
       tree cast_expression;
       tree expression = error_mark_node;
-      const char *non_constant_p = NULL;
+      non_integral_constant non_constant_p = 0;
 
       /* Consume the operator token.  */
       token = cp_lexer_consume_token (parser->lexer);
@@ -5649,13 +5909,13 @@ cp_parser_unary_expression (cp_parser *p
       switch (unary_operator)
 	{
 	case INDIRECT_REF:
-	  non_constant_p = "%<*%>";
+	  non_constant_p = NIC_STAR;
 	  expression = build_x_indirect_ref (cast_expression, RO_UNARY_STAR,
                                              tf_warning_or_error);
 	  break;
 
 	case ADDR_EXPR:
-	  non_constant_p = "%<&%>";
+	   non_constant_p = NIC_ADDR;
 	  /* Fall through.  */
 	case BIT_NOT_EXPR:
 	  expression = build_x_unary_op (unary_operator, cast_expression,
@@ -5664,8 +5924,8 @@ cp_parser_unary_expression (cp_parser *p
 
 	case PREINCREMENT_EXPR:
 	case PREDECREMENT_EXPR:
-	  non_constant_p = (unary_operator == PREINCREMENT_EXPR
-			    ? "%<++%>" : "%<--%>");
+	  non_constant_p = unary_operator == PREINCREMENT_EXPR
+			   ? NIC_PREINCREMENT : NIC_PREDECREMENT;
 	  /* Fall through.  */
 	case UNARY_PLUS_EXPR:
 	case NEGATE_EXPR:
@@ -5745,7 +6005,7 @@ cp_parser_new_expression (cp_parser* par
 				   /*current_scope_valid_p=*/false)
        != NULL_TREE);
   /* 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
      `( type-id )' construct.  */
   cp_parser_parse_tentatively (parser);
@@ -5769,7 +6029,7 @@ cp_parser_new_expression (cp_parser* par
       /* Parse the type-id.  */
       type = cp_parser_type_id (parser);
       /* 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);
       /* 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
@@ -5797,7 +6057,7 @@ cp_parser_new_expression (cp_parser* par
 
   /* A new-expression may not appear in an integral constant
      expression.  */
-  if (cp_parser_non_integral_constant_expression (parser, "%<new%>"))
+  if (cp_parser_non_integral_constant_expression (parser, NIC_NEW))
     ret = error_mark_node;
   else
     {
@@ -5963,7 +6223,7 @@ cp_parser_direct_new_declarator (cp_pars
       tree expression;
 
       /* 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.  */
       if (!declarator)
 	{
@@ -5997,7 +6257,7 @@ cp_parser_direct_new_declarator (cp_pars
 					   /*allow_non_constant=*/false,
 					   NULL);
       /* 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.  */
       declarator = make_array_declarator (declarator, expression);
@@ -6063,14 +6323,14 @@ cp_parser_delete_expression (cp_parser* 
 				   /*current_scope_valid_p=*/false)
        != NULL_TREE);
   /* 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.  */
   if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_SQUARE))
     {
       /* Consume the `[' token.  */
       cp_lexer_consume_token (parser->lexer);
       /* 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.  */
       array_p = true;
     }
@@ -6082,7 +6342,7 @@ cp_parser_delete_expression (cp_parser* 
 
   /* A delete-expression may not appear in an integral constant
      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 delete_sanity (expression, NULL_TREE, array_p, global_scope_p);
@@ -6215,7 +6475,7 @@ cp_parser_cast_expression (cp_parser *pa
 	  /* Look for the type-id.  */
 	  type = cp_parser_type_id (parser);
 	  /* 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;
 	}
 
@@ -6244,10 +6504,8 @@ cp_parser_cast_expression (cp_parser *pa
 	  /* Only type conversions to integral or enumeration types
 	     can be used in constant-expressions.  */
 	  if (!cast_valid_in_integral_constant_expression_p (type)
-	      && (cp_parser_non_integral_constant_expression
-		  (parser,
-		   "a cast to a type other than an integral or "
-		   "enumeration type")))
+	      && (cp_parser_non_integral_constant_expression (parser,
+							      NIC_CAST)))
 	    return error_mark_node;
 
 	  /* Perform the cast.  */
@@ -6482,8 +6740,8 @@ cp_parser_binary_expression (cp_parser* 
 	 least one of the operands is of enumeration type.  */
 
       if (overloaded_p
-	  && (cp_parser_non_integral_constant_expression
-	      (parser, "calls to overloaded operators")))
+	  && (cp_parser_non_integral_constant_expression (parser,
+							  NIC_OVERLOADED)))
 	return error_mark_node;
     }
 
@@ -6530,7 +6788,7 @@ cp_parser_question_colon_clause (cp_pars
     }
 
   /* The next token should be a `:'.  */
-  cp_parser_require (parser, CPP_COLON, "%<:%>");
+  cp_parser_require (parser, CPP_COLON, RT_COLON);
   /* Parse the assignment-expression.  */
   assignment_expr = cp_parser_assignment_expression (parser, /*cast_p=*/false, NULL);
   c_inhibit_evaluation_warnings -= logical_or_expr == truthvalue_true_node;
@@ -6595,7 +6853,7 @@ cp_parser_assignment_expression (cp_pars
 	      /* An assignment may not appear in a
 		 constant-expression.  */
 	      if (cp_parser_non_integral_constant_expression (parser,
-							      "an assignment"))
+							      NIC_ASSIGNMENT))
 		return error_mark_node;
 	      /* Build the assignment expression.  */
 	      expr = build_x_modify_expr (expr,
@@ -6730,8 +6988,7 @@ cp_parser_expression (cp_parser* parser,
       /* Consume the `,'.  */
       cp_lexer_consume_token (parser->lexer);
       /* A comma operator cannot appear in a constant-expression.  */
-      if (cp_parser_non_integral_constant_expression (parser,
-						      "a comma operator"))
+      if (cp_parser_non_integral_constant_expression (parser, NIC_COMMA))
 	expression = error_mark_node;
     }
 
@@ -6837,11 +7094,11 @@ cp_parser_builtin_offsetof (cp_parser *p
   /* Consume the "__builtin_offsetof" token.  */
   cp_lexer_consume_token (parser->lexer);
   /* Consume the opening `('.  */
-  cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>");
+  cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
   /* Parse the type-id.  */
   type = cp_parser_type_id (parser);
   /* Look for the `,'.  */
-  cp_parser_require (parser, CPP_COMMA, "%<,%>");
+  cp_parser_require (parser, CPP_COMMA, RT_COMMA);
   token = cp_lexer_peek_token (parser->lexer);
 
   /* Build the (type *)null that begins the traditional offsetof macro.  */
@@ -6882,7 +7139,7 @@ cp_parser_builtin_offsetof (cp_parser *p
 	default:
 	  /* Error.  We know the following require will fail, but
 	     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);
 	  expr = error_mark_node;
 	  goto failure;
@@ -6982,7 +7239,7 @@ cp_parser_trait_expr (cp_parser* parser,
   /* Consume the token.  */
   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);
 
@@ -6999,7 +7256,7 @@ cp_parser_trait_expr (cp_parser* parser,
 
   if (binary)
     {
-      cp_parser_require (parser, CPP_COMMA, "%<,%>");
+      cp_parser_require (parser, CPP_COMMA, RT_COMMA);
  
       type2 = cp_parser_type_id (parser);
 
@@ -7015,7 +7272,7 @@ cp_parser_trait_expr (cp_parser* parser,
 			      /*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
      the trait expr now or saving it for template instantiation.  */
@@ -7184,7 +7441,7 @@ cp_parser_lambda_introducer (cp_parser* 
   bool first = true;
 
   /* Eat the leading `['.  */
-  cp_parser_require (parser, CPP_OPEN_SQUARE, "%<[%>");
+  cp_parser_require (parser, CPP_OPEN_SQUARE, RT_OPEN_SQUARE);
 
   /* Record default capture mode.  "[&" "[=" "[&," "[=,"  */
   if (cp_lexer_next_token_is (parser->lexer, CPP_AND)
@@ -7223,7 +7480,7 @@ cp_parser_lambda_introducer (cp_parser* 
       if (first)
 	first = false;
       else
-	cp_parser_require (parser, CPP_COMMA, "%<,%>");
+	cp_parser_require (parser, CPP_COMMA, RT_COMMA);
 
       /* Possibly capture `this'.  */
       if (cp_lexer_next_token_is_keyword (parser->lexer, RID_THIS))
@@ -7318,7 +7575,7 @@ cp_parser_lambda_introducer (cp_parser* 
 		   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.
@@ -7363,7 +7620,7 @@ cp_parser_lambda_declarator_opt (cp_pars
 	  pedwarn (DECL_SOURCE_LOCATION (TREE_VALUE (t)), OPT_pedantic,
 		   "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);
 
@@ -7497,13 +7754,13 @@ cp_parser_lambda_body (cp_parser* parser
 	   statement.  */
 	cp_parser_parse_tentatively (parser);
 
-	cp_parser_require (parser, CPP_OPEN_BRACE, "%<{%>");
-	cp_parser_require_keyword (parser, RID_RETURN, "%<return%>");
+	cp_parser_require (parser, CPP_OPEN_BRACE, RT_OPEN_BRACE);
+	cp_parser_require_keyword (parser, RID_RETURN, RT_RETURN);
 
 	expr = cp_parser_expression (parser, /*cast_p=*/false, &idk);
 
-	cp_parser_require (parser, CPP_SEMICOLON, "%<;%>");
-	cp_parser_require (parser, CPP_CLOSE_BRACE, "%<}%>");
+	cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
+	cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
 
 	if (cp_parser_parse_definitely (parser))
 	  {
@@ -7780,7 +8037,7 @@ cp_parser_label_for_labeled_statement (c
     }
 
   /* 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.
      However, this is only permitted if the attributes are then
@@ -7884,7 +8141,7 @@ cp_parser_compound_statement (cp_parser 
   tree compound_stmt;
 
   /* 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;
   /* Begin the compound-statement.  */
   compound_stmt = begin_compound_stmt (in_try ? BCS_TRY_BLOCK : 0);
@@ -7896,7 +8153,7 @@ cp_parser_compound_statement (cp_parser 
   /* Finish the compound-statement.  */
   finish_compound_stmt (compound_stmt);
   /* Consume the `}'.  */
-  cp_parser_require (parser, CPP_CLOSE_BRACE, "%<}%>");
+  cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
 
   return compound_stmt;
 }
@@ -7963,7 +8220,7 @@ cp_parser_selection_statement (cp_parser
     *if_p = false;
 
   /* 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.  */
   keyword = token->keyword;
@@ -7976,7 +8233,7 @@ cp_parser_selection_statement (cp_parser
 	tree condition;
 
 	/* 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);
 	    return error_mark_node;
@@ -7991,7 +8248,7 @@ cp_parser_selection_statement (cp_parser
 	/* Parse the condition.  */
 	condition = cp_parser_condition (parser);
 	/* 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,
 						 /*consume_paren=*/true);
 
@@ -8186,7 +8443,7 @@ cp_parser_condition (cp_parser* parser)
 	  else
 	    {
 	      /* 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);
 	    }
 	  if (BRACE_ENCLOSED_INITIALIZER_P (initializer))
@@ -8235,7 +8492,7 @@ cp_parser_iteration_statement (cp_parser
   unsigned char in_statement;
 
   /* 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)
     return error_mark_node;
 
@@ -8254,12 +8511,12 @@ cp_parser_iteration_statement (cp_parser
 	/* Begin the while-statement.  */
 	statement = begin_while_stmt ();
 	/* Look for the `('.  */
-	cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>");
+	cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
 	/* Parse the condition.  */
 	condition = cp_parser_condition (parser);
 	finish_while_stmt_cond (condition, statement);
 	/* Look for the `)'.  */
-	cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>");
+	cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
 	/* Parse the dependent statement.  */
 	parser->in_statement = IN_ITERATION_STMT;
 	cp_parser_already_scoped_statement (parser);
@@ -8281,17 +8538,17 @@ cp_parser_iteration_statement (cp_parser
 	parser->in_statement = in_statement;
 	finish_do_body (statement);
 	/* 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 `('.  */
-	cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>");
+	cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
 	/* Parse the expression.  */
 	expression = cp_parser_expression (parser, /*cast_p=*/false, NULL);
 	/* We're done with the do-statement.  */
 	finish_do_stmt (expression, statement);
 	/* Look for the `)'.  */
-	cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>");
+	cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
 	/* Look for the `;'.  */
-	cp_parser_require (parser, CPP_SEMICOLON, "%<;%>");
+	cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
       }
       break;
 
@@ -8303,7 +8560,7 @@ cp_parser_iteration_statement (cp_parser
 	/* Begin the for-statement.  */
 	statement = begin_for_stmt ();
 	/* Look for the `('.  */
-	cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>");
+	cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
 	/* Parse the initialization.  */
 	cp_parser_for_init_statement (parser);
 	finish_for_init_stmt (statement);
@@ -8313,14 +8570,14 @@ cp_parser_iteration_statement (cp_parser
 	  condition = cp_parser_condition (parser);
 	finish_for_cond (condition, statement);
 	/* 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 (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN))
 	  expression = cp_parser_expression (parser, /*cast_p=*/false, NULL);
 	finish_for_expr (expression, statement);
 	/* 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.  */
 	parser->in_statement = IN_ITERATION_STMT;
@@ -8398,7 +8655,7 @@ cp_parser_jump_statement (cp_parser* par
   unsigned char in_statement;
 
   /* 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)
     return error_mark_node;
 
@@ -8425,7 +8682,7 @@ cp_parser_jump_statement (cp_parser* par
 	  error_at (token->location, "break statement used with OpenMP for loop");
 	  break;
 	}
-      cp_parser_require (parser, CPP_SEMICOLON, "%<;%>");
+      cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
       break;
 
     case RID_CONTINUE:
@@ -8444,7 +8701,7 @@ cp_parser_jump_statement (cp_parser* par
 	default:
 	  gcc_unreachable ();
 	}
-      cp_parser_require (parser, CPP_SEMICOLON, "%<;%>");
+      cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
       break;
 
     case RID_RETURN:
@@ -8466,7 +8723,7 @@ cp_parser_jump_statement (cp_parser* par
 	/* Build the return-statement.  */
 	statement = finish_return_stmt (expr);
 	/* Look for the final `;'.  */
-	cp_parser_require (parser, CPP_SEMICOLON, "%<;%>");
+	cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
       }
       break;
 
@@ -8484,7 +8741,7 @@ cp_parser_jump_statement (cp_parser* par
       else
 	finish_goto_stmt (cp_parser_identifier (parser));
       /* Look for the final `;'.  */
-      cp_parser_require (parser, CPP_SEMICOLON, "%<;%>");
+      cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
       break;
 
     default:
@@ -8582,13 +8839,13 @@ cp_parser_already_scoped_statement (cp_p
     {
       /* Avoid calling cp_parser_compound_statement, so that we
 	 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.  */
       while (cp_lexer_next_token_is_keyword (parser->lexer, RID_LABEL))
 	cp_parser_label_declaration (parser);
       /* Parse an (optional) statement-seq.  */
       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 +9290,7 @@ cp_parser_simple_declaration (cp_parser*
     }
 
   /* Consume the `;'.  */
-  cp_parser_require (parser, CPP_SEMICOLON, "%<;%>");
+  cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
 
  done:
   pop_deferring_access_checks ();
@@ -9400,7 +9657,7 @@ cp_parser_linkage_specification (cp_pars
   tree linkage;
 
   /* 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.  */
   linkage = cp_parser_string_literal (parser, false, false);
@@ -9430,7 +9687,7 @@ cp_parser_linkage_specification (cp_pars
       /* Parse the declarations.  */
       cp_parser_declaration_seq_opt (parser);
       /* 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.  */
   else
@@ -9471,7 +9728,7 @@ cp_parser_static_assert(cp_parser *parse
 
   /* Look for the `static_assert' keyword.  */
   if (!cp_parser_require_keyword (parser, RID_STATIC_ASSERT, 
-                                  "%<static_assert%>"))
+                                  RT_STATIC_ASSERT))
     return;
 
   /*  We know we are in a static assertion; commit to any tentative
@@ -9480,7 +9737,7 @@ cp_parser_static_assert(cp_parser *parse
     cp_parser_commit_to_tentative_parse (parser);
 
   /* 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.  */
   condition = 
@@ -9489,7 +9746,7 @@ cp_parser_static_assert(cp_parser *parse
                                    /*non_constant_p=*/NULL);
 
   /* Parse the separating `,'.  */
-  cp_parser_require (parser, CPP_COMMA, "%<,%>");
+  cp_parser_require (parser, CPP_COMMA, RT_COMMA);
 
   /* Parse the string-literal message.  */
   message = cp_parser_string_literal (parser, 
@@ -9497,14 +9754,14 @@ cp_parser_static_assert(cp_parser *parse
                                       /*wide_ok=*/true);
 
   /* 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, 
                                            /*recovering=*/true, 
                                            /*or_comma=*/false,
 					   /*consume_paren=*/true);
 
   /* 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 
      the static assert now or saving it for template instantiation.  */
@@ -9527,7 +9784,7 @@ cp_parser_decltype (cp_parser *parser)
   cp_token *id_expr_start_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;
 
   /* Types cannot be defined in a `decltype' expression.  Save away the
@@ -9553,7 +9810,7 @@ cp_parser_decltype (cp_parser *parser)
   ++c_inhibit_evaluation_warnings;
 
   /* 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;
   
   /* First, try parsing an id-expression.  */
@@ -9687,7 +9944,7 @@ cp_parser_decltype (cp_parser *parser)
     }
   
   /* 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,
 					     /*consume_paren=*/true);
@@ -9716,7 +9973,7 @@ cp_parser_conversion_function_id (cp_par
   tree pushed_scope = NULL_TREE;
 
   /* 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;
   /* When we parse the conversion-type-id, the current scope will be
      reset.  However, we need that information in able to look up the
@@ -10092,7 +10349,7 @@ static tree
 cp_parser_operator_function_id (cp_parser* parser)
 {
   /* 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;
   /* And then the name of the operator itself.  */
   return cp_parser_operator (parser);
@@ -10148,7 +10405,7 @@ cp_parser_operator (cp_parser* parser)
 	    /* Consume the `[' token.  */
 	    cp_lexer_consume_token (parser->lexer);
 	    /* 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
 			      ? VEC_NEW_EXPR : VEC_DELETE_EXPR);
 	  }
@@ -10307,14 +10564,14 @@ cp_parser_operator (cp_parser* parser)
       /* Consume the `('.  */
       cp_lexer_consume_token (parser->lexer);
       /* 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);
 
     case CPP_OPEN_SQUARE:
       /* Consume the `['.  */
       cp_lexer_consume_token (parser->lexer);
       /* 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);
 
     default:
@@ -10602,8 +10859,7 @@ cp_parser_type_parameter (cp_parser* par
   tree parameter;
 
   /* Look for a keyword to tell us what kind of parameter this is.  */
-  token = cp_parser_require (parser, CPP_KEYWORD,
-			     "%<class%>, %<typename%>, or %<template%>");
+  token = cp_parser_require (parser, CPP_KEYWORD, RT_CLASS_TYPENAME_TEMPLATE);
   if (!token)
     return error_mark_node;
 
@@ -10676,13 +10932,13 @@ cp_parser_type_parameter (cp_parser* par
 	tree default_argument;
 
 	/* Look for the `<'.  */
-	cp_parser_require (parser, CPP_LESS, "%<<%>");
+	cp_parser_require (parser, CPP_LESS, RT_LESS);
 	/* Parse the template-parameter-list.  */
 	cp_parser_template_parameter_list (parser);
 	/* Look for the `>'.  */
-	cp_parser_require (parser, CPP_GREATER, "%<>%>");
+	cp_parser_require (parser, CPP_GREATER, RT_GREATER);
 	/* 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
            argument pack. */
         if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS))
@@ -10919,7 +11175,7 @@ cp_parser_template_id (cp_parser *parser
   else
     {
       /* 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 ();
 	  return error_mark_node;
@@ -11553,7 +11809,7 @@ cp_parser_explicit_instantiation (cp_par
     }
 
   /* 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
      instantiation.  */
   begin_explicit_instantiation ();
@@ -11638,11 +11894,11 @@ cp_parser_explicit_specialization (cp_pa
   cp_token *token = cp_lexer_peek_token (parser->lexer);
 
   /* 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 `<'.  */
-  cp_parser_require (parser, CPP_LESS, "%<<%>");
+  cp_parser_require (parser, CPP_LESS, RT_LESS);
   /* Look for the `>'.  */
-  cp_parser_require (parser, CPP_GREATER, "%<>%>");
+  cp_parser_require (parser, CPP_GREATER, RT_GREATER);
   /* We have processed another parameter list.  */
   ++parser->num_template_parameter_lists;
   /* [temp]
@@ -12219,7 +12475,7 @@ cp_parser_nonclass_name (cp_parser* pars
     {
       if (!cp_parser_simulate_error (parser))
 	cp_parser_name_lookup_error (parser, identifier, type_decl,
-				     "is not a type", token->location);
+				     NLE_TYPE, token->location);
       return error_mark_node;
     }
   /* Remember that the name was used in the definition of the
@@ -12703,7 +12959,7 @@ cp_parser_enum_specifier (cp_parser* par
     cp_parser_enumerator_list (parser, type);
 
   /* 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
      apply them if appropriate.  */
@@ -12890,7 +13146,7 @@ cp_parser_namespace_definition (cp_parse
     is_inline = false;
 
   /* 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
      between an original-namespace-definition and an
@@ -12905,7 +13161,7 @@ cp_parser_namespace_definition (cp_parse
   attribs = cp_parser_attributes_opt (parser);
 
   /* 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.  */
   push_namespace (identifier);
 
@@ -12937,7 +13193,7 @@ cp_parser_namespace_definition (cp_parse
   /* Finish the namespace.  */
   pop_namespace ();
   /* 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.
@@ -12965,7 +13221,7 @@ cp_parser_namespace_alias_definition (cp
   cp_token *token = cp_lexer_peek_token (parser->lexer);
 
   /* 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.  */
   identifier = cp_parser_identifier (parser);
   if (identifier == error_mark_node)
@@ -12981,12 +13237,12 @@ cp_parser_namespace_alias_definition (cp
 	cp_lexer_consume_token (parser->lexer);
       return;
     }
-  cp_parser_require (parser, CPP_EQ, "%<=%>");
+  cp_parser_require (parser, CPP_EQ, RT_EQ);
   /* Look for the qualified-namespace-specifier.  */
   namespace_specifier
     = cp_parser_qualified_namespace_specifier (parser);
   /* 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.  */
   do_namespace_alias (identifier, namespace_specifier);
@@ -13045,7 +13301,7 @@ cp_parser_using_declaration (cp_parser* 
   else
     {
       /* 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.  */
       token = cp_lexer_peek_token (parser->lexer);
@@ -13136,7 +13392,7 @@ cp_parser_using_declaration (cp_parser* 
 					       token->location);
 	  if (decl == error_mark_node)
 	    cp_parser_name_lookup_error (parser, identifier,
-					 decl, NULL,
+					 decl, NLE_NULL,
 					 token->location);
 	  else if (check_for_bare_parameter_packs (decl))
 	    return false;
@@ -13148,7 +13404,7 @@ cp_parser_using_declaration (cp_parser* 
     }
 
   /* Look for the final `;'.  */
-  cp_parser_require (parser, CPP_SEMICOLON, "%<;%>");
+  cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
   
   return true;
 }
@@ -13166,9 +13422,9 @@ cp_parser_using_directive (cp_parser* pa
   tree attribs;
 
   /* 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.  */
-  cp_parser_require_keyword (parser, RID_NAMESPACE, "%<namespace%>");
+  cp_parser_require_keyword (parser, RID_NAMESPACE, RT_NAMESPACE);
   /* Look for the optional `::' operator.  */
   cp_parser_global_scope_opt (parser, /*current_scope_valid_p=*/false);
   /* And the optional nested-name-specifier.  */
@@ -13184,7 +13440,7 @@ cp_parser_using_directive (cp_parser* pa
   /* Update the symbol table.  */
   parse_using_directive (namespace_decl, attribs);
   /* Look for the final `;'.  */
-  cp_parser_require (parser, CPP_SEMICOLON, "%<;%>");
+  cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
 }
 
 /* Parse an asm-definition.
@@ -13220,10 +13476,10 @@ cp_parser_asm_definition (cp_parser* par
   bool invalid_inputs_p = false;
   bool invalid_outputs_p = false;
   bool goto_p = false;
-  const char *missing = NULL;
+  required_token missing = 0;
 
   /* 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'.  */
   if (cp_parser_allow_gnu_extensions_p (parser)
       && cp_lexer_next_token_is_keyword (parser->lexer, RID_VOLATILE))
@@ -13243,7 +13499,7 @@ cp_parser_asm_definition (cp_parser* par
       cp_lexer_consume_token (parser->lexer);
     }
   /* Look for the opening `('.  */
-  if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"))
+  if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
     return;
   /* Look for the string.  */
   string = cp_parser_string_literal (parser, false, false);
@@ -13348,17 +13604,17 @@ cp_parser_asm_definition (cp_parser* par
 	}
 
       if (goto_p && !labels_p)
-	missing = clobbers_p ? "%<:%>" : "%<:%> or %<::%>";
+	missing = clobbers_p ? RT_COLON : RT_COLON_SCOPE;
     }
   else if (goto_p)
-    missing = "%<:%> or %<::%>";
+    missing = RT_COLON_SCOPE;
 
   /* Look for the closing `)'.  */
   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,
 					   /*consume_paren=*/true);
-  cp_parser_require (parser, CPP_SEMICOLON, "%<;%>");
+  cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
 
   if (!invalid_inputs_p && !invalid_outputs_p)
     {
@@ -14027,7 +14283,7 @@ cp_parser_direct_declarator (cp_parser* 
 		    *ctor_dtor_or_conv_p = *ctor_dtor_or_conv_p < 0;
 		  first = false;
 		  /* Consume the `)'.  */
-		  cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>");
+		  cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
 
 		  /* Parse the cv-qualifier-seq.  */
 		  cv_quals = cp_parser_cv_qualifier_seq_opt (parser);
@@ -14081,7 +14337,7 @@ cp_parser_direct_declarator (cp_parser* 
 	      parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p;
 	      first = false;
 	      /* 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;
 	      if (declarator == cp_error_declarator)
 		break;
@@ -14141,7 +14397,7 @@ cp_parser_direct_declarator (cp_parser* 
 	  else
 	    bounds = NULL_TREE;
 	  /* 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;
 	      break;
@@ -14455,7 +14711,7 @@ cp_parser_ptr_operator (cp_parser* parse
       /* If we found it, and the next token is a `*', then we are
 	 indeed looking at a pointer-to-member operator.  */
       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.  */
 	  code = INDIRECT_REF;
@@ -14851,7 +15107,7 @@ cp_parser_parameter_declaration_clause (
       cp_lexer_consume_token (parser->lexer);
       /* Expect an ellipsis.  */
       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
      omitted.  */
@@ -15559,7 +15815,7 @@ cp_parser_braced_list (cp_parser* parser
 	cp_lexer_consume_token (parser->lexer);
     }
   /* 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;
   return initializer;
 }
@@ -15855,7 +16111,7 @@ cp_parser_class_specifier (cp_parser* pa
     }
 
   /* 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 ();
       return error_mark_node;
@@ -15906,7 +16162,7 @@ cp_parser_class_specifier (cp_parser* pa
     cp_parser_member_specification_opt (parser);
 
   /* 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.  */
   if (cp_parser_allow_gnu_extensions_p (parser))
     attributes = cp_parser_attributes_opt (parser);
@@ -16433,7 +16689,7 @@ cp_parser_class_key (cp_parser* parser)
   enum tag_types tag_type;
 
   /* 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)
     return none_type;
 
@@ -16478,7 +16734,7 @@ cp_parser_member_specification_opt (cp_p
 	  /* Remember which access-specifier is active.  */
 	  current_access_specifier = token->u.value;
 	  /* Look for the `:'.  */
-	  cp_parser_require (parser, CPP_COLON, "%<:%>");
+	  cp_parser_require (parser, CPP_COLON, RT_COLON);
 	  break;
 
 	default:
@@ -16909,7 +17165,7 @@ cp_parser_member_declaration (cp_parser*
 	}
     }
 
-  cp_parser_require (parser, CPP_SEMICOLON, "%<;%>");
+  cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
 }
 
 /* Parse a pure-specifier.
@@ -16926,7 +17182,7 @@ cp_parser_pure_specifier (cp_parser* par
   cp_token *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;
   /* Look for the `0' token.  */
   token = cp_lexer_peek_token (parser->lexer);
@@ -16973,7 +17229,7 @@ static tree
 cp_parser_constant_initializer (cp_parser* parser)
 {
   /* Look for the `=' token.  */
-  if (!cp_parser_require (parser, CPP_EQ, "%<=%>"))
+  if (!cp_parser_require (parser, CPP_EQ, RT_EQ))
     return error_mark_node;
 
   /* It is invalid to write:
@@ -16990,7 +17246,7 @@ cp_parser_constant_initializer (cp_parse
       /* Skip the initializer.  */
       cp_parser_skip_to_closing_brace (parser);
       /* 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;
     }
@@ -17024,7 +17280,7 @@ cp_parser_base_clause (cp_parser* parser
   tree bases = NULL_TREE;
 
   /* 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.  */
   while (true)
@@ -17233,7 +17489,7 @@ cp_parser_exception_specification_opt (c
   cp_lexer_consume_token (parser->lexer);
 
   /* 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.  */
   token = cp_lexer_peek_token (parser->lexer);
@@ -17255,7 +17511,7 @@ cp_parser_exception_specification_opt (c
     type_id_list = empty_except_spec;
 
   /* Look for the `)'.  */
-  cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>");
+  cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
 
   return type_id_list;
 }
@@ -17314,7 +17570,7 @@ cp_parser_try_block (cp_parser* parser)
 {
   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 ();
   cp_parser_compound_statement (parser, NULL, true);
   finish_try_block (try_block);
@@ -17337,7 +17593,7 @@ cp_parser_function_try_block (cp_parser*
   bool ctor_initializer_p;
 
   /* 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;
   /* Let the rest of the front end know where we are.  */
   try_block = begin_function_try_block (&compound_stmt);
@@ -17387,12 +17643,12 @@ cp_parser_handler (cp_parser* parser)
   tree handler;
   tree declaration;
 
-  cp_parser_require_keyword (parser, RID_CATCH, "%<catch%>");
+  cp_parser_require_keyword (parser, RID_CATCH, RT_CATCH);
   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);
   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);
   finish_handler (handler);
 }
@@ -17463,7 +17719,7 @@ cp_parser_throw_expression (cp_parser* p
   tree expression;
   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);
   /* Figure out whether or not there is an assignment-expression
      following the "throw" keyword.  */
@@ -17508,13 +17764,13 @@ cp_parser_asm_specification_opt (cp_pars
   /* Consume the `asm' token.  */
   cp_lexer_consume_token (parser->lexer);
   /* 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.  */
   asm_specification = cp_parser_string_literal (parser, false, false);
 
   /* Look for the `)'.  */
-  cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>");
+  cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
 
   return asm_specification;
 }
@@ -17558,7 +17814,7 @@ cp_parser_asm_operand_list (cp_parser* p
 	    name = build_string (IDENTIFIER_LENGTH (name),
 				 IDENTIFIER_POINTER (name));
 	  /* Look for the closing `]'.  */
-	  cp_parser_require (parser, CPP_CLOSE_SQUARE, "%<]%>");
+	  cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
 	}
       else
 	name = NULL_TREE;
@@ -17566,11 +17822,11 @@ cp_parser_asm_operand_list (cp_parser* p
       string_literal = cp_parser_string_literal (parser, false, false);
 
       /* Look for the `('.  */
-      cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>");
+      cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
       /* Parse the expression.  */
       expression = cp_parser_expression (parser, /*cast_p=*/false, NULL);
       /* 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 
 	  || string_literal == error_mark_node 
@@ -17697,8 +17953,8 @@ cp_parser_attributes_opt (cp_parser* par
       /* Consume the `__attribute__' keyword.  */
       cp_lexer_consume_token (parser->lexer);
       /* Look for the two `(' tokens.  */
-      cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>");
-      cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>");
+      cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
+      cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
 
       /* Peek at the next token.  */
       token = cp_lexer_peek_token (parser->lexer);
@@ -17711,8 +17967,8 @@ cp_parser_attributes_opt (cp_parser* par
 	attribute_list = NULL;
 
       /* Look for the two `)' tokens.  */
-      cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>");
-      cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>");
+      cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
+      cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
 
       /* Add these new attributes to the list.  */
       attributes = chainon (attributes, attribute_list);
@@ -17857,7 +18113,7 @@ static void
 cp_parser_label_declaration (cp_parser* parser)
 {
   /* Look for the `__label__' keyword.  */
-  cp_parser_require_keyword (parser, RID_LABEL, "%<__label__%>");
+  cp_parser_require_keyword (parser, RID_LABEL, RT_LABEL);
 
   while (true)
     {
@@ -17874,11 +18130,11 @@ cp_parser_label_declaration (cp_parser* 
       if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
 	break;
       /* 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 `;'.  */
-  cp_parser_require (parser, CPP_SEMICOLON, "%<;%>");
+  cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
 }
 
 /* Support Functions */
@@ -18475,7 +18731,7 @@ cp_parser_constructor_declarator_p (cp_p
 	 takes one parameter (of type `int') and returns a value of type
 	 `S'.  */
       if (constructor_p
-	  && !cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"))
+	  && !cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
 	constructor_p = false;
 
       if (constructor_p
@@ -18693,11 +18949,11 @@ cp_parser_template_declaration_after_exp
 
   /* Look for the `template' keyword.  */
   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;
 
   /* And the `<'.  */
-  if (!cp_parser_require (parser, CPP_LESS, "%<<%>"))
+  if (!cp_parser_require (parser, CPP_LESS, RT_LESS))
     return;
   if (at_class_scope_p () && current_function_decl)
     {
@@ -18946,7 +19202,7 @@ cp_parser_single_declaration (cp_parser*
   /* Look for a trailing `;' after the declaration.  */
   if (!function_definition_p
       && (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);
 
   return decl;
@@ -19003,8 +19259,8 @@ cp_parser_functional_cast (cp_parser* pa
     type = TREE_TYPE (type);
   if (cast != error_mark_node
       && !cast_valid_in_integral_constant_expression_p (type)
-      && (cp_parser_non_integral_constant_expression
-	  (parser, "a call to a constructor")))
+      && (cp_parser_non_integral_constant_expression (parser,
+						      NIC_CONSTRUCTOR)))
     return error_mark_node;
   return cast;
 }
@@ -19443,7 +19699,7 @@ cp_parser_sizeof_operand (cp_parser* par
       type = cp_parser_type_id (parser);
       parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p;
       /* 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 (cp_parser_parse_definitely (parser))
 	{
@@ -19616,6 +19872,171 @@ cp_parser_friend_p (const cp_decl_specif
   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,
    issue an error message indicating that TOKEN_DESC was expected.
 
@@ -19625,7 +20046,7 @@ cp_parser_friend_p (const cp_decl_specif
 static cp_token *
 cp_parser_require (cp_parser* parser,
 		   enum cpp_ttype type,
-		   const char* token_desc)
+		   required_token token_desc)
 {
   if (cp_lexer_next_token_is (parser->lexer, type))
     return cp_lexer_consume_token (parser->lexer);
@@ -19633,11 +20054,7 @@ cp_parser_require (cp_parser* parser,
     {
       /* Output the MESSAGE -- unless we're parsing tentatively.  */
       if (!cp_parser_simulate_error (parser))
-	{
-	  char *message = concat ("expected ", token_desc, NULL);
-	  cp_parser_error (parser, message);
-	  free (message);
-	}
+        cp_parser_required_error (parser, token_desc, /*keyword=*/false);
       return NULL;
     }
 }
@@ -19655,7 +20072,7 @@ cp_parser_skip_to_end_of_template_parame
   unsigned nesting_depth = 0;
 
   /* 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;
 
   /* Skip tokens until the desired token is found.  */
@@ -19732,20 +20149,13 @@ cp_parser_skip_to_end_of_template_parame
 static cp_token *
 cp_parser_require_keyword (cp_parser* parser,
 			   enum rid keyword,
-			   const char* token_desc)
+			   required_token token_desc)
 {
   cp_token *token = cp_parser_require (parser, CPP_KEYWORD, token_desc);
 
   if (token && token->keyword != keyword)
     {
-      dyn_string_t error_msg;
-
-      /* 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);
+      cp_parser_required_error (parser, token_desc,  /*keyword=*/true); 
       return NULL;
     }
 
@@ -20176,7 +20586,7 @@ cp_parser_objc_message_expression (cp_pa
   cp_lexer_consume_token (parser->lexer);  /* Eat '['.  */
   receiver = cp_parser_objc_message_receiver (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));
 }
@@ -20248,7 +20658,7 @@ cp_parser_objc_message_args (cp_parser* 
 	return build_tree_list (selector, NULL_TREE);
 
       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);
 
       sel_args
@@ -20290,10 +20700,10 @@ cp_parser_objc_encode_expression (cp_par
   cp_token *token;
 
   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);
   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)
     {
@@ -20313,9 +20723,9 @@ cp_parser_objc_defs_expression (cp_parse
   tree name;
 
   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);
-  cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>");
+  cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
 
   return objc_get_class_ivars (name);
 }
@@ -20333,9 +20743,9 @@ cp_parser_objc_protocol_expression (cp_p
   tree proto;
 
   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);
-  cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>");
+  cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
 
   return objc_build_protocol_expr (proto);
 }
@@ -20364,7 +20774,7 @@ cp_parser_objc_selector_expression (cp_p
   location_t loc = cp_lexer_peek_token (parser->lexer)->location;
 
   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);
 
   while (cp_parser_objc_selector_p (token->type) || token->type == CPP_COLON
@@ -20411,7 +20821,7 @@ cp_parser_objc_selector_expression (cp_p
     }
 
  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);
 }
@@ -20497,7 +20907,7 @@ cp_parser_objc_protocol_refs_opt (cp_par
     {
       cp_lexer_consume_token (parser->lexer);  /* Eat '<'.  */
       protorefs = cp_parser_objc_identifier_list (parser);
-      cp_parser_require (parser, CPP_GREATER, "%<>%>");
+      cp_parser_require (parser, CPP_GREATER, RT_GREATER);
     }
 
   return protorefs;
@@ -20586,7 +20996,7 @@ cp_parser_objc_typename (cp_parser* pars
       if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN))
 	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);
     }
 
@@ -20658,7 +21068,7 @@ cp_parser_objc_method_keyword_params (cp
 	return selector;
 
       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);
       identifier = cp_parser_identifier (parser);
 
@@ -20988,7 +21398,7 @@ cp_parser_objc_superclass_or_category (c
     {
       cp_lexer_consume_token (parser->lexer);  /* Eat '('.  */
       *categ = cp_parser_identifier (parser);
-      cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>");
+      cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
     }
 }
 
@@ -21109,7 +21519,7 @@ cp_parser_objc_try_catch_finally_stateme
   location_t location;
   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;
   /* NB: The @try block needs to be wrapped in its own STATEMENT_LIST
      node, lest it get absorbed into the surrounding block.  */
@@ -21123,13 +21533,13 @@ cp_parser_objc_try_catch_finally_stateme
       tree parm;
 
       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);
       parm = grokdeclarator (parmdecl->declarator,
 			     &parmdecl->decl_specifiers,
 			     PARM, /*initialized=*/0,
 			     /*attrlist=*/NULL);
-      cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>");
+      cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
       objc_begin_catch_clause (parm);
       cp_parser_compound_statement (parser, NULL, false);
       objc_finish_catch_clause ();
@@ -21161,12 +21571,12 @@ cp_parser_objc_synchronized_statement (c
   location_t location;
   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;
-  cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>");
+  cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
   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
      node, lest it get absorbed into the surrounding block.  */
@@ -21188,7 +21598,7 @@ cp_parser_objc_throw_statement (cp_parse
   tree expr = NULL_TREE;
   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))
     expr = cp_parser_assignment_expression (parser, false, NULL);
@@ -21346,7 +21756,8 @@ cp_parser_omp_var_list_no_open (cp_parse
 
       decl = cp_parser_lookup_name_simple (parser, name, token->location);
       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)
 	{
 	  tree u = build_omp_clause (token->location, kind);
@@ -21363,7 +21774,7 @@ cp_parser_omp_var_list_no_open (cp_parse
       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;
 
@@ -21387,7 +21798,7 @@ cp_parser_omp_var_list_no_open (cp_parse
 static tree
 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 list;
 }
@@ -21403,12 +21814,12 @@ cp_parser_omp_clause_collapse (cp_parser
   HOST_WIDE_INT n;
 
   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;
 
   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,
 					   /*or_comma=*/false,
 					   /*consume_paren=*/true);
@@ -21442,7 +21853,7 @@ cp_parser_omp_clause_default (cp_parser 
   enum omp_clause_default_kind kind = OMP_CLAUSE_DEFAULT_UNSPECIFIED;
   tree c;
 
-  if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"))
+  if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
     return list;
   if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
     {
@@ -21475,7 +21886,7 @@ cp_parser_omp_clause_default (cp_parser 
       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,
 					   /*or_comma=*/false,
 					   /*consume_paren=*/true);
@@ -21499,13 +21910,13 @@ cp_parser_omp_clause_if (cp_parser *pars
 {
   tree t, c;
 
-  if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"))
+  if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
     return list;
 
   t = cp_parser_condition (parser);
 
   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,
 					   /*or_comma=*/false,
 					   /*consume_paren=*/true);
@@ -21544,13 +21955,13 @@ cp_parser_omp_clause_num_threads (cp_par
 {
   tree t, c;
 
-  if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"))
+  if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
     return list;
 
   t = cp_parser_expression (parser, false, NULL);
 
   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,
 					   /*or_comma=*/false,
 					   /*consume_paren=*/true);
@@ -21594,7 +22005,7 @@ cp_parser_omp_clause_reduction (cp_parse
   enum tree_code code;
   tree nlist, c;
 
-  if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"))
+  if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
     return list;
 
   switch (cp_lexer_peek_token (parser->lexer)->type)
@@ -21634,7 +22045,7 @@ cp_parser_omp_clause_reduction (cp_parse
     }
   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;
 
   nlist = cp_parser_omp_var_list_no_open (parser, OMP_CLAUSE_REDUCTION, list);
@@ -21656,7 +22067,7 @@ cp_parser_omp_clause_schedule (cp_parser
 {
   tree c, t;
 
-  if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"))
+  if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
     return list;
 
   c = build_omp_clause (location, OMP_CLAUSE_SCHEDULE);
@@ -21717,10 +22128,10 @@ cp_parser_omp_clause_schedule (cp_parser
       else
 	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;
     }
-  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;
 
   check_no_duplicate_clause (list, OMP_CLAUSE_SCHEDULE, "schedule", location);
@@ -22030,7 +22441,7 @@ cp_parser_omp_critical (cp_parser *parse
       name = cp_parser_identifier (parser);
 
       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,
 					       /*or_comma=*/false,
 					       /*consume_paren=*/true);
@@ -22228,7 +22639,7 @@ cp_parser_omp_for_loop (cp_parser *parse
 	}
       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;
 
       init = decl = real_decl = NULL;
@@ -22288,7 +22699,7 @@ cp_parser_omp_for_loop (cp_parser *parse
 			       "OpenMP %<for%> loop");
 		      else
 			/* Trigger an error.  */
-			cp_parser_require (parser, CPP_EQ, "%<=%>");
+			cp_parser_require (parser, CPP_EQ, RT_EQ);
 
 		      init = error_mark_node;
 		      cp_parser_skip_to_end_of_statement (parser);
@@ -22363,7 +22774,7 @@ cp_parser_omp_for_loop (cp_parser *parse
 		  tree rhs;
 
 		  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);
 		  finish_expr_stmt (build_x_modify_expr (decl, NOP_EXPR,
 							 rhs,
@@ -22384,7 +22795,7 @@ cp_parser_omp_for_loop (cp_parser *parse
 		}
 	    }
 	}
-      cp_parser_require (parser, CPP_SEMICOLON, "%<;%>");
+      cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
       if (this_pre_body)
 	{
 	  this_pre_body = pop_stmt_list (this_pre_body);
@@ -22471,7 +22882,7 @@ cp_parser_omp_for_loop (cp_parser *parse
       cond = NULL;
       if (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON))
 	cond = cp_parser_omp_for_cond (parser, decl);
-      cp_parser_require (parser, CPP_SEMICOLON, "%<;%>");
+      cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
 
       incr = NULL;
       if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN))
@@ -22486,7 +22897,7 @@ cp_parser_omp_for_loop (cp_parser *parse
 	    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,
 					       /*or_comma=*/false,
 					       /*consume_paren=*/true);
@@ -22657,7 +23068,7 @@ cp_parser_omp_sections_scope (cp_parser 
   bool error_suppress = false;
   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;
 
   stmt = push_stmt_list ();
@@ -22712,7 +23123,7 @@ cp_parser_omp_sections_scope (cp_parser 
       substmt = build1 (OMP_SECTION, void_type_node, 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);
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]