From patchwork Wed Jan 2 21:26:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1020088 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-493297-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="ksDG30Uq"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="AkrxxYZE"; 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 43VPJS1gDBz9s2P for ; Thu, 3 Jan 2019 08:27:03 +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=enVuLoILgfH6DV+6o/pSdJKK2GSdkf7L13vejfT2g6xE7aVNZc fyvz+wD+jn+5gkMSazI1y0HhOzpP3H8ZTfR2IvpN/cN6hpXaOKcqjpPCBrHSmEJk V7sOB5VsXGWgQeMKE2mdK0ygtJP5hCAtXK+PhnJvetoeKJacjI6gxRUK0= 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=yQ2IZ5sjLt7TeXFX60Hfkk48K64=; b=ksDG30Uql1ZHA6r46gpI XFFusHfqbbE3nzxbmk6E0G7Ny5I3EsfRXuBs4aC/PvUxVIzWXb6AAKYZBPHGoJGp Dm6kscJnKadCcRh/eeeFCt96fq1CkQ01/KV68qAtI9dyoXyt91hmrnVyMN585v3M gZE/Ux0PJZetvGmszHs1xFQ= Received: (qmail 92924 invoked by alias); 2 Jan 2019 21:26:56 -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 92915 invoked by uid 89); 2 Jan 2019 21:26:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*r:Gateway, H*Ad:D*oracle.com X-HELO: aserp2130.oracle.com Received: from aserp2130.oracle.com (HELO aserp2130.oracle.com) (141.146.126.79) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 02 Jan 2019 21:26:55 +0000 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x02LJOBu085062; Wed, 2 Jan 2019 21:26:52 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-2018-07-02; bh=j6RgGVb0aIiEC/7hfwLmGKMSUsYvSTGzPtk9OvdD3GA=; b=AkrxxYZE66ajO4k4eotUFL/FXlm62o8IIm5X9aMi5Y5Ex4P5dHOAEEN74UQ2OogfE3DX Cyigi/bVEq1npvCuSDPHgq7Wset6ALbSWI3GIduc5NiY8iPr2RUmj41npXrO7YrYyMeV IIvgBNkBpWSLdnXViknUnM5pYYs2tZ1ErCMrXqF8p5p+SGWsKvhnOqVE4VhVsWjHctwT pA8MoCL7eSW2AsWScjJHFtlp2lklun5OpcSi1BrIk7n8u4YEE8/pzpfsGs69S8H9WpBp 89GacycZg1VR/oBDkag7vOOmkIfupj72GII3pFe7k0cOkI5L9vE6sOcANszknc14eAfR kQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2pnxee49vw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 02 Jan 2019 21:26:52 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x02LQp8c026529 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 2 Jan 2019 21:26:51 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x02LQp1r020445; Wed, 2 Jan 2019 21:26:51 GMT Received: from [192.168.1.4] (/80.181.224.14) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 02 Jan 2019 13:26:50 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Improve handle_nodiscard_attribute location Message-ID: <7186eef2-74f6-c687-6328-e660a43660a7@oracle.com> Date: Wed, 2 Jan 2019 22:26:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, it seems we can easily improve this location by using DECL_SOURCE_LOCATION in the standard way. Tested x86_64-linux. Thanks, Paolo. ////////////////// /cp 2019-01-02 Paolo Carlini * tree.c (handle_nodiscard_attribute): Improve warning location. /testsuite 2019-01-02 Paolo Carlini * g++.dg/cpp1z/nodiscard3.C: Test locations too. Index: cp/tree.c =================================================================== --- cp/tree.c (revision 267507) +++ cp/tree.c (working copy) @@ -4372,8 +4372,9 @@ handle_nodiscard_attribute (tree *node, tree name, if (TREE_CODE (*node) == FUNCTION_DECL) { if (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (*node)))) - warning (OPT_Wattributes, "%qE attribute applied to %qD with void " - "return type", name, *node); + warning_at (DECL_SOURCE_LOCATION (*node), + OPT_Wattributes, "%qE attribute applied to %qD with void " + "return type", name, *node); } else if (OVERLOAD_TYPE_P (*node)) /* OK */; Index: testsuite/g++.dg/cpp1z/nodiscard3.C =================================================================== --- testsuite/g++.dg/cpp1z/nodiscard3.C (revision 267507) +++ testsuite/g++.dg/cpp1z/nodiscard3.C (working copy) @@ -13,8 +13,8 @@ typedef struct { char big[1024]; fnt fn; } C; struct [[nodiscard]] D { int i; D(); ~D(); }; WUR E check1 (void); -WUR void check2 (void); /* { dg-warning "nodiscard" } */ -WUR int foo; /* { dg-warning "nodiscard" } */ +WUR void check2 (void); /* { dg-warning "10:.nodiscard." } */ +WUR int foo; /* { dg-warning "9:.nodiscard." } */ int bar (void); WURAI E check3 (void) { return (E)bar (); } WUR A check4 (void);