From patchwork Tue Oct 22 18:48:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1181599 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-511524-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="JuY6AHt7"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="A5+zEBaz"; 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 46yMwd0PVyz9sPV for ; Wed, 23 Oct 2019 05:48:47 +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=UdAz6BfyS0eHG42bYHIumZjNczRN8AxQdV2P7qjfzwEoCkdyoF miiGQaq9MGyBKzZrwSym/Q0zVI+ejA+5tmciHBrYwphUTvOzsFyzXBm8hsycWiGb yDlT4tEoV2capP1iK+5PtAdJEHj0GyqlF1WBxk0N5pyE8gw9rsTfpn0GA= 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=u/KVgSbEoF5lmKyXY66l60aOTn0=; b=JuY6AHt7blSSykxOaNqZ Sc3DOdTPrsDjozZmwp4E3wJZIPB0LsEHJI37E8mfcUJAkJGX25UWNJohFH2HDf5J sv4WQc6mAwjU9FxOQyb/nRTXWHYOzYsdLM1elN60qlxnzf7/2woBH7zawJ1AJ/+N yW/tv5Mp+iEOcVc3cZUY6iY= Received: (qmail 20341 invoked by alias); 22 Oct 2019 18:48:40 -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 20316 invoked by uid 89); 22 Oct 2019 18:48:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: aserp2120.oracle.com Received: from aserp2120.oracle.com (HELO aserp2120.oracle.com) (141.146.126.78) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 22 Oct 2019 18:48:37 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9MIiOnK091082; Tue, 22 Oct 2019 18:48:34 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=xxR1g3070y4c4g4byKZq5vSXBZb7iFsBO/3J8WJrRIs=; b=A5+zEBazXkSerm7K1znNP8gl82RIgmmhs+0r31fd7hdrHlcItOBEZCMyfVCgZNPgL6y4 /TBcKhoQj/FLTgsi8J+4P96Bnezpw9KjfiQrmDDj2IJg/RZHjS/vaFu+Ax6Sa36sXBEq dgabcSUcrXLee3RrH0b012umgkZRSJyoWo4OcZmj+5BSe+YG3U6yDjJLfYk6wC/MyXYZ /LN3esJEnO+IvE1W8wMzzF3s8klzqqPR8vl+kRvqPrIp3onpbzfTuUt+DQkGKTlxkI/X BSHrcPncNxdFwMzkPiodilLgrzdtzaHsYFP3K0QiiUN9sLRce7ux2oExskTmtI23mPCi ew== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2vqteprr5q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Oct 2019 18:48:34 +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 x9MIiOub070520; Tue, 22 Oct 2019 18:48:33 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2vsx2rkgwp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Oct 2019 18:48:33 +0000 Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x9MImWQc029911; Tue, 22 Oct 2019 18:48:33 GMT Received: from [192.168.1.4] (/82.55.223.173) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 22 Oct 2019 11:48:32 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Improve build_x_unary_op locations Message-ID: <9c05a55c-5389-1e91-8552-c177945008ed@oracle.com> Date: Tue, 22 Oct 2019 20:48:30 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi, at the moment I'm going through more typeck.c and typeck2.c functions: the below are some straightforward changes for build_x_unary_op (fwiw, the resulting locations are also consistent with clang) Tested x86_64-linux. Thanks, Paolo. //////////////////////////// /cp 2019-10-22 Paolo Carlini * typeck.c (build_x_unary_op): Use the location_t argument in three error_at. /testsuite 2019-10-22 Paolo Carlini * g++.dg/other/ptrmem8.C: Test locations too. * g++.dg/template/dtor6.C: Likewise. Index: cp/typeck.c =================================================================== --- cp/typeck.c (revision 277268) +++ cp/typeck.c (working copy) @@ -5829,10 +5831,10 @@ build_x_unary_op (location_t loc, enum tree_code c if (DECL_CONSTRUCTOR_P (fn) || DECL_DESTRUCTOR_P (fn)) { if (complain & tf_error) - error (DECL_CONSTRUCTOR_P (fn) - ? G_("taking address of constructor %qD") - : G_("taking address of destructor %qD"), - fn); + error_at (loc, DECL_CONSTRUCTOR_P (fn) + ? G_("taking address of constructor %qD") + : G_("taking address of destructor %qD"), + fn); return error_mark_node; } } @@ -5847,10 +5849,10 @@ build_x_unary_op (location_t loc, enum tree_code c { if (complain & tf_error) { - error ("invalid use of %qE to form a " - "pointer-to-member-function", xarg.get_value ()); + error_at (loc, "invalid use of %qE to form a " + "pointer-to-member-function", xarg.get_value ()); if (TREE_CODE (xarg) != OFFSET_REF) - inform (input_location, " a qualified-id is required"); + inform (loc, " a qualified-id is required"); } return error_mark_node; } @@ -5857,9 +5859,9 @@ build_x_unary_op (location_t loc, enum tree_code c else { if (complain & tf_error) - error ("parentheses around %qE cannot be used to form a" - " pointer-to-member-function", - xarg.get_value ()); + error_at (loc, "parentheses around %qE cannot be used to " + "form a pointer-to-member-function", + xarg.get_value ()); else return error_mark_node; PTRMEM_OK_P (xarg) = 1; Index: testsuite/g++.dg/other/ptrmem8.C =================================================================== --- testsuite/g++.dg/other/ptrmem8.C (revision 277268) +++ testsuite/g++.dg/other/ptrmem8.C (working copy) @@ -6,11 +6,11 @@ struct A {}; template void foo(void (A::* f)()) { A a; - &(a.*f); // { dg-error "invalid use of\[^\n\]*\\.\\*\[^\n\]*to form|qualified-id is required" } + &(a.*f); // { dg-error "3:invalid use of\[^\n\]*\\.\\*\[^\n\]*to form|qualified-id is required" } } template void bar(void (A::* f)()) { A *p; - &(p->*f); // { dg-error "invalid use of\[^\n\]*->\\*\[^\n\]*to form|qualified-id is required" } + &(p->*f); // { dg-error "3:invalid use of\[^\n\]*->\\*\[^\n\]*to form|qualified-id is required" } } Index: testsuite/g++.dg/template/dtor6.C =================================================================== --- testsuite/g++.dg/template/dtor6.C (revision 277268) +++ testsuite/g++.dg/template/dtor6.C (working copy) @@ -5,12 +5,12 @@ template struct A static int i; }; -template int A::i = { A::~A }; // { dg-error "non-static member function" } +template int A::i = { A::~A }; // { dg-error "36:invalid use of non-static member function" } template class A<0>; struct X { }; -int i1 = X::~X; // { dg-error "non-static member function" } -int i2 = &X::~X; // { dg-error "address of destructor" } -int i3 = &A<0>::~A; // { dg-error "address of destructor" } +int i1 = X::~X; // { dg-error "13:invalid use of non-static member function" } +int i2 = &X::~X; // { dg-error "10:taking address of destructor" } +int i3 = &A<0>::~A; // { dg-error "10:taking address of destructor" }