This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] Fix -Wlogical-not-parentheses (PR c++/62199)
- From: Marek Polacek <polacek at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: Paolo Carlini <paolo dot carlini at oracle dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 22 Aug 2014 18:33:57 +0200
- Subject: Re: [C++ PATCH] Fix -Wlogical-not-parentheses (PR c++/62199)
- Authentication-results: sourceware.org; auth=none
- References: <20140820175610 dot GN14320 at redhat dot com> <53F4EAA5 dot 8050205 at redhat dot com> <20140820200252 dot GO14320 at redhat dot com> <53F50CE0 dot 5010305 at redhat dot com> <20140821154125 dot GS14320 at redhat dot com> <53F63BCE dot 4050006 at redhat dot com> <20140822144848 dot GB15033 at redhat dot com> <53F75981 dot 3020401 at oracle dot com> <20140822155914 dot GD15033 at redhat dot com> <53F76EB0 dot 7000507 at redhat dot com>
On Fri, Aug 22, 2014 at 12:24:16PM -0400, Jason Merrill wrote:
> On 08/22/2014 11:59 AM, Marek Polacek wrote:
> >+ if (TREE_CODE (current.lhs) == INTEGER_CST)
> >+ warn_logical_not_parentheses (current.loc, current.tree_type,
> >+ current.lhs, rhs);
> >+ else if (EXPR_P (current.lhs))
> >+ warn_logical_not_parentheses (current.loc, current.tree_type,
> >+ TREE_OPERAND (current.lhs, 0), rhs);
>
> Sorry to nitpick, but now that we aren't checking the lhs for BOOLEAN_TYPE,
> do we need to look at it at all?
I believe so: if the LHS is an INTEGER_CST, we can't use TREE_OPERAND
on it. Happens e.g. for if (!5 > a).
Marek