aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/c-family/ChangeLog4
-rw-r--r--gcc/c-family/c-lex.c3
-rw-r--r--gcc/system.h8
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C6
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