From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11106 invoked by alias); 8 Oct 2016 20:05:39 -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 11096 invoked by uid 89); 8 Oct 2016 20:05:38 -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_50,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Distribute, adjust_packed, sk:type_co, COND_EXPR X-HELO: BLU004-OMC1S6.hotmail.com Received: from blu004-omc1s6.hotmail.com (HELO BLU004-OMC1S6.hotmail.com) (65.55.116.17) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 08 Oct 2016 20:05:27 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com ([65.55.116.9]) by BLU004-OMC1S6.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Sat, 8 Oct 2016 13:05:26 -0700 Received: from VE1EUR03FT024.eop-EUR03.prod.protection.outlook.com (10.152.18.53) by VE1EUR03HT020.eop-EUR03.prod.protection.outlook.com (10.152.19.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.629.5; Sat, 8 Oct 2016 20:05:24 +0000 Received: from AM4PR0701MB2162.eurprd07.prod.outlook.com (10.152.18.57) by VE1EUR03FT024.mail.protection.outlook.com (10.152.18.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.629.5 via Frontend Transport; Sat, 8 Oct 2016 20:05:24 +0000 Received: from AM4PR0701MB2162.eurprd07.prod.outlook.com ([10.167.132.147]) by AM4PR0701MB2162.eurprd07.prod.outlook.com ([10.167.132.147]) with mapi id 15.01.0659.015; Sat, 8 Oct 2016 20:05:24 +0000 From: Bernd Edlinger To: Jason Merrill CC: Florian Weimer , "gcc-patches@gcc.gnu.org" , Jeff Law Subject: Re: [PATCH] Make -Wint-in-bool-context warn on suspicious shift ops Date: Sat, 08 Oct 2016 20:05:00 -0000 Message-ID: References: <87fuol77ri.fsf@mid.deneb.enyo.de> In-Reply-To: authentication-results: spf=softfail (sender IP is 10.152.18.57) smtp.mailfrom=hotmail.de; redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=hotmail.de; received-spf: SoftFail (protection.outlook.com: domain of transitioning hotmail.de discourages use of 10.152.18.57 as permitted sender) x-ms-exchange-messagesentrepresentingtype: 1 x-eopattributedmessage: 0 x-microsoft-exchange-diagnostics: 1;VE1EUR03HT020;6:jfKUV4gkubXO+PudBg8ls8+9fH1k5lA4Cd/B4aAg06HZrE0o+lDe1Bvd4rLQdkGV6R3mAjKOAmoz1uZNPYgqhTLf6+AtUkbvngNX3gyDkYEhaxT1k6tzzbh/wxoxVEQL23BOFmmrOdVf26Fpd3b65fzAJfh1lKJR7PfUnZSDmEoSSRllrxQlmRcdkye6d7ZWZrroZ2DkESsBuhUEO0imAORpuPzsm10nzfm4IOtJo9JwBnrMwQsKJXkDJjfDAALT7r5mkepfJI91H6SlXgqeLooVHNxbxbVUGH7NVue1T4s=;5:K6j0w/wF3wJnwgY7/7X/t0gCOVW0wm9hOYVnJuXwfw2ZQaB+KEdU1KK0/SgizgSZTcdkf+iCiYwts7smAg3lzPMhXqu+HrDbsKxL1ILQx7Ozw7bQhhBlo/AywB1Kqj53GWw29Bcs/l8XxFTgb75+ag==;24:XTedwOj7n+l7sOpAmNdWr4NmaZMHMM7muAICuTL7nizzh/e3jnyjlVvbrfmM2ZMywfUP/s67hLHhHDW5F425H6ZVoPzy8BXTF09IwhKLHjA=;7:IpzKXBtXt7x8NlZD2L3QnLqeoJvjZqHNjmK+3zX48y0BSj4HTfTx9LZYXW6mqb4urKofFWinKZJ5LRwF4NuovoauZkxl6wXzQL7fx33Xa1DJuCsv8EC0UWg4Rz91m0y1Bdvq7I+ttgrxaNkW3jxU0w2IIIH0kfCu3a1EWh6YUauc5h2IlKISGyAgOAVubPru8XlwaO8zUmL1bSKrgxZgQFqml+ckoBI8zWpAYrj8SWTK7C/zFYgUChJSn1hC+6Egue175BYxywIRMv7rMOi9tF9sUt4RSMXLaHj+5Mi1+tiyKKh5eDm1OGpmKJCKyC6M x-forefront-antispam-report: EFV:NLI;SFV:NSPM;SFS:(10019020)(98900003);DIR:OUT;SFP:1102;SCL:1;SRVR:VE1EUR03HT020;H:AM4PR0701MB2162.eurprd07.prod.outlook.com;FPR:;SPF:None;LANG:en; x-ms-office365-filtering-correlation-id: 8f4cf06a-1d9f-4b4b-e838-08d3efb67013 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(1601124038)(1603103081)(1601125047);SRVR:VE1EUR03HT020; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(432015012)(82015046);SRVR:VE1EUR03HT020;BCL:0;PCL:0;RULEID:;SRVR:VE1EUR03HT020; x-forefront-prvs: 008960E8EC spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="Windows-1252" Content-ID: <2FEBBCF852149449B31FA9AE29CE0A2A@eurprd07.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Oct 2016 20:05:24.3129 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR03HT020 X-SW-Source: 2016-10/txt/msg00546.txt.bz2 On 10/08/16 19:40, Jason Merrill wrote: > On Fri, Sep 30, 2016 at 1:07 AM, Bernd Edlinger > wrote: >> On 09/29/16 22:38, Jason Merrill wrote: >>> On Thu, Sep 29, 2016 at 3:58 PM, Bernd Edlinger >>> wrote: >>>> Unfortunately, without that exception there is a false positive: >>>> >>>> In file included from ../../gcc-trunk/gcc/ada/gcc-interface/decl.c:30:= 0: >>>> ../../gcc-trunk/gcc/ada/gcc-interface/decl.c: In function 'int >>>> adjust_packed(tree, tree, int)': >>>> ../../gcc-trunk/gcc/tree.h:1874:22: error: << on signed integer in >>>> boolean context [-Werror=3Dint-in-bool-context] >>>> ? ((unsigned)1) << ((NODE)->type_common.align - 1) : 0) >>>> ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> >>> Ah, this issue again: the shift isn't in boolean context, it's in >>> integer context. I think we want to be a lot more conservative about >>> these warnings in the arms of a COND_EXPR. In fact, I think the >>> entire >>> >>> /* Distribute the conversion into the arms of a COND_EXPR. */ >>> >>> section is wrong now that we're doing delayed folding. >> >> Could you take care of this ? > > Done thus: > Thanks. But I have one question: --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -2253,6 +2253,15 @@ cp_fold (tree x) op1 =3D cp_fold (TREE_OPERAND (x, 1)); op2 =3D cp_fold (TREE_OPERAND (x, 2)); + if (TREE_CODE (TREE_TYPE (x)) =3D=3D BOOLEAN_TYPE) + { + warning_sentinel (warn_int_in_bool_context); Yes, it compiles, but ... how can this compile at all? Doesn't it miss a name of a local? like warning_sentinel c (warn_int_in_bool_context); If I disassemble this function I see a constructor of warning_sentinel directly followed by a destuctor. And apparently warn_int_in_bool_context is not zero in the block, thus: if (TREE_CODE (TREE_TYPE (x)) =3D=3D BOOLEAN_TYPE) { warning_sentinel (warn_int_in_bool_context); gcc_assert (!warn_int_in_bool_context); if (!VOID_TYPE_P (TREE_TYPE (op1))) op1 =3D cp_truthvalue_conversion (op1); fails the assertion. Bernd.