d: Give consistent error message when attribute argument not a string constant
authorIain Buclaw <ibuclaw@gdcproject.org>
Fri, 24 Jun 2022 13:30:13 +0000 (15:30 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Fri, 24 Jun 2022 18:54:03 +0000 (20:54 +0200)
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
gcc/testsuite/gdc.dg/attr_section1.d
gcc/testsuite/gdc.dg/attr_visibility1.d

index 23bbe39..1dd806f 100644 (file)
@@ -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;
     }
 
index c24634f..759b203 100644 (file)
@@ -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." }
 {
index a7ed406..932e6e6 100644 (file)
@@ -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" }