Hello.

The change is about error handling.

Ready to be installed?
Thanks,
Martin

        PR middle-end/100504

gcc/c-family/ChangeLog:

        * c-attribs.c (handle_target_clones_attribute): Expect a string
        argument to target_clone argument.

gcc/testsuite/ChangeLog:

        * gcc.target/i386/pr100504.c: New test.
---
 gcc/c-family/c-attribs.c                 | 6 ++++++
 gcc/testsuite/gcc.target/i386/pr100504.c | 7 +++++++
 2 files changed, 13 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr100504.c

diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index c1f652d1dc9..9905ee56947 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -5300,6 +5300,12 @@ handle_target_clones_attribute (tree *node, tree name, 
tree ARG_UNUSED (args),
                   "with %qs attribute", name, "target");
          *no_add_attrs = true;
        }
+      else if (TREE_CODE (TREE_VALUE (args)) != STRING_CST)
+       {
+         error ("%qE attribute argument not a string constant", name);
+         *no_add_attrs = true;
+       }
+
       else
       /* Do not inline functions with multiple clone targets.  */
        DECL_UNINLINABLE (*node) = 1;
diff --git a/gcc/testsuite/gcc.target/i386/pr100504.c 
b/gcc/testsuite/gcc.target/i386/pr100504.c
new file mode 100644
index 00000000000..2910dfb948b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr100504.c
@@ -0,0 +1,7 @@
+/* PR middle-end/100504 */
+/* { dg-do compile } */
+
+__attribute__((target_clones(0)))
+foo()
+{ /* { dg-error ".target_clones. attribute argument not a string constant" } */
+}
--
2.31.1

Reply via email to