On Mon, May 23, 2016 at 11:43:24AM +0200, Florian Weimer wrote:
> On 05/20/2016 06:36 PM, Marek Polacek wrote:
> > --- gcc/gimplify.c
> > +++ gcc/gimplify.c
> > @@ -1595,6 +1595,32 @@ gimplify_switch_expr (tree *expr_p, gimple_seq 
> > *pre_p)
> >        gimplify_ctxp->case_labels.create (8);
> > 
> >        gimplify_stmt (&SWITCH_BODY (switch_expr), &switch_body_seq);
> > +
> > +      /* Possibly warn about unreachable statements between switch's
> > +    controlling expression and the first case.  */
> > +      if (warn_switch_unreachable
> > +     /* This warning doesn't play well with Fortran when optimizations
> > +        are on.  */
> > +     && !lang_GNU_Fortran ()
> > +     && switch_body_seq != NULL)
> 
> Does this still make the warning dependent on the optimization level and the
> target?

It's not dependent on the optimization level for C/C++ and I don't quite see
why would it be dependent on the target.  It's just that the Fortran FE with
-O optimizes a switch by removing the first case.  I don't know Fortran to
judge whether the warning could be useful there.
 
> Can we document what a programmer needs to do to suppress the warning? My
> worry is that the warning will be too unpredictable to be useful.

Why would you suppress the warning?  Just delete the code that cannot be
executed anyway.  And what is unpredictable?  You don't want the compiler
to warn on
   switch(x) {
     found = 1;
     case 1:
     ...
?

        Marek

Reply via email to