This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC stage 1] Proposed new warning: -Wmisleading-indentation
- From: Mike Stump <mikestump at comcast dot net>
- To: David Malcolm <dmalcolm at redhat dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 16 Apr 2015 10:26:45 -0700
- Subject: Re: [RFC stage 1] Proposed new warning: -Wmisleading-indentation
- Authentication-results: sourceware.org; auth=none
- References: <1429196485 dot 32584 dot 46 dot camel at surprise>
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