This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [libcpp+C++ PATCH] Fix -Wempty-body C++ warning (PR c++/36478)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: Tom Tromey <tromey at redhat dot com>, Jason Merrill <jason at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 10 Nov 2008 20:46:53 +0100
- Subject: Re: [libcpp+C++ PATCH] Fix -Wempty-body C++ warning (PR c++/36478)
- References: <20081110133714.GQ3572@tyan-ft48-01.lab.bos.redhat.com> <49188C86.4030806@codesourcery.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, Nov 10, 2008 at 11:33:26AM -0800, Mark Mitchell wrote:
> >From a technical perspective, I think this patch makes sense. In
> particular, using a flag from the preprocessor, rather than poking at
> location information, seems OK to me.
>
> But, do we really want to warn about:
>
> while (0);
>
> but not:
>
> while (0) ;
>
> ?
A lot of people write for (a = b; something; somethingelse) ;
or for (a = b; something; somethingelse)/* Empty */;
if everything needed for the loop happens in the condition
or increment or both. I don't think we want to add extra cases where
we want to warn, it will make the warning completely useless.
> That seems surprising to me.
>
> I can understand not warning about:
>
> while (0)
> ;
That's just one of the possible styles people use to mark an empty body
of a loop. A space is another one, a comment another one, a macro another
one. The alternative is IMHO just reverting Mike's 2007-05-07 changes.
> If we're using the single space as a way of making -save-temps work
> (because an empty macro gets replaced with a space), I think that's just
> as fragile a hack as we had before. If we really need to make
Why? Space is used by the preprocessor generally as a token separator
if whitespace is needed and we don't preserve columns with -E anyway.
> -save-temps work, then we need -save-temps to emit something explicit to
> mark the presence of the macro.
>
> But, I also don't see it as a crisis if -save-temps doesn't work in this
> particular case. Once we decide that the presence of a macro is a
> significant fact, we also accept that preprocessing the code is going to
> result in a change. That might argue that using the presence of a macro
> is a mistake...
-save-temps is perhaps not 100% important, though many people will moan, but
ccache is important for a lot of users.
Jakub