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

Argyrios Kyrtzidis kyrtzidis at apple.com
Mon Feb 13 19:28:40 PST 2012

Hi Dmitri,

On Feb 11, 2012, at 7:32 AM, Dmitri Gribenko wrote:

> Hello Chandler,
> I have to agree with you.  If this warning is starting to interfere
> with someone's style preference, then, although it might be useful, it
> can't be on-by-default.
> I've removed special handling of range-based for.  So, now we have the
> following behavior:
> * if, switch, range-based for: warn if semicolon is on the same line.
> * for, while: warn if semicolon is on the same line and either next
> statement is compound statement or next statement has more
> indentation.

Chandler and Richard raised concerns about not being consistent with how the warning treats the semicolon.
I can imagine that the same way one would comment out inside a compound body, e.g.:

if (...) { /*my_silly_code();*/ }

one could also comment out like this:

if (...) ; // my_silly_code();

Do you have cases (from e.g. llvm/clang or chromium, etc.) where the warning found an actual bug in a place where there was a semicolon in the same line but next statement was not compound statement and it didn't have more indentation ?


> Replacing the semicolon with {} or moving the semicolon to the next
> line will always silence the warning.
> 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>*/
> <generalize-warn-empty-body-v16.patch>_______________________________________________
> 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