This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C/C++ PATCH] -Wlogical-not-parentheses tweaks (PR c/65120)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 9 Mar 2015 15:34:56 +0100
- Subject: Re: [C/C++ PATCH] -Wlogical-not-parentheses tweaks (PR c/65120)
- Authentication-results: sourceware.org; auth=none
- References: <20150220000326 dot GT1746 at tucnak dot redhat dot com> <54F0EFDB dot 5030703 at redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Feb 27, 2015 at 05:29:47PM -0500, Jason Merrill wrote:
> On 02/19/2015 07:03 PM, Jakub Jelinek wrote:
> >+ /* Avoid warning for !!b == y where b is boolean. */
> >+ && (!DECL_P (current.lhs)
> >+ || TREE_TYPE (current.lhs) == NULL_TREE
> >+ || TREE_CODE (TREE_TYPE (current.lhs)) != BOOLEAN_TYPE))
>
> There's something wrong here. If the type is null, trying to check its
> TREE_CODE will SEGV.
If the type is NULL, then it will just call warn_logical_not_parentheses
and won't check TREE_CODE. Only when it is non-NULL, it will check
TREE_CODE and if it is not BOOLEAN_TYPE, will call
warn_logical_not_parentheses.
Jakub