From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4562 invoked by alias); 20 Feb 2015 15:35:18 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 4549 invoked by uid 89); 20 Feb 2015 15:35:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 20 Feb 2015 15:35:16 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1KFZDVX029642 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 20 Feb 2015 10:35:13 -0500 Received: from redhat.com ([10.40.204.30]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1KFZ6vr028339 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Fri, 20 Feb 2015 10:35:10 -0500 Date: Fri, 20 Feb 2015 15:47:00 -0000 From: Marek Polacek To: Jakub Jelinek Cc: "Joseph S. Myers" , Jason Merrill , gcc-patches@gcc.gnu.org Subject: Re: [C/C++ PATCH] -Wlogical-not-parentheses tweaks (PR c/65120) Message-ID: <20150220153505.GE23138@redhat.com> References: <20150220000326.GT1746@tucnak.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150220000326.GT1746@tucnak.redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2015-02/txt/msg01288.txt.bz2 On Fri, Feb 20, 2015 at 01:03:26AM +0100, Jakub Jelinek wrote: > Hi! > > As reported, !!x == y is quite common in the Linux kernel > and unlike the !x == y case it usually doesn't mean mistyped > !(x == y) or x != y. clang++ apparently doesn't warn about that > either, and it doesn't warn even about the case where ! is applied > to a bool. Note that first version of -Wlogical-not-parentheses didn't warn when LHS had a boolean type, this has been changed later on. I have no strong preference either way. > As the argument is already folded, it isn't easy to determine > those cases always, but I hope the following is sufficient until we switch > to late folding. Yes, this means that we warn for return !(a != 0) == b; but not for return !(a == 0) == b; I think we can live with that for now. > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2015-02-19 Jakub Jelinek > > PR c/65120 > * c-typeck.c (parser_build_binary_op): Don't warn for > !!x == y or !b == y where b is _Bool. > > * parser.c (cp_parser_binary_expression): Don't warn for > !!x == y or !b == y where b is bool. > > * c-c++-common/pr49706.c: Adjust tests for not warning > about !!x == y or !b == y where b is boolean, and add > some further tests. > * c-c++-common/pr62199-2.c: Likewise. The C part is ok. Maybe we should also update the docs to reflect that -Wlogical-not-parentheses does not warn if the RHS *or LHS* operand is of a boolean type. Thanks, Marek