[cfe-commits] [PATCH][PR11329] StaticAnalyzer: Warn when statement body is a semicolon -- an unintended null statement
Nico Weber
thakis at chromium.org
Tue Jan 3 15:09:11 PST 2012
FWIW, clang already warns on this for ifs:
$ cat test.cc
void f() {
if (false)
;
while (false)
;
for (;;)
;
}
$ clang -c test.cc
test.cc:3:5: warning: if statement has empty body [-Wempty-body]
;
^
1 warning generated.
So if you add this, you might want to put it under that flag. But
since that flag exists already, I'd guess that whoever added that
tried adding this for loops as well and decided that the noise level
is too high. It might be worth to look at the svn history of that
warning.
Nico
On Tue, Jan 3, 2012 at 1:25 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
> On Tue, Jan 3, 2012 at 11:16 PM, Ted Kremenek <kremenek at apple.com> wrote:
>> Thanks Dmitri. I agree with Anna that this should be a compiler warning.
>
> OK, I also agree that it is useful as a warning. I will rewrite and
> repost the patch.
>
> 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