On 1/18/22 23:00, Joseph Myers wrote:
On Tue, 18 Jan 2022, Martin Liška wrote:

@@ -3309,8 +3309,8 @@ riscv_handle_type_attribute (tree *node
ATTRIBUTE_UNUSED, tree name, tree args,
              && strcmp (string, "machine"))
            {
              warning (OPT_Wattributes,
-                      "argument to %qE attribute is not \"user\",
\"supervisor\", or \"machine\"",
-                      name);
+                      "argument to %qE attribute is not %<user%>,
%<supervisor%>, "
+                      "or %<machine%>", name);
              *no_add_attrs = true;

My reading is that the attribute arguments here are string constants, not
identifiers - that is, the ASCII double quotes are correct in the
diagnostic output, because those double quotes are part of the literal
text that's supposed to appear in the program.  (Maybe %<\"user\"%> is the
right way of marking it up to indicate that the double quotes are part of
the literal program text, not English-level quoting.)

Makes sense, I' going to install the following patch.

Martin
From fdf31ae25f66cd486e655d7ebda36826025b9d0e Mon Sep 17 00:00:00 2001
From: Martin Liska <mli...@suse.cz>
Date: Wed, 19 Jan 2022 10:32:13 +0100
Subject: [PATCH] Update on riscv -Wformat-diag string.

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_handle_type_attribute):
	Update one -Wformat-diag string in warning message.
---
 gcc/config/riscv/riscv.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 8314864d5e7..6885b4bbad2 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -3309,8 +3309,8 @@ riscv_handle_type_attribute (tree *node ATTRIBUTE_UNUSED, tree name, tree args,
 	      && strcmp (string, "machine"))
 	    {
 	      warning (OPT_Wattributes,
-		       "argument to %qE attribute is not %<user%>, %<supervisor%>, "
-		       "or %<machine%>", name);
+		       "argument to %qE attribute is not %<\"user\"%>, %<\"supervisor\"%>, "
+		       "or %<\"machine\"%>", name);
 	      *no_add_attrs = true;
 	    }
 	}
-- 
2.34.1

Reply via email to