aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2016-10-07 11:45:50 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2016-10-07 11:45:50 +0000
commitd4bd46463c63cf0304a71563f1b68f271f3cb230 (patch)
treec8e35580b4975ab62a613e94a7e9c260c987fb90
parent7a18d752e7061c81f83f97969ecf5cd46379d51e (diff)
downloadgcc-d4bd46463c63cf0304a71563f1b68f271f3cb230.zip
gcc-d4bd46463c63cf0304a71563f1b68f271f3cb230.tar.gz
gcc-d4bd46463c63cf0304a71563f1b68f271f3cb230.tar.bz2
re PR c++/77803 (Bogus implicit-fallthrough warning)
PR c++/77803 * gimplify.c (last_stmt_in_scope): Add check for FALLTHROUGH (). * g++.dg/warn/Wimplicit-fallthrough-1.C: New test. From-SVN: r240861
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/gimplify.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/warn/Wimplicit-fallthrough-1.C33
4 files changed, 45 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 15315eb..ece1252 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2016-10-07 Marek Polacek <polacek@redhat.com>
+
+ PR c++/77803
+ * gimplify.c (last_stmt_in_scope): Add check for FALLTHROUGH ().
+
2016-10-07 Richard Biener <rguenther@suse.de>
* bitmap.h: Document constraints on bitmap modification while
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 66bb8be..a60d947 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1687,6 +1687,8 @@ last_stmt_in_scope (gimple *stmt)
stmt = gimple_seq_last_stmt (gimple_try_eval (try_stmt));
gimple *last_eval = last_stmt_in_scope (stmt);
if (gimple_stmt_may_fallthru (last_eval)
+ && (last_eval == NULL
+ || !gimple_call_internal_p (last_eval, IFN_FALLTHROUGH))
&& gimple_try_kind (try_stmt) == GIMPLE_TRY_FINALLY)
{
stmt = gimple_seq_last_stmt (gimple_try_cleanup (try_stmt));
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5721cda..49ad223 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-10-07 Marek Polacek <polacek@redhat.com>
+
+ PR c++/77803
+ * g++.dg/warn/Wimplicit-fallthrough-1.C: New test.
+
2016-10-07 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/77664
diff --git a/gcc/testsuite/g++.dg/warn/Wimplicit-fallthrough-1.C b/gcc/testsuite/g++.dg/warn/Wimplicit-fallthrough-1.C
new file mode 100644
index 0000000..053ed68
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wimplicit-fallthrough-1.C
@@ -0,0 +1,33 @@
+// PR c++/77803
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wimplicit-fallthrough" }
+
+struct A {};
+int a;
+
+void
+fn1 ()
+{
+ switch (0) {
+ case 0:
+ {
+ A b;
+ [[fallthrough]];
+ }
+ default:
+ a = 0;
+ }
+}
+
+void
+fn2 ()
+{
+ switch (0) {
+ case 0:
+ {
+ A b; // { dg-warning "statement may fall through" }
+ }
+ default:
+ a = 0;
+ }
+}