From patchwork Mon Nov 18 15:45:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1196831 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-513933-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="bxRdC1g5"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="i38+/7Hr"; dkim-atps=neutral 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 47GtbW6NJlz9sPT for ; Tue, 19 Nov 2019 02:46:14 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=lZHX/vNOwdo7g0dzGnw4R/6jzLZL72rfrQWOaqCRneqE4juDys mXQDnDGbcDvTxoQj9aETzA8sg+dYjIs9BeLZdudUjC46p3X2/0pBsJxaXu26sVxA 1iAvOD1g/5E8nO2koDckUthyh9bIpLCNSLsA/84AGrpfCdhYNoyXZFhC4= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=VqafIzu+wPlNIf/3ct4ePy6tnQk=; b=bxRdC1g5foMecojdA4uO t0GabKXqQ6NDqYShrajdecV0+VwzQ4ily8IbW8PqPC26KTwxehg1g9DsjPfkaeDl Qi88rp77Njkl6Wh6qtA0WHx0a00MPs2DjQLbn5EuykaJvk9xgnv0X/qZe0ZgWJEQ m6Cv9er0zVfi1XpccUdDdYQ= Received: (qmail 29155 invoked by alias); 18 Nov 2019 15:46:07 -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 29146 invoked by uid 89); 18 Nov 2019 15:46:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=H*r:8.14.4, HX-Envelope-From:sk:paolo.c, sk:paolo.c, dg-warning X-HELO: userp2120.oracle.com Received: from userp2120.oracle.com (HELO userp2120.oracle.com) (156.151.31.85) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 Nov 2019 15:46:05 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAIFiPfA058073; Mon, 18 Nov 2019 15:46:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : cc : from : subject : message-id : date : mime-version : content-type; s=corp-2019-08-05; bh=QyHYkcqBN0zsudKTxem0Ek+JKhtgGkLU4M7s3DSjWfg=; b=i38+/7Hr+KQvmiTqcC89u9Tfd6icsLDVWoPkoGFJ3/R3H8Qo7+r0yZVIazpOnWV7T9hx 4Y0uqe1BeWbE6WxnAsp0S6abLH4nFqIBRD5R5uFClTVe5GnuVJH1/xCcuGv9z07ecuYV qFoInadZrqY6RjKXZLYNOCdKZVkLzew4MuC5MHmO9vQJ3qFgPEPjEfa+c6T0BFE5D5eo ICZN3JWv8s0zAqrKGRCJHEHJ9Y93NPIBekqMamFRuPYCs6RhcwVgG7uPJ/2e25y45mAm UVTZ0nTe3Xtc8iqr2N80oNvdtf10SEvDqf3WWUex2Q1ADXoIEXe8iGFhW3t3U4JyVpEb dQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2wa9rq8x5x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2019 15:46:03 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAIFiZJB017186; Mon, 18 Nov 2019 15:46:03 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2watjxqutu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2019 15:46:02 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id xAIFk1t9025737; Mon, 18 Nov 2019 15:46:01 GMT Received: from [192.168.1.4] (/95.246.235.231) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Nov 2019 07:46:01 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Avoid duplicate warning Message-ID: <1c19955c-f213-0c35-b2b8-93a9517c86dc@oracle.com> Date: Mon, 18 Nov 2019 16:45:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi, functions like c_common_truthvalue_conversion are shared with the C front-end thus don't get a tsubst_flags_t argument. It seems clear that long term we have to do something about those but in the meanwhile we have been using warning sentinels which, along the paths which certainly must have all the warnings suppressed, work well for now and cannot cause regressions. Here I propose to add (at least) one more to ocp_convert since I have a straightforward testcase. Note sue if we want to proactively add, say, one for warn_parentheses too. Tested x86_64-linux. Thanks, Paolo. /////////////////// /cp 2019-11-18 Paolo Carlini * cvt.c (ocp_convert): Use additional warning sentinel. /testsuite 2019-11-18 Paolo Carlini * g++.dg/warn/multiple-sign-compare-warn-1.C: New. Index: cp/cvt.c =================================================================== --- cp/cvt.c (revision 278407) +++ cp/cvt.c (working copy) @@ -847,6 +847,7 @@ ocp_convert (tree type, tree expr, int convtype, i /* Prevent bogus -Wint-in-bool-context warnings coming from c_common_truthvalue_conversion down the line. */ warning_sentinel w (warn_int_in_bool_context); + warning_sentinel c (warn_sign_compare); return cp_truthvalue_conversion (e, complain); } } Index: testsuite/g++.dg/warn/multiple-sign-compare-warn-1.C =================================================================== --- testsuite/g++.dg/warn/multiple-sign-compare-warn-1.C (nonexistent) +++ testsuite/g++.dg/warn/multiple-sign-compare-warn-1.C (working copy) @@ -0,0 +1,11 @@ +// { dg-options "-Wsign-compare" } + +int foo() +{ + unsigned char b = '1'; + + bool x = ~b; // { dg-bogus "promoted bitwise complement of an unsigned value is always nonzero.*promoted bitwise complement of an unsigned value is always nonzero" } + // { dg-warning "promoted bitwise complement of an unsigned value is always nonzero" "" { target *-*-* } .-1 } + + return 0; +}