diff options
author | Marek Polacek <polacek@redhat.com> | 2016-09-26 15:53:28 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2016-09-26 15:53:28 +0000 |
commit | c6147dc433015793d92602811e585b83c9018bc2 (patch) | |
tree | 0ae29fdb0d04e4498b59ab6240031213610fb6e8 | |
parent | 8e4284d0b24bd3c745c054054d673ed306d30467 (diff) | |
download | gcc-c6147dc433015793d92602811e585b83c9018bc2.zip gcc-c6147dc433015793d92602811e585b83c9018bc2.tar.gz gcc-c6147dc433015793d92602811e585b83c9018bc2.tar.bz2 |
c-lex.c (c_common_has_attribute): Handle attribute fallthrough.
* c-lex.c (c_common_has_attribute): Handle attribute fallthrough.
* system.h: Use __has_attribute to check whether the fallthrough
attribute is supported.
* g++.dg/cpp1z/feat-cxx1z.C: Test attribute fallthrough.
From-SVN: r240499
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-family/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/c-family/c-lex.c | 3 | ||||
-rw-r--r-- | gcc/system.h | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C | 6 |
6 files changed, 27 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9427b50..f7122e2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2016-09-26 Marek Polacek <polacek@redhat.com> + * system.h: Use __has_attribute to check whether the fallthrough + attribute is supported. + +2016-09-26 Marek Polacek <polacek@redhat.com> + * ipa-inline-analysis.c (find_foldable_builtin_expect): Use gimple_call_internal_p. * ipa-split.c (find_return_bb): Likewise. diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index cd3eeab..6eec895 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,5 +1,9 @@ 2016-09-26 Marek Polacek <polacek@redhat.com> + * c-lex.c (c_common_has_attribute): Handle attribute fallthrough. + +2016-09-26 Marek Polacek <polacek@redhat.com> + PR c/7652 * c-common.c (c_common_attribute_table): Add fallthrough attribute. (handle_fallthrough_attribute): New function. diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c index 829c18b..5c6496e 100644 --- a/gcc/c-family/c-lex.c +++ b/gcc/c-family/c-lex.c @@ -350,7 +350,8 @@ c_common_has_attribute (cpp_reader *pfile) else if (is_attribute_p ("deprecated", attr_name)) result = 201309; else if (is_attribute_p ("maybe_unused", attr_name) - || is_attribute_p ("nodiscard", attr_name)) + || is_attribute_p ("nodiscard", attr_name) + || is_attribute_p ("fallthrough", attr_name)) result = 201603; if (result) attr_name = NULL_TREE; diff --git a/gcc/system.h b/gcc/system.h index 8ca71cf..0952e4f 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -746,8 +746,12 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN; #define gcc_unreachable() (fancy_abort (__FILE__, __LINE__, __FUNCTION__)) #endif -#if GCC_VERSION >= 7000 -# define gcc_fallthrough() __attribute__((fallthrough)) +#if GCC_VERSION >= 7000 && defined(__has_attribute) +# if __has_attribute(fallthrough) +# define gcc_fallthrough() __attribute__((fallthrough)) +# else +# define gcc_fallthrough() +# endif #else # define gcc_fallthrough() #endif diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f8567e1..0692c01 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2016-09-26 Marek Polacek <polacek@redhat.com> + + * g++.dg/cpp1z/feat-cxx1z.C: Test attribute fallthrough. + 2016-09-26 Martin Liska <mliska@suse.cz> * c-c++-common/ubsan/sanitize-recover-1.c: New test. diff --git a/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C b/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C index 982572e..71c8c7d 100644 --- a/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C +++ b/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C @@ -370,6 +370,12 @@ # error "__has_cpp_attribute(nodiscard) != 201603" # endif +# if ! __has_cpp_attribute(fallthrough) +# error "__has_cpp_attribute(fallthrough)" +# elif __has_cpp_attribute(fallthrough) != 201603 +# error "__has_cpp_attribute(fallthrough) != 201603" +# endif + #else # error "__has_cpp_attribute" #endif |