This is the mail archive of the
mailing list for the GCC project.
Re: if() and trailing ;
- From: "Thomas R. Truscott" <trt at cs dot duke dot edu>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 2 Aug 2006 10:25:27 -0400 (EDT)
- Subject: Re: if() and trailing ;
> But it is common to have an empty action on a condition. You'll often
> see code like
/* nothing */;
Yes, the intent of the warning is catch people who stick a ; at the end
of a line (out of habit) when there should not be one.
That is what the warning should target, not good code like the above.
gcc should suppress the warning when the ';' is on a different line
than the `if'. I do that (and other filtering) in a similar warning
for `for' and `while' with good results.
If the pre-processor would mark comment and macro boundaries,
then we could do better. E.g. these should not trigger the warning:
if (condition) /* nothing */;
if (condition) SPEW();
And we could easily detect the problem with
SOME_MACRO(with complex arguments)
since we could determine that the control is spanning a null macro.