diff options
author | Kyrylo Tkachov <kyrylo.tkachov@arm.com> | 2016-01-15 17:27:41 +0000 |
---|---|---|
committer | Kyrylo Tkachov <ktkachov@gcc.gnu.org> | 2016-01-15 17:27:41 +0000 |
commit | 16d129928bbb3cf6a59695a8ce95353a416080b8 (patch) | |
tree | 16dc60fa879d7e7d52adb8f54a453ebbd3776ee7 | |
parent | ad45ac43e4518715f4a56a7cf92f9d73aea6ed6c (diff) | |
download | gcc-16d129928bbb3cf6a59695a8ce95353a416080b8.zip gcc-16d129928bbb3cf6a59695a8ce95353a416080b8.tar.gz gcc-16d129928bbb3cf6a59695a8ce95353a416080b8.tar.bz2 |
[AArch64] Properly reject invalid attribute strings
* config/aarch64/aarch64.c (aarch64_process_one_target_attr): Return
false when argument string is not found in the attributes table
at all.
* gcc.target/aarch64/target_attr_17.c: New test.
From-SVN: r232440
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/config/aarch64/aarch64.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/aarch64/target_attr_17.c | 8 |
4 files changed, 24 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 609b135..371ec82 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-01-15 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + * config/aarch64/aarch64.c (aarch64_process_one_target_attr): Return + false when argument string is not found in the attributes table + at all. + 2016-01-15 David Edelsohn <dje.gcc@gmail.com> PR target/68609 diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 6853b0a..cb57fe2 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -8898,6 +8898,7 @@ aarch64_process_one_target_attr (char *arg_str, const char* pragma_or_attr) arg++; } const struct aarch64_attribute_info *p_attr; + bool found = false; for (p_attr = aarch64_attributes; p_attr->name; p_attr++) { /* If the names don't match up, or the user has given an argument @@ -8906,6 +8907,7 @@ aarch64_process_one_target_attr (char *arg_str, const char* pragma_or_attr) if (strcmp (str_to_check, p_attr->name) != 0) continue; + found = true; bool attr_need_arg_p = p_attr->attr_type == aarch64_attr_custom || p_attr->attr_type == aarch64_attr_enum; @@ -8985,7 +8987,10 @@ aarch64_process_one_target_attr (char *arg_str, const char* pragma_or_attr) } } - return true; + /* If we reached here we either have found an attribute and validated + it or didn't match any. If we matched an attribute but its arguments + were malformed we will have returned false already. */ + return found; } /* Count how many times the character C appears in diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bc6105d..2cc8508 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2016-01-15 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + * gcc.target/aarch64/target_attr_17.c: New test. + 2016-01-15 Richard Biener <rguenther@suse.de> PR tree-optimization/66856 diff --git a/gcc/testsuite/gcc.target/aarch64/target_attr_17.c b/gcc/testsuite/gcc.target/aarch64/target_attr_17.c new file mode 100644 index 0000000..483cc6d --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/target_attr_17.c @@ -0,0 +1,8 @@ +__attribute__((target("invalid-attr-string"))) +int +foo (int a) +{ + return a + 5; +} + +/* { dg-error "target attribute.*is invalid" "" { target *-*-* } 0 } */
\ No newline at end of file |