re PR c++/77803 (Bogus implicit-fallthrough warning)
authorMarek Polacek <polacek@redhat.com>
Fri, 7 Oct 2016 11:45:50 +0000 (11:45 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 7 Oct 2016 11:45:50 +0000 (11:45 +0000)
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

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wimplicit-fallthrough-1.C [new file with mode: 0644]

index 15315eb39eb6fadecd0c4a53b10cd0a8ca5c1393..ece1252c5ca9381bff7b4e34a634b3de1d9da727 100644 (file)
@@ -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
index 66bb8be264b45bab8477233bc7b95f83eeb75a08..a60d9471c68a9e0cb8b5bfa5890a6cb97622efbe 100644 (file)
@@ -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));
index 5721cda85eb093359ea66894f4ef3e79f51da270..49ad223b5f1646a544c29eb70229a459b4e789a7 100644 (file)
@@ -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 (file)
index 0000000..053ed68
--- /dev/null
@@ -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;
+  }
+}