]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/91024 (-Wimplicit-fallthrough is confused by likely/unlikely...
authorJakub Jelinek <jakub@redhat.com>
Fri, 28 Jun 2019 22:57:16 +0000 (00:57 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 28 Jun 2019 22:57:16 +0000 (00:57 +0200)
Backported from mainline
2019-06-27  Jakub Jelinek  <jakub@redhat.com>

PR c++/91024
* gimplify.c (collect_fallthrough_labels): Ignore GIMPLE_PREDICT
statements.

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

From-SVN: r272804

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

index c5a7c2eb316fd21eaf20e3554101316fa54abad7..025aa5b5bf0cc64570e6b2263385737bfa5117f3 100644 (file)
@@ -1,6 +1,12 @@
 2019-06-29  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-06-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/91024
+       * gimplify.c (collect_fallthrough_labels): Ignore GIMPLE_PREDICT
+       statements.
+
        2019-06-26  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/90991
index 72f1cc38ff7ea21bf1607569a06d993e570291a8..362877cbae64a4676ab6c8d0bcf46c5f7bc1f865 100644 (file)
@@ -2081,6 +2081,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 b65008ba889e20f0f522189805b9eb035eb7ee32..1a546d3b7c1d99758f1ab1dc38d24b13825c8094 100644 (file)
@@ -1,6 +1,11 @@
 2019-06-29  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-06-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/91024
+       * g++.dg/warn/Wimplicit-fallthrough-4.C: New test.
+
        2019-06-26  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/90991
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;
+}