Commit 8b4efb4e by Volker Reichelt Committed by Volker Reichelt

parser.c (cp_parser_check_type_definition): Print error string directly rather than using "%s".

	* parser.c (cp_parser_check_type_definition): Print error string
	directly rather than using "%s".
	(cp_parser_postfix_expression): Fix quotation.
	(cp_parser_decltype): Likewise.
	(cp_parser_sizeof_operand): Fix quotation. Simplify.

From-SVN: r134129
parent 2a97bf74
2008-04-09 Volker Reichelt <v.reichelt@netcologne.de> 2008-04-09 Volker Reichelt <v.reichelt@netcologne.de>
* parser.c (cp_parser_check_type_definition): Print error string
directly rather than using "%s".
(cp_parser_postfix_expression): Fix quotation.
(cp_parser_decltype): Likewise.
(cp_parser_sizeof_operand): Fix quotation. Simplify.
* parser.c (cp_parser_non_integral_constant_expression): Build error * parser.c (cp_parser_non_integral_constant_expression): Build error
message with CONCAT rather than using "%s". message with CONCAT rather than using "%s".
(cp_parser_primary_expression): Fix quotation. (cp_parser_primary_expression): Fix quotation.
......
...@@ -2183,9 +2183,9 @@ cp_parser_check_type_definition (cp_parser* parser) ...@@ -2183,9 +2183,9 @@ cp_parser_check_type_definition (cp_parser* parser)
/* If types are forbidden here, issue a message. */ /* If types are forbidden here, issue a message. */
if (parser->type_definition_forbidden_message) if (parser->type_definition_forbidden_message)
{ {
/* Use `%s' to print the string in case there are any escape /* Don't use `%s' to print the string, because quotations (`%<', `%>')
characters in the message. */ in the message need to be interpreted. */
error ("%s", parser->type_definition_forbidden_message); error (parser->type_definition_forbidden_message);
return false; return false;
} }
return true; return true;
...@@ -4372,7 +4372,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, ...@@ -4372,7 +4372,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
/* Types cannot be defined in a `typeid' expression. */ /* Types cannot be defined in a `typeid' expression. */
saved_message = parser->type_definition_forbidden_message; saved_message = parser->type_definition_forbidden_message;
parser->type_definition_forbidden_message parser->type_definition_forbidden_message
= "types may not be defined in a `typeid\' expression"; = "types may not be defined in a %<typeid%> expression";
/* We can't be sure yet whether we're looking at a type-id or an /* We can't be sure yet whether we're looking at a type-id or an
expression. */ expression. */
cp_parser_parse_tentatively (parser); cp_parser_parse_tentatively (parser);
...@@ -8515,7 +8515,7 @@ cp_parser_decltype (cp_parser *parser) ...@@ -8515,7 +8515,7 @@ cp_parser_decltype (cp_parser *parser)
/* And create the new one. */ /* And create the new one. */
parser->type_definition_forbidden_message parser->type_definition_forbidden_message
= "types may not be defined in `decltype' expressions"; = "types may not be defined in %<decltype%> expressions";
/* The restrictions on constant-expressions do not apply inside /* The restrictions on constant-expressions do not apply inside
decltype expressions. */ decltype expressions. */
...@@ -17572,7 +17572,6 @@ cp_parser_late_parsing_default_args (cp_parser *parser, tree fn) ...@@ -17572,7 +17572,6 @@ cp_parser_late_parsing_default_args (cp_parser *parser, tree fn)
static tree static tree
cp_parser_sizeof_operand (cp_parser* parser, enum rid keyword) cp_parser_sizeof_operand (cp_parser* parser, enum rid keyword)
{ {
static const char *format;
tree expr = NULL_TREE; tree expr = NULL_TREE;
const char *saved_message; const char *saved_message;
char *tmp; char *tmp;
...@@ -17580,19 +17579,14 @@ cp_parser_sizeof_operand (cp_parser* parser, enum rid keyword) ...@@ -17580,19 +17579,14 @@ cp_parser_sizeof_operand (cp_parser* parser, enum rid keyword)
bool saved_non_integral_constant_expression_p; bool saved_non_integral_constant_expression_p;
bool pack_expansion_p = false; bool pack_expansion_p = false;
/* Initialize FORMAT the first time we get here. */
if (!format)
format = "types may not be defined in '%s' expressions";
/* Types cannot be defined in a `sizeof' expression. Save away the /* Types cannot be defined in a `sizeof' expression. Save away the
old message. */ old message. */
saved_message = parser->type_definition_forbidden_message; saved_message = parser->type_definition_forbidden_message;
/* And create the new one. */ /* And create the new one. */
parser->type_definition_forbidden_message = tmp tmp = concat ("types may not be defined in %<",
= XNEWVEC (char, strlen (format) IDENTIFIER_POINTER (ridpointers[keyword]),
+ strlen (IDENTIFIER_POINTER (ridpointers[keyword])) "%> expressions", NULL);
+ 1 /* `\0' */); parser->type_definition_forbidden_message = tmp;
sprintf (tmp, format, IDENTIFIER_POINTER (ridpointers[keyword]));
/* The restrictions on constant-expressions do not apply inside /* The restrictions on constant-expressions do not apply inside
sizeof expressions. */ sizeof expressions. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment