This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Simplify quoting in diagnostics of C++ frontend
- From: Volker Reichelt <v dot reichelt at netcologne dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 23 Apr 2017 20:53:59 +0200 (CEST)
- Subject: [PATCH] Simplify quoting in diagnostics of C++ frontend
- Authentication-results: sourceware.org; auth=none
Hi,
the following patch simplifies quoting in diagnostics by using
%qD instead of %<%D%> etc.
Bootstrapped and regtested on x86_64-pc-linux-gnu.
Btw, line 14563 in pt.c
error ("enumerator value %E is outside the range of underlying "
contains an unquoted %E. Shouldn't that be replaced with %qE?
OK for trunk?
Regards,
Volker
2017-04-23 Volker Reichelt <v.reichelt@netcologne.de>
* decl.c (grokdeclarator): Use %qT instead of %<%T%> in diagnostics.
(start_enum): Likewise.
(build_enumerator): Likewise.
* parser.c (cp_parser_mem_initializer_list): Use %qD instead of
%<%D%> in diagnostics.
(cp_parser_elaborated_type_specifier): Likewise.
* pt.c (make_pack_expansion): Use %qT and %qE instead of
%<%T%> and %<%E%> in diagnostics.
(tsubst_pack_expansion): Likewise.
Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c (revision 247067)
+++ gcc/cp/decl.c (working copy)
@@ -11433,9 +11433,9 @@
{
error (funcdef_flag || initialized
? G_("cannot define member function %<%T::%s%> "
- "within %<%T%>")
+ "within %qT")
: G_("cannot declare member function %<%T::%s%> "
- "within %<%T%>"),
+ "within %qT"),
ctype, name, current_class_type);
return error_mark_node;
}
@@ -14150,7 +14150,7 @@
else if (dependent_type_p (underlying_type))
ENUM_UNDERLYING_TYPE (enumtype) = underlying_type;
else
- error ("underlying type %<%T%> of %<%T%> must be an integral type",
+ error ("underlying type %qT of %qT must be an integral type",
underlying_type, enumtype);
}
@@ -14561,7 +14561,7 @@
{
if (!int_fits_type_p (value, ENUM_UNDERLYING_TYPE (enumtype)))
error ("enumerator value %E is outside the range of underlying "
- "type %<%T%>", value, ENUM_UNDERLYING_TYPE (enumtype));
+ "type %qT", value, ENUM_UNDERLYING_TYPE (enumtype));
/* Convert the value to the appropriate type. */
value = fold_convert (ENUM_UNDERLYING_TYPE (enumtype), value);
Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c (revision 247067)
+++ gcc/cp/parser.c (working copy)
@@ -14073,7 +14073,7 @@
&& !TYPE_P (TREE_PURPOSE (mem_initializer)))
{
error_at (token->location,
- "cannot expand initializer for member %<%D%>",
+ "cannot expand initializer for member %qD",
TREE_PURPOSE (mem_initializer));
mem_initializer = error_mark_node;
}
@@ -17263,7 +17263,7 @@
|| cp_lexer_next_token_is_keyword (parser->lexer, RID_STRUCT))
{
pedwarn (input_location, 0, "elaborated-type-specifier "
- "for a scoped enum must not use the %<%D%> keyword",
+ "for a scoped enum must not use the %qD keyword",
cp_lexer_peek_token (parser->lexer)->u.value);
/* Consume the `struct' or `class' and parse it anyway. */
cp_lexer_consume_token (parser->lexer);
Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c (revision 247067)
+++ gcc/cp/pt.c (working copy)
@@ -3701,7 +3701,7 @@
if (parameter_packs == NULL_TREE)
{
- error ("base initializer expansion %<%T%> contains no parameter packs", arg);
+ error ("base initializer expansion %qT contains no parameter packs", arg);
delete ppd.visited;
return error_mark_node;
}
@@ -3765,9 +3765,9 @@
if (parameter_packs == NULL_TREE)
{
if (TYPE_P (arg))
- error ("expansion pattern %<%T%> contains no argument packs", arg);
+ error ("expansion pattern %qT contains no argument packs", arg);
else
- error ("expansion pattern %<%E%> contains no argument packs", arg);
+ error ("expansion pattern %qE contains no argument packs", arg);
return error_mark_node;
}
PACK_EXPANSION_PARAMETER_PACKS (result) = parameter_packs;
@@ -11409,12 +11409,10 @@
if (!(complain & tf_error))
/* Fail quietly. */;
else if (TREE_CODE (t) == TYPE_PACK_EXPANSION)
- error ("mismatched argument pack lengths while expanding "
- "%<%T%>",
+ error ("mismatched argument pack lengths while expanding %qT",
pattern);
else
- error ("mismatched argument pack lengths while expanding "
- "%<%E%>",
+ error ("mismatched argument pack lengths while expanding %qE",
pattern);
return error_mark_node;
}
===================================================================