From patchwork Tue May 24 12:32:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 625606 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 3rDZcy2YDdz9t6j for ; Tue, 24 May 2016 22:35:30 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=hqswOmWk; 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:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=dLFs3DseKw/KwNE/ip659QiFIUiYQ7exJgwO/cYwESuwmBOKA0 fsJ7mWdUYx9dSAFjjUyfEejUBuU/OZY0Rzmolyh+eOrMorFIuvzUJKg7cRdXp6l0 fpQL/nV1OzG8iRJBQ84YOZkiEGX6HuVjhiL+C9b5s5NKw8CPlPlf+/NvM= 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=HvvkSS6AsiVT9cZ+7yp3FDUh86M=; b=hqswOmWkYqZtSuzBi9yB 0N5tdQN3v1H3v47AmFbpFlhvsHjzKgxhq9Aruo0tsTpmOqG1IzMXrjjCZfTz5rN3 o+pum6C14xO4hMi167CZVOQCnN5LNY/s5G8kw7V630HSgwsEZg1EMymrcLoNtgyA OVey90bN6h74hTo/L9NE4xM= Received: (qmail 13963 invoked by alias); 24 May 2016 12:32:45 -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 13742 invoked by uid 89); 24 May 2016 12:32:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=BAYES_00, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 24 May 2016 12:32:33 +0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u4OCWSvR020299 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 24 May 2016 12:32:31 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u4OCWOqn015962 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 24 May 2016 12:32:26 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id u4OCWL2f005353; Tue, 24 May 2016 12:32:22 GMT Received: from [192.168.1.4] (/79.12.211.42) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 24 May 2016 05:32:21 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] PR 69872 ("[6/7 Regression] -Wnarrowing note without warning/errror") Message-ID: <574449D2.2070305@oracle.com> Date: Tue, 24 May 2016 14:32:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, in this small diagnostic regression we emit an inform without a preceding warning/error: checking the return value of the pedwarn, as we normally want to do, fixes the problem. Tested x86_64-linux. Thanks, Paolo. ///////////////////// /cp 2016-05-24 Paolo Carlini PR c++/69872 * typeck2.c (check_narrowing): Check pedwarn return value. /testsuite 2016-05-24 Paolo Carlini PR c++/69872 * g++.dg/warn/Wno-narrowing1.C: New. Index: cp/typeck2.c =================================================================== --- cp/typeck2.c (revision 236630) +++ cp/typeck2.c (working copy) @@ -950,10 +950,12 @@ check_narrowing (tree type, tree init, tsubst_flag { if (complain & tf_warning_or_error) { - if (!almost_ok || pedantic) - pedwarn (loc, OPT_Wnarrowing, "narrowing conversion of %qE " - "from %qT to %qT inside { }", init, ftype, type); - if (pedantic && almost_ok) + if ((!almost_ok || pedantic) + && pedwarn (loc, OPT_Wnarrowing, + "narrowing conversion of %qE " + "from %qT to %qT inside { }", + init, ftype, type) + && almost_ok) inform (loc, " the expression has a constant value but is not " "a C++ constant-expression"); ok = true; Index: testsuite/g++.dg/warn/Wno-narrowing1.C =================================================================== --- testsuite/g++.dg/warn/Wno-narrowing1.C (revision 0) +++ testsuite/g++.dg/warn/Wno-narrowing1.C (working copy) @@ -0,0 +1,7 @@ +// PR c++/69872 +// { dg-options "-Wall -Wextra -pedantic -Wno-narrowing" } + +struct s { int x, y; }; +short offsets[1] = { + ((char*) &(((struct s*)16)->y) - (char *)16), // { dg-bogus "note" } +};