diff options
author | Martin Liska <mliska@suse.cz> | 2022-12-27 16:31:57 +0100 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2023-01-09 11:49:31 +0100 |
commit | befd29d5fe15c09638f73eeeb1f8a9e62ce569ee (patch) | |
tree | 854ea2c6ef15d61be70dc049a6143770d781c6c7 | |
parent | cb93c5f8008b95743b741d6f1842f9be50c6985c (diff) | |
download | gcc-befd29d5fe15c09638f73eeeb1f8a9e62ce569ee.zip gcc-befd29d5fe15c09638f73eeeb1f8a9e62ce569ee.tar.gz gcc-befd29d5fe15c09638f73eeeb1f8a9e62ce569ee.tar.bz2 |
c: check if target_clone attrs are all string
PR c/107993
gcc/c-family/ChangeLog:
* c-attribs.cc (handle_target_clones_attribute): Check for
string constant for all target_clone attribute values.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr107993.c: New test.
-rw-r--r-- | gcc/c-family/c-attribs.cc | 14 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr107993.c | 9 |
2 files changed, 19 insertions, 4 deletions
diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc index b36dd97..33d84cb 100644 --- a/gcc/c-family/c-attribs.cc +++ b/gcc/c-family/c-attribs.cc @@ -5574,12 +5574,18 @@ 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 (TREE_CODE (TREE_VALUE (args)) != STRING_CST) + for (tree t = args; t != NULL_TREE; t = TREE_CHAIN (t)) { - error ("%qE attribute argument not a string constant", name); - *no_add_attrs = true; + tree value = TREE_VALUE (t); + if (TREE_CODE (value) != STRING_CST) + { + error ("%qE attribute argument not a string constant", name); + *no_add_attrs = true; + return NULL_TREE; + } } - else if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node))) + + 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/pr107993.c b/gcc/testsuite/gcc.target/i386/pr107993.c new file mode 100644 index 0000000..b0b84a6 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr107993.c @@ -0,0 +1,9 @@ +/* PR c/107993 */ +/* { dg-do compile } */ + +typedef union { int x; } u; +__attribute__((target_clones("arch=alderlake",!"default"))) +int f (u *x) +{ /* { dg-error ".target_clones. attribute argument not a string constant" } */ + return 0; +} |