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

Dmitri Gribenko gribozavr at gmail.com
Sat Feb 11 07:32:53 PST 2012


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.

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>*/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: generalize-warn-empty-body-v16.patch
Type: text/x-diff
Size: 32646 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120211/c448e811/attachment.patch>


More information about the cfe-commits mailing list