From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 97430 invoked by alias); 30 Apr 2015 13:39:31 -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 97411 invoked by uid 89); 30 Apr 2015 13:39:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL,BAYES_40,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: mail-out.m-online.net Received: from mail-out.m-online.net (HELO mail-out.m-online.net) (212.18.0.9) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 30 Apr 2015 13:39:29 +0000 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3lcyVj4H6Mz3hkJN; Thu, 30 Apr 2015 15:39:25 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 3lcyVj0hhPzvPsg; Thu, 30 Apr 2015 15:39:25 +0200 (CEST) Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavisd-new, port 10024) with ESMTP id qCs3A76z-NrS; Thu, 30 Apr 2015 15:39:24 +0200 (CEST) X-Auth-Info: w+ouacLglD0cUqI7T1vYvu+TMG3rlHa7KpLS3TNlmLe/iHoNLEoVcmBlqtoMMWOv Received: from igel.home (ppp-93-104-94-204.dynamic.mnet-online.de [93.104.94.204]) by mail.mnet-online.de (Postfix) with ESMTPA; Thu, 30 Apr 2015 15:39:24 +0200 (CEST) Received: by igel.home (Postfix, from userid 1000) id 11DE62C3C14; Thu, 30 Apr 2015 15:39:24 +0200 (CEST) From: Andreas Schwab To: Marek Polacek Cc: GCC Patches Subject: Re: c-family PATCH to improve -Wbool-compare (PR c/64610) References: <20150428104932.GD11448@redhat.com> <87egn2hs05.fsf@igel.home> <20150430112727.GG3384@redhat.com> X-Yow: ... Blame it on the BOSSA NOVA!!! Date: Thu, 30 Apr 2015 14:21:00 -0000 In-Reply-To: <20150430112727.GG3384@redhat.com> (Marek Polacek's message of "Thu, 30 Apr 2015 13:27:27 +0200") Message-ID: <87lhh9hh0z.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2015-04/txt/msg02039.txt.bz2 Marek Polacek writes: > diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c > index 7d314f8..ada8e8a 100644 > --- gcc/c-family/c-common.c > +++ gcc/c-family/c-common.c > @@ -11924,6 +11924,17 @@ maybe_warn_bool_compare (location_t loc, enum tree_code code, tree op0, > } > else if (integer_zerop (cst) || integer_onep (cst)) > { > + /* If the non-constant operand isn't of a boolean type, we > + don't want to warn here. */ > + tree noncst = TREE_CODE (op0) == INTEGER_CST ? op1 : op0; > + /* Handle booleans promoted to integers. */ > + if (CONVERT_EXPR_P (noncst) > + && TREE_TYPE (noncst) == integer_type_node > + && TREE_CODE (TREE_TYPE (TREE_OPERAND (noncst, 0))) == BOOLEAN_TYPE) > + /* Warn. */; > + else if (TREE_CODE (TREE_TYPE (noncst)) != BOOLEAN_TYPE > + && !truth_value_p (TREE_CODE (noncst))) > + return; > /* Do some magic to get the right diagnostics. */ > bool flag = TREE_CODE (op0) == INTEGER_CST; > flag = integer_zerop (cst) ? flag : !flag; Looks good, successfully built stage3. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."