re PR c++/91024 (-Wimplicit-fallthrough is confused by likely/unlikely attributes)
authorJakub Jelinek <jakub@redhat.com>
Thu, 27 Jun 2019 21:25:56 +0000 (23:25 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 27 Jun 2019 21:25:56 +0000 (23:25 +0200)
PR c++/91024
* gimplify.c (collect_fallthrough_labels): Ignore GIMPLE_PREDICT
statements.

* g++.dg/warn/Wimplicit-fallthrough-4.C: New test.

From-SVN: r272764

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

index 0c939090d618d4f6aab5413609bd6de77091018c..eab9ab9a8591eb0720acb392f4d5a1699f6d26e7 100644 (file)
@@ -1,5 +1,9 @@
 2019-06-27  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/91024
+       * gimplify.c (collect_fallthrough_labels): Ignore GIMPLE_PREDICT
+       statements.
+
        PR tree-optimization/91010
        * tree-vect-stmts.c (scan_operand_equal_p): If offset1 == offset2,
        return true.  Otherwise, don't call operand_equal_p if offset1 or
index 0b25e7100cde48795a7d68f52064b541c1084984..5c51f504368923be7f9ad10acb7bd02ee4f1dd74 100644 (file)
@@ -2120,6 +2120,8 @@ collect_fallthrough_labels (gimple_stmt_iterator *gsi_p,
        }
       else if (gimple_call_internal_p (gsi_stmt (*gsi_p), IFN_ASAN_MARK))
        ;
+      else if (gimple_code (gsi_stmt (*gsi_p)) == GIMPLE_PREDICT)
+       ;
       else if (!is_gimple_debug (gsi_stmt (*gsi_p)))
        prev = gsi_stmt (*gsi_p);
       gsi_next (gsi_p);
index 0a3ea3765073024c9caaad8b548636e544eb8066..ed07047a984925444eb915cad5f624b47b613257 100644 (file)
@@ -1,5 +1,8 @@
 2019-06-27  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/91024
+       * g++.dg/warn/Wimplicit-fallthrough-4.C: New test.
+
        PR tree-optimization/91010
        * g++.dg/vect/simd-10.cc: New test.
 
diff --git a/gcc/testsuite/g++.dg/warn/Wimplicit-fallthrough-4.C b/gcc/testsuite/g++.dg/warn/Wimplicit-fallthrough-4.C
new file mode 100644 (file)
index 0000000..993e695
--- /dev/null
@@ -0,0 +1,22 @@
+// PR c++/91024
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wimplicit-fallthrough" }
+
+int
+foo (char c)
+{
+  int result = 0;
+
+  switch (c)
+    {
+    case 'O':
+    case 'K':
+      return result;
+    [[unlikely]] case 'X':     // { dg-bogus "this statement may fall through" }
+    case 'x':                  // { dg-bogus "here" }
+      return result;
+    default:
+      break;
+    }
+  return result;
+}