On Fri, Jun 10, 2016 at 02:36:23PM +0200, Marek Polacek wrote: > --- gcc/gimplify.c > +++ gcc/gimplify.c > @@ -1559,6 +1559,50 @@ gimplify_statement_list (tree *expr_p, gimple_seq > *pre_p) > return GS_ALL_DONE; > } > > +/* Possibly warn about unreachable statements between switch's controlling > + expression and the first case. SEQ is the body of a switch expression. > */ > + > +static void > +maybe_warn_switch_unreachable (gimple_seq seq) > +{ > + if (!warn_switch_unreachable > + /* This warning doesn't play well with Fortran when optimizations > + are on. */ > + || lang_GNU_Fortran () > + || seq == NULL) > + return; > + > + /* Look into the innermost lexical scope. */ > + while (seq && gimple_code (seq) == GIMPLE_BIND) > + seq = gimple_bind_body (as_a <gbind *> (seq)); > + > + /* If it is empty, there's nothing to do. */ > + if (seq == NULL) > + return;
Won't this just give up on say: void foo (int a, int b) { switch (a) { { int c; } { int d; } { int e; } b++; case 1: break; } } ? Such blocks can also be can be arbitrarily nested. Wouldn't it be better to just walk_gimple_seq with NULL callback_op and non-NULL callback_stmt that would stop on the first real stmt in there? Also, the above loop looks confusing, I'd be expecting gimple_seq_first_stmt (seq) before testing it for GIMPLE_BIND or casting to gbind. Jakub