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
This commit is contained in:
Marek Polacek 2016-09-26 15:53:28 +00:00 committed by Marek Polacek
parent 8e4284d0b2
commit c6147dc433
6 changed files with 27 additions and 3 deletions

View file

@ -1,3 +1,8 @@
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

View file

@ -1,3 +1,7 @@
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

View file

@ -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;

View file

@ -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

View file

@ -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.

View file

@ -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