This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Refactor -Wmisleading-indentation API and extend coverage
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: Patrick Palka <patrick at parcs dot ath dot cx>
- Cc: gcc-patches at gcc dot gnu dot org, joseph at codesourcery dot com, jason at redhat dot com, dmalcolm at redhat dot com
- Date: Mon, 08 Jun 2015 19:45:56 +0100
- Subject: Re: [PATCH] Refactor -Wmisleading-indentation API and extend coverage
- Authentication-results: sourceware.org; auth=none
- References: <1433707596-6988-1-git-send-email-patrick at parcs dot ath dot cx>
Patrick Palka <patrick@parcs.ath.cx> writes:
> At the same time this patch extends the coverage of the
> -Wmisleading-indentation implementation to catch misleading indentation
> involving the semicolon. (These changes are all contained in
> c-indentation.c.) For example, now we warn on the following code
> samples:
>
> if (flag);
> foo ();
>
> while (flag);
> {
> ...
> }
>
> if (flag); {
> ...
> }
>
> if (flag)
> ; /* blah */ {
> ...
> }
>
> if (flag); foo ();
>
> while avoiding to warn on code that is poorly indented but not
> misleadingly so;
>
> while (flag);
> foo ();
>
> while (flag)
> ;
> foo ();
Maybe I've just been doing too much Python recently, but unlike the
other two examples, this one does seem a little misleading. What would
happen for:
while (flag)
/* blah */;
foo ();
where the semicolon is hidden after a comment?
Thanks to David and you for the patches btw -- looks like a really
useful feature.
Richard
> if (flag1)
> ;
> if (flag)
> ;
> else
> ...