From patchwork Tue Sep 20 18:40:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 672408 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sds5f2Q7rz9s65 for ; Wed, 21 Sep 2016 04:40:53 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=WStSUeIS; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:references:in-reply-to :content-type:content-id:content-transfer-encoding:mime-version; q=dns; s=default; b=AfgCRLBAqxjdaFnSIBmsts2zKozM4R5DPQpREuCpO3d hwyF1dHlTwJIjO/5jbNhozi/BDfPwPKYF9/8J5RHgQ/2zTO7cTB+HoYpUCFSiprT bXyb/kIfC/N/dg+TwTEfSjK/AH9NSG8cG038ozMnclcBNgE/G61eJkYlGIDRfdtU = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:references:in-reply-to :content-type:content-id:content-transfer-encoding:mime-version; s=default; bh=PUILvNteIcdEbJbBcv4ZkLUXn3s=; b=WStSUeISbFZwQB3Ne wCXZ0/wLO4j9j7vL1ljUEoCG84wyafspb2byV2KUD6AUM+4v4YxCVqh4tZfnaBDU eJGANOQeZq35HGUROhNs+cOAW+QEtR4znR0v03KTL5t0cz7epjRpV126gA1srBAa ab4lHWnUmEIBYZ4qyfFFeGvi3c= Received: (qmail 93426 invoked by alias); 20 Sep 2016 18:40:39 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 93364 invoked by uid 89); 20 Sep 2016 18:40:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, MIME_BASE64_BLANKS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=Distribute, Hx-languages-length:2761, distribute X-HELO: BAY004-OMC4S24.hotmail.com Received: from bay004-omc4s24.hotmail.com (HELO BAY004-OMC4S24.hotmail.com) (65.54.190.226) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Sep 2016 18:40:26 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com ([65.54.190.200]) by BAY004-OMC4S24.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Tue, 20 Sep 2016 11:40:25 -0700 Received: from AM5EUR03FT037.eop-EUR03.prod.protection.outlook.com (10.152.16.60) by AM5EUR03HT021.eop-EUR03.prod.protection.outlook.com (10.152.17.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.629.5; Tue, 20 Sep 2016 18:40:19 +0000 Received: from HE1PR0701MB2169.eurprd07.prod.outlook.com (10.152.16.59) by AM5EUR03FT037.mail.protection.outlook.com (10.152.17.241) 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; Tue, 20 Sep 2016 18:40:19 +0000 Received: from HE1PR0701MB2169.eurprd07.prod.outlook.com ([10.168.36.18]) by HE1PR0701MB2169.eurprd07.prod.outlook.com ([10.168.36.18]) with mapi id 15.01.0629.006; Tue, 20 Sep 2016 18:40:19 +0000 From: Bernd Edlinger To: Jason Merrill CC: Kyrill Tkachov , Jeff Law , GCC Patches , Joseph Myers Subject: Re: [PATCHv3, resent] Add a warning for suspicious use of conditional expressions in boolean context Date: Tue, 20 Sep 2016 18:40:18 +0000 Message-ID: References: <8ef95068-7826-ab09-6c22-12dd381aa808@redhat.com> <57E11D80.9080409@foss.arm.com> In-Reply-To: authentication-results: spf=softfail (sender IP is 10.152.16.59) 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.16.59 as permitted sender) x-ms-exchange-messagesentrepresentingtype: 1 x-eopattributedmessage: 0 x-microsoft-exchange-diagnostics: 1; AM5EUR03HT021; 6:5PLObpuu8PvTW+1tK52ihiONbQAIeZIY+FNVMQcgc/JK4xF6QtFD0cJ9unOJBFQUvE289au6Ee6AxowD/QKO/OdxZkyJw/xtIVLnewOGHt08Ep+ysL9Y84AJ+ma//Auuyzrx7e0rrBoa/CnjLc0MlrcrHYqiWTiOfArRFlMWybvWTRhQK7+FtVtKIb0Z+FCJ+yrCTgDyEzeYCiv1gRGp7lLamycMCZDI1QkrDlVEbJLnp94xvKIMIZljmlb+Iy/m9OWTJelJ4LUTt09582Wsx4kAgsp2etUlnqiNjvE94lI=; 5:LkJYBQeLUQzyd0FVgAENzYAMb2hAIEkCqu44R8KzeT28Pun4LnlyPr47xKZF8woxoJcgLH5AK4rupiyI8m/TaeTZhE2FpB3qpO2OVUcXKoxibYAetCi84a8fTeP+xLw1+ec5zN5V1F7ctGajEnDe5g==; 24:O7I0k/S5KmfcsLUVSr0F1MRRvMdaAOxvVWLl7gq8XeMcrsIq+QV+N3y8HSuSr+JbDuQDZcyvGdHuNG0I8DjfTfLks18iUr/5evFMzqFlHYk=; 7:gg0yv6dUc27ApW3jznVlvB+cAsii+cHBNVpUZetvaUZBdiwPBS2Viy9Ajg2+DF2gclN07rEcmtEfWwWxiAuX1H9r+FlpVoOg6V2ry/gEjSFmiQplnVO8mdc3ROx47EMCwwF/WPwKnb3q6WB+xwZ+WdccbFnHSIP+SEnZuLqUZTFrl5rndOpkNCPNo75hvlBfIvrItiCaf4PtmDe2sa8El0JWFLh3lSW0ETWTyTK0QCfN65qD5zdwAH3VnASKHNA9IwaWrm4RRzFUca4PxzQvuThZezJva0noGDquX6HxmuA6x1Zv99CzPJH3/FIlmGDw x-forefront-antispam-report: EFV:NLI; SFV:NSPM; SFS:(10019020)(98900003); DIR:OUT; SFP:1102; SCL:1; SRVR:AM5EUR03HT021; H:HE1PR0701MB2169.eurprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; x-ms-office365-filtering-correlation-id: 3a3dc6ab-bfcc-483e-98f6-08d3e18590f5 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(1601124038)(1603103081)(1601125047); SRVR:AM5EUR03HT021; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(432015012)(82015046); SRVR:AM5EUR03HT021; BCL:0; PCL:0; RULEID:; SRVR:AM5EUR03HT021; x-forefront-prvs: 0071BFA85B spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: <4A299936F2DE0746BC5E4AD64F203B1B@eurprd07.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Sep 2016 18:40:18.9994 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5EUR03HT021 On 09/20/16 16:51, Jason Merrill wrote: > On Tue, Sep 20, 2016 at 10:11 AM, Bernd Edlinger > wrote: >> On 09/20/16 13:29, Kyrill Tkachov wrote: >>> >>> arm bootstrap is now failing: >>> $SRC/gcc/config/arm/arm.h:2229:40: error: ?: using integer constants in >>> boolean context [-Werror=int-in-bool-context] >>> : (TARGET_VFP_DOUBLE ? (TARGET_FP16 ? 14 : 12) : 0)) \ >>> ~~~~~~~~~~~~~^~~~~~~~~~ >>> $SRC/gcc/config/arm/arm-c.c:133:7: note: in expansion of macro >>> 'TARGET_ARM_FP' >>> if (TARGET_ARM_FP) >>> >>> >>> The full definition of TARGET_ARM_FP is: >>> #define TARGET_ARM_FP \ >>> (!TARGET_SOFT_FLOAT ? (TARGET_VFP_SINGLE ? 4 \ >>> : (TARGET_VFP_DOUBLE ? (TARGET_FP16 ? 14 : 12) : 0)) \ >>> : 0) >>> >>> We want it set to 0 when there's no FP but when FP is available we set >>> it to a bitmask >>> to suggest the level that is available. That seems like a legitimate use >>> to me. >>> >> >> Ok, I see, sorry for that. >> >> I think I will have to suppress the warning if the conditional is in >> a macro somehow. > > from_macro_expansion_at will help with that. > > Though it seems to me that the issue here is more that (TARGET_FP16 ? > 14 : 12) is not in a boolean context, it's in an integer context; only > the outer ?: is in a boolean context. > > I also still think the warning message should be changed. > I try this: That will fix "if (TARGET_ARM_FP)" which is fine. But this seems to suppress all such warnings from an assert macro too. Like for instance "assert(a?1:2)". Sure, we would not be interested in a ?: that is part of the assert macro itself, but the expression that is evaluated by the macro should be checked, but that is no longer done, because the macro parameter is now also from the macro expansion. But it is initially from the macro invocation point. Ideas? Thanks Bernd. Index: c-common.c =================================================================== --- c-common.c (revision 240268) +++ c-common.c (working copy) @@ -4652,7 +4652,8 @@ TREE_OPERAND (expr, 0)); case COND_EXPR: - if (warn_int_in_bool_context) + if (warn_int_in_bool_context + && !from_macro_expansion_at (EXPR_LOCATION (expr))) { tree val1 = fold_for_warn (TREE_OPERAND (expr, 1)); tree val2 = fold_for_warn (TREE_OPERAND (expr, 2)); @@ -4663,7 +4664,8 @@ && (!integer_onep (val1) || !integer_onep (val2))) warning_at (EXPR_LOCATION (expr), OPT_Wint_in_bool_context, - "?: using integer constants in boolean context"); + "?: using integer constants in boolean context, " + "the expression will always evaluate to %"); } /* Distribute the conversion into the arms of a COND_EXPR. */ if (c_dialect_cxx ())