diff mbox series

[committed] d: Give consistent error message when attribute argument not a string constant

Message ID 20220624185913.3907944-1-ibuclaw@gdcproject.org
State New
Headers show
Series [committed] d: Give consistent error message when attribute argument not a string constant | expand

Commit Message

Iain Buclaw June 24, 2022, 6:59 p.m. UTC
Hi,

This patch adjusts all the "not a string" errors in the D attribute
handlers to use the same format string for consistency.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32/-mx32, and
committed to mainline.

Regards,
Iain.

---
gcc/d/ChangeLog:

	* d-attribs.cc (d_handle_section_attribute): Update error message.
	(d_handle_symver_attribute): Likewise.
	(d_handle_no_sanitize_attribute): Likewise.
	(d_handle_visibility_attribute): Likewise.

gcc/testsuite/ChangeLog:

	* gdc.dg/attr_section1.d: Update dg-error.
	* gdc.dg/attr_visibility1.d: Likewise.
---
 gcc/d/d-attribs.cc                      | 11 ++++++-----
 gcc/testsuite/gdc.dg/attr_section1.d    |  2 +-
 gcc/testsuite/gdc.dg/attr_visibility1.d |  2 +-
 3 files changed, 8 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/gcc/d/d-attribs.cc b/gcc/d/d-attribs.cc
index 23bbe3946fb..b7b014f72be 100644
--- a/gcc/d/d-attribs.cc
+++ b/gcc/d/d-attribs.cc
@@ -1015,7 +1015,7 @@  d_handle_section_attribute (tree *node, tree name, tree args, int flags,
 
   if (TREE_CODE (TREE_VALUE (args)) != STRING_CST)
     {
-      error ("section attribute argument not a string constant");
+      error ("%qE attribute argument not a string constant", name);
       *no_add_attrs = true;
       return NULL_TREE;
     }
@@ -1065,7 +1065,8 @@  d_handle_section_attribute (tree *node, tree name, tree args, int flags,
    struct attribute_spec.handler.  */
 
 static tree
-d_handle_symver_attribute (tree *node, tree, tree args, int, bool *no_add_attrs)
+d_handle_symver_attribute (tree *node, tree name, tree args, int,
+			   bool *no_add_attrs)
 {
   if (TREE_CODE (*node) != FUNCTION_DECL && TREE_CODE (*node) != VAR_DECL)
     {
@@ -1088,7 +1089,7 @@  d_handle_symver_attribute (tree *node, tree, tree args, int, bool *no_add_attrs)
       tree symver = TREE_VALUE (args);
       if (TREE_CODE (symver) != STRING_CST)
 	{
-	  error ("%<symver%> attribute argument not a string constant");
+    	  error ("%qE attribute argument not a string constant", name);
 	  *no_add_attrs = true;
 	  return NULL_TREE;
 	}
@@ -1391,7 +1392,7 @@  d_handle_no_sanitize_attribute (tree *node, tree name, tree args, int,
       tree id = TREE_VALUE (args);
       if (TREE_CODE (id) != STRING_CST)
 	{
-	  error ("%qE argument not a string", name);
+	  error ("%qE attribute argument not a string constant", name);
 	  return NULL_TREE;
 	}
 
@@ -1525,7 +1526,7 @@  d_handle_visibility_attribute (tree *node, tree name, tree args,
   tree id = TREE_VALUE (args);
   if (TREE_CODE (id) != STRING_CST)
     {
-      error ("visibility argument not a string");
+      error ("%qE attribute argument not a string constant", name);
       return NULL_TREE;
     }
 
diff --git a/gcc/testsuite/gdc.dg/attr_section1.d b/gcc/testsuite/gdc.dg/attr_section1.d
index c24634f7fd5..759b203dd44 100644
--- a/gcc/testsuite/gdc.dg/attr_section1.d
+++ b/gcc/testsuite/gdc.dg/attr_section1.d
@@ -7,7 +7,7 @@  import gcc.attributes;
 struct S {} // { dg-warning ".section. attribute does not apply to types" }
 
 @attribute("section", 123)
-int f1(); // { dg-error "section attribute argument not a string constant" }
+int f1(); // { dg-error ".section. attribute argument not a string constant" }
 
 int f2(@section("param") int a) // { dg-error "section attribute not allowed for .a." }
 {
diff --git a/gcc/testsuite/gdc.dg/attr_visibility1.d b/gcc/testsuite/gdc.dg/attr_visibility1.d
index a7ed4065605..932e6e6051f 100644
--- a/gcc/testsuite/gdc.dg/attr_visibility1.d
+++ b/gcc/testsuite/gdc.dg/attr_visibility1.d
@@ -13,7 +13,7 @@  void nested()
 }
 
 @attribute("visibility", 123)
-int not_a_string(); // { dg-error "visibility argument not a string" }
+int not_a_string(); // { dg-error ".visibility. attribute argument not a string constant" }
 
 @attribute("visibility", "invalid argument")
 int invalid_argument(); // { dg-error ".visibility. argument must be one of" }