On Wed, 2015-12-09 at 16:40 +0100, Bernd Schmidt wrote: > On 12/09/2015 04:38 PM, David Malcolm wrote: > > +/* The following function contains examples of bad indentation that's > > + arguably not misleading, due to a blank line between the guarded and the > > + non-guarded code. Some of the blank lines deliberately contain > > + redundant whitespace, to verify that this is handled. > > + Based on examples seen in gcc/fortran/io.c, gcc/function.c, and > > + gcc/regrename.c. > > + > > + At -Wmisleading-indentation (implying level 1) we shouldn't emit > > + warnings for this function. Compare with > > + fn_40_level_1 in Wmisleading-indentation-level-1.c and > > + fn_40_level_2 in Wmisleading-indentation-level-2.c. */ > > + > > +void > > +fn_40_implicit_level_1 (int arg) > > +{ > > +if (flagA) > > + foo (0); > > + > > + foo (1); > > + > > I personally see no use for the blank line heuristic, in fact I think it > is misguided. To my eyes a warning is clearly warranted for the examples > in this testcase.
This goes back to the examples given in: https://gcc.gnu.org/ml/gcc-patches/2015-10/msg03225.html This is about managing the signal:noise ratio for something in -Wall. The distinction I want to make here is between badly indented code vs misleadingly indented code. Yes, the code is badly indented, but to my eyes the code is sufficiently badly indented that it has become *not* misleading: I can immediately see that something is awry. I want to preserve the -Wall level of the warning for the cases when it's not immediately clear that there's a problem. The levels idea means that you can turn off the blank-lines heuristic by setting -Wmisleading-indentation=2. > Do we actually have any users calling for this heuristic? FWIW, gcc trunk is clean with the blank-lines heuristic, but not without it (see the URL above for the 3 places I know of that fire without the heuristic). Dave