[RFC stage 1] Proposed new warning: -Wmisleading-indentation
Mike Stump
mikestump@comcast.net
Thu Apr 16 17:27:00 GMT 2015
On Apr 16, 2015, at 8:01 AM, David Malcolm <dmalcolm@redhat.com> wrote:
> Attached is a work-in-progress patch for a new
> -Wmisleading-indentation
> warning I've been experimenting with, for GCC 6.
Seems like a nice idea in general.
Does it also handle:
if (cone);
stmt;
? Would be good to add that to the test suite, as that is another hard to spot common error that should be caught.
I do think that it is reasonable to warn for things like:
stmt;
stmt;
one of those two lines is likely misindented, though, maybe you want to start with the high payback things first.
> An issue here is how to determine (i), or if it's OK to default to 8
Yes, 8 is the proper value to default it to.
> and have a command-line option (param?) to override it? (though what about,
> say, each header file?)
I’ll abstain from this. The purist in me says no option for other than 8, life goes on. 20 years ago, someone was confused over hard v soft tabbing and what exactly the editor key TAB does. That confusion is over, the 8 people have won. Catering to other than 8 gives the impression that the people that lost still have a chance at winning. :-)
> Thoughts on this, and on the patch?
Would be nice to have a stricter version that warns about all wildly inconsistently or wrongly indented lines.
{
stmt;
stmt; // must be same as above
}
{
stmt; // must be indented at least 1
}
if (cond)
stmt; // must be indented at least 1
More information about the Gcc-patches
mailing list