[PATCH 4/4] Add -Wmisleading-indentation to -Wall
Sun Nov 1 22:06:00 GMT 2015
On Fri, Oct 30, 2015 at 5:03 AM, Richard Biener
> On Thu, Oct 29, 2015 at 6:38 PM, Jeff Law <email@example.com> wrote:
>> On 10/29/2015 10:49 AM, David Malcolm wrote:
>>> Our documentation describes -Wall as enabling "all the warnings about
>>> constructions that some users consider questionable, and that are easy to
>>> (or modify to prevent the warning), even in conjunction with macros."
>>> I believe that -Wmisleading-indentation meets these criteria, and is
>>> likely to be of benefit to users who may not read release notes; it
>>> warns for indentation that's misleading, but not for indentation
>>> that's merely bad: the former are places where a user will likely
>>> want to fix the code.
>>> The fix is usually easy and obvious: fix the misleadingly-indented
>>> code. If that isn't an option for some reason, pragmas can be used to
>>> turn off the warning for a particular fragment of code:
>>> #pragma GCC diagnostic push
>>> #pragma GCC diagnostic ignored "-Wmisleading-indentation"
>>> if (flag)
>>> x = 3;
>>> y = 2;
>>> #pragma GCC diagnostic pop
>>> -Wmisleading-indentation has been tested with a variety of indentation
>>> styles (see gcc/testsuite/c-c++-common/Wmisleading-indentation.c)
>>> and on a variety of real-world projects. For example, in:
>>> Patrick reports:
>>> "Tested by building the linux, git, vim, sqlite and gdb-binutils sources
>>> with -Wmisleading-indentation."
>>> With the tweak earlier in this kit I believe we now have a good
>>> enough signal:noise ratio for this warning to be widely used; hence this
>>> patch adds the warning to -Wall.
>>> Bootstrapped®rtested with x86_64-pc-linux-gnu.
>>> OK for trunk?
>>> * c.opt (Wmisleading-indentation): Add to -Wall for C and C++.
>>> * doc/invoke.texi (-Wall): Add -Wmisleading-indentation to the
>>> (-Wmisleading-indentation): Update documentation to reflect
>>> being enabled by -Wall in C/C++.
>> I'm sure we'll get some grief for this :-)
>> Approved once we're clean in GCC. I'm going to explicitly say that we'll
>> have to watch for fallout, particularly as we start getting feedback from
>> Debian & Fedora mass-rebuilds as we approach release time. If the fallout
>> is too bad, we'll have to reconsider.
>> I'll pre-approve patches which fix anything caught by this option in GCC as
>> long as the fix just adjusts whitespace :-)
> Please at least check also binutils and gdb and other packages that use -Werror
> (well, just rebuild Fedora world).
FYI binutils, gdb and glibc, from git, all fail to build due to
-Wmisleading-indentation warnings/errors. (None of the warnings are
bogus (IMO), though I don't think any of the warnings expose a real
More information about the Gcc-patches