[cfe-commits] [PATCH][PR11329][v4] Generalize -Wempty-body: warn when statement body is empty

Nico Weber thakis at chromium.org
Tue Jan 10 14:34:22 PST 2012


Hi Dmitri,

I ran a build of chromium and dependencies again, and that resulted in
3 false positives (2 in libxml, 1 in hunspell – in addition to 1 in
sqlite that already exists with the old warning). They all look like

third_party/libxml/src/pattern.c:308:43: warning: for loop has empty
body [-Wempty-body]
        for (i = 0;namespaces[2 * i] != NULL;i++);
                                                 ^
third_party/libxml/src/pattern.c:308:43: note: put the semicolon on a
separate line to silence this warning [-Wempty-body]

and are acceptable in my opinion.

I have two remaining comments, both of which are optional and could be
done in follow-ups:

1.) Maybe the "note" text could be tweaked to suggest that using
braces is fine, and that adding a space in front of the ';' is
sufficient too?
2.) It would be nice if -Wempty-body for if statements would also
print this new note – it looks like it's only printed for loops at the
moment.

Thanks for working on this! (I haven't looked at the actual patch,
only at the user-visible effects.)

Nico

On Sat, Jan 7, 2012 at 3:05 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
> On Thu, Jan 5, 2012 at 9:22 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
>> Attached is a patch that implements enhancement proposed in PR11329.
>
> *ping*
>
> Are there any issues with this patch?  Any other cases to include/exclude?
>
> Dmitri
>
> --
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list