mirror of git://gcc.gnu.org/git/gcc.git
gimplify.c (should_warn_for_implicit_fallthrough): Check for FALLTHROUGH_LABEL_P here...
* gimplify.c (should_warn_for_implicit_fallthrough): Check for FALLTHROUGH_LABEL_P here... (warn_implicit_fallthrough_r): ...not here. * c-c++-common/Wimplicit-fallthrough-22.c: New test. From-SVN: r240864
This commit is contained in:
parent
8a14afd065
commit
a9172bf307
|
|
@ -1,3 +1,9 @@
|
||||||
|
2016-10-07 Marek Polacek <polacek@redhat.com>
|
||||||
|
|
||||||
|
* gimplify.c (should_warn_for_implicit_fallthrough): Check for
|
||||||
|
FALLTHROUGH_LABEL_P here...
|
||||||
|
(warn_implicit_fallthrough_r): ...not here.
|
||||||
|
|
||||||
2016-10-07 Bernd Schmidt <bschmidt@redhat.com>
|
2016-10-07 Bernd Schmidt <bschmidt@redhat.com>
|
||||||
|
|
||||||
PR tree-optimization/77880
|
PR tree-optimization/77880
|
||||||
|
|
|
||||||
|
|
@ -1819,6 +1819,10 @@ should_warn_for_implicit_fallthrough (gimple_stmt_iterator *gsi_p, tree label)
|
||||||
{
|
{
|
||||||
gimple_stmt_iterator gsi = *gsi_p;
|
gimple_stmt_iterator gsi = *gsi_p;
|
||||||
|
|
||||||
|
/* Don't warn if the label is marked with a "falls through" comment. */
|
||||||
|
if (FALLTHROUGH_LABEL_P (label))
|
||||||
|
return false;
|
||||||
|
|
||||||
/* Don't warn for a non-case label followed by a statement:
|
/* Don't warn for a non-case label followed by a statement:
|
||||||
case 0:
|
case 0:
|
||||||
foo ();
|
foo ();
|
||||||
|
|
@ -1905,7 +1909,6 @@ warn_implicit_fallthrough_r (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
|
||||||
if (gimple_code (next) == GIMPLE_LABEL
|
if (gimple_code (next) == GIMPLE_LABEL
|
||||||
&& gimple_has_location (next)
|
&& gimple_has_location (next)
|
||||||
&& (label = gimple_label_label (as_a <glabel *> (next)))
|
&& (label = gimple_label_label (as_a <glabel *> (next)))
|
||||||
&& !FALLTHROUGH_LABEL_P (label)
|
|
||||||
&& prev != NULL)
|
&& prev != NULL)
|
||||||
{
|
{
|
||||||
struct label_entry *l;
|
struct label_entry *l;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
2016-10-07 Marek Polacek <polacek@redhat.com>
|
||||||
|
|
||||||
|
* c-c++-common/Wimplicit-fallthrough-22.c: New test.
|
||||||
|
|
||||||
2016-10-07 Bernd Schmidt <bschmidt@redhat.com>
|
2016-10-07 Bernd Schmidt <bschmidt@redhat.com>
|
||||||
|
|
||||||
PR c++/69733
|
PR c++/69733
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
/* { dg-do compile } */
|
||||||
|
/* { dg-options "-Wimplicit-fallthrough" } */
|
||||||
|
|
||||||
|
void bar (int);
|
||||||
|
|
||||||
|
void
|
||||||
|
foo (int i)
|
||||||
|
{
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
bar (1);
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
case 2:
|
||||||
|
bar (2); /* { dg-warning "statement may fall through" } */
|
||||||
|
case 3:
|
||||||
|
bar (3); /* { dg-warning "statement may fall through" } */
|
||||||
|
case 4:
|
||||||
|
bar (4);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue