aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2021-05-13 13:59:59 +0200
committerMartin Liska <mliska@suse.cz>2021-05-13 19:30:18 +0200
commit9feb5822b713c6a12cb290ba0406ba2362d4c09c (patch)
treee9966f41bbed4d491665cb890860efae48f16436 /gcc
parentb7b413152ecb9e6a734a45688f3a9df77a686206 (diff)
downloadgcc-9feb5822b713c6a12cb290ba0406ba2362d4c09c.zip
gcc-9feb5822b713c6a12cb290ba0406ba2362d4c09c.tar.gz
gcc-9feb5822b713c6a12cb290ba0406ba2362d4c09c.tar.bz2
attributes: target_clone expects a string argument
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-family/c-attribs.c7
-rw-r--r--gcc/testsuite/gcc.target/i386/pr100504.c7
2 files changed, 13 insertions, 1 deletions
diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index c1f652d..f54388e 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -5288,7 +5288,12 @@ handle_target_clones_attribute (tree *node, tree name, tree ARG_UNUSED (args),
/* Ensure we have a function type. */
if (TREE_CODE (*node) == FUNCTION_DECL)
{
- if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node)))
+ if (TREE_CODE (TREE_VALUE (args)) != STRING_CST)
+ {
+ error ("%qE attribute argument not a string constant", name);
+ *no_add_attrs = true;
+ }
+ else if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node)))
{
warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
"with %qs attribute", name, "always_inline");
diff --git a/gcc/testsuite/gcc.target/i386/pr100504.c b/gcc/testsuite/gcc.target/i386/pr100504.c
new file mode 100644
index 0000000..2910dfb
--- /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" } */
+}