public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Simplify quoting in diagnostics of C++ frontend
@ 2017-04-24  6:25 Volker Reichelt
  2017-04-24 16:04 ` Nathan Sidwell
  0 siblings, 1 reply; 2+ messages in thread
From: Volker Reichelt @ 2017-04-24  6:25 UTC (permalink / raw)
  To: gcc-patches

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;
             }
===================================================================

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Simplify quoting in diagnostics of C++ frontend
  2017-04-24  6:25 [PATCH] Simplify quoting in diagnostics of C++ frontend Volker Reichelt
@ 2017-04-24 16:04 ` Nathan Sidwell
  0 siblings, 0 replies; 2+ messages in thread
From: Nathan Sidwell @ 2017-04-24 16:04 UTC (permalink / raw)
  To: Volker Reichelt, gcc-patches

On 04/23/2017 02:53 PM, Volker Reichelt wrote:
> 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?

yes, please add that change too.

> OK for trunk?

ok


-- 
Nathan Sidwell

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-24 15:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-24  6:25 [PATCH] Simplify quoting in diagnostics of C++ frontend Volker Reichelt
2017-04-24 16:04 ` Nathan Sidwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).