From: Jakub Jelinek Date: Fri, 28 Jun 2019 22:57:16 +0000 (+0200) Subject: backport: re PR c++/91024 (-Wimplicit-fallthrough is confused by likely/unlikely... X-Git-Tag: releases/gcc-9.2.0~189 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a4024807aacfeac22da3ec21620ece3a029bfbc;p=thirdparty%2Fgcc.git backport: re PR c++/91024 (-Wimplicit-fallthrough is confused by likely/unlikely attributes) Backported from mainline 2019-06-27 Jakub Jelinek PR c++/91024 * gimplify.c (collect_fallthrough_labels): Ignore GIMPLE_PREDICT statements. * g++.dg/warn/Wimplicit-fallthrough-4.C: New test. From-SVN: r272804 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c5a7c2eb316f..025aa5b5bf0c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,12 @@ 2019-06-29 Jakub Jelinek Backported from mainline + 2019-06-27 Jakub Jelinek + + PR c++/91024 + * gimplify.c (collect_fallthrough_labels): Ignore GIMPLE_PREDICT + statements. + 2019-06-26 Jakub Jelinek PR target/90991 diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 72f1cc38ff7e..362877cbae64 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b65008ba889e..1a546d3b7c1d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2019-06-29 Jakub Jelinek Backported from mainline + 2019-06-27 Jakub Jelinek + + PR c++/91024 + * g++.dg/warn/Wimplicit-fallthrough-4.C: New test. + 2019-06-26 Jakub Jelinek 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 index 000000000000..993e695fa168 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wimplicit-fallthrough-4.C @@ -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; +}