This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: if() and trailing ;


> But it is common to have an empty action on a condition.  You'll often
> see code like

    if (condition)
        /* 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

	if(...)
	   SOME_MACRO(with complex arguments)
	do_something();

since we could determine that the control is spanning a null macro.

Tom Truscott


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]