This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PING C++] Move empty-if warning to the front-end
- From: Paolo Bonzini <bonzini at gnu dot org>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sat, 27 Sep 2008 07:51:57 +0200
- Subject: Re: [PING C++] Move empty-if warning to the front-end
- References: <ga52a1$tks$1@ger.gmane.org> <48DDA807.3050908@codesourcery.com>
Mark Mitchell wrote:
> Paolo Bonzini wrote:
>> This patch from stage1:
>>
>> http://permalink.gmane.org/gmane.comp.gcc.patches/170041
>>
>> needs C++ maintainer approval. It allows to avoid a hack in the removal
>> of CONVERT_EXPR, by avoiding that NOP_EXPR<void>(0) and
>> CONVERT_EXPR<void>(0) have different meaning.
>
> This is conceptually OK. But, I would like to understand why you've
> duplicate the code for both the if and else clauses, and also why that
> code isn't exactly the same, other than the literal word "if" and "else".
Because the testcase says
if (x)
; /* By design we don't warn in this case. */
else
(void)0;
if (x)
(void)0;
else
; /* { dg-warning "suggest braces around empty body in an" } */
and this causes all the differences you spotted.
Thanks for the review!
Paolo