From patchwork Thu Jan 10 14:24:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1022953 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-493779-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="yW69EMx0"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="obD8O9vr"; 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 43b7Yq2Js8z9sCs for ; Fri, 11 Jan 2019 01:25:02 +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=smpmeDmBxILCsP8jW9nPDBPIw2ds185pMEGBSEqDozVCvpFKyQ xDjgCrXwaVwfMun4zHDlAyepJJQrsufDKJHs3MrosqNJtpt8cVxT1nLC/fs5kmcw QetZ116e0fGsEAZe52zOVRlGNNHDJKlOuqmU2GlN/I/P3y2Dhp7A3cUDI= 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=3wcN+J5DW0/0C2Pv/LRky2RUlo8=; b=yW69EMx0SXTqMRSFSPzW jANkXnL1xCDRfZfyDVt15ozOIELigcGCxzUydxzYhXIVE1P3jVTGz77KiJS6rAPg Z3SYkGoDtdmhBwF+ixaO9QT1TU9I/Di3gCuNz4Ht5h5TrmjWJeSAUHUBZpHFroSl Jy3/X8vu1sXR+B6I2WNxjjE= Received: (qmail 104191 invoked by alias); 10 Jan 2019 14:24:55 -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 104179 invoked by uid 89); 10 Jan 2019 14:24:54 -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=hanging, dgpruneoutput, Volker, dg-prune-output 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; Thu, 10 Jan 2019 14:24:52 +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 x0AEOK5v036510; Thu, 10 Jan 2019 14:24:50 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=mCK7YAVvaxxul+kO72xP8Pn8Quu1Bj0JDvps7nj6A1g=; b=obD8O9vrX8kp3a90gQEoOt0DJ6ZFeFWvnpuXPQdPsZs+zp2MSow9s1HjyS6VjMKPu3wc wSJhfVdTzVjJJuxbW72xn/CY97ddW323LHlzCik3yvFFLSSCbf6/W12SjVAYenPLw5Rl 9WELTVn7LsTfaqujYIIQTLXWrfDLkGbBROMy9TfuYGk47RI8CADIyAzw1ii/Ik+eLrO0 9kLcgHVfYvaVAXHeI9Ge8Z62ijRxIIsK50ptdfVAJMG3aaJXisc9gmrwec+a1k3r9Wg1 PfQcaijMmJ46H1sJz66DQsA+VHpSpenkAztuFgI8Hysesemt+e1lheXrtcNQ5CeNovBh +A== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2ptj3e7ncy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jan 2019 14:24:50 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x0AEOnlf022981 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jan 2019 14:24:50 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x0AEOn3F004643; Thu, 10 Jan 2019 14:24:49 GMT Received: from [192.168.1.4] (/80.181.224.14) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 10 Jan 2019 06:24:49 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Fix three additional locations Message-ID: <93fcd7fe-af75-953a-2f44-61f857df3376@oracle.com> Date: Thu, 10 Jan 2019 15:24:46 +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 again, this one is also matter of consistency with, say, the precise location that we use for the error message at the beginning of check_methods. Indeed, the sequence of error messages of g++.dg/inherit/pure1.C reflect that. Tested x86_64-linux. Thanks, Paolo. PS: minor issues anyway, but I'm almost done with these low hanging fruits which I'm proposing to fix for 9 too.... ///////////////////// /cp 2019-01-10 Paolo Carlini * decl.c (cp_finish_decl): Improve error location. (grokfield): Likewise, improve two locations. /testsuite 2019-01-10 Paolo Carlini * g++.dg/g++.dg/cpp0x/pr62101.C: Test locations too. * g++.dg/inherit/pure1.C: Likewise. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 267807) +++ cp/decl.c (working copy) @@ -7292,7 +7293,9 @@ cp_finish_decl (tree decl, tree init, bool init_co synthesize_method (decl); } else - error ("function %q#D is initialized like a variable", decl); + error_at (DECL_SOURCE_LOCATION (decl), + "function %q#D is initialized like a variable", + decl); } /* else no initialization required. */ } Index: cp/decl2.c =================================================================== --- cp/decl2.c (revision 267807) +++ cp/decl2.c (working copy) @@ -925,11 +925,13 @@ grokfield (const cp_declarator *declarator, { gcc_assert (TREE_CODE (TREE_TYPE (value)) == FUNCTION_TYPE); if (friendp) - error ("initializer specified for friend function %qD", - value); + error_at (DECL_SOURCE_LOCATION (value), + "initializer specified for friend function %qD", + value); else - error ("initializer specified for static member function %qD", - value); + error_at (DECL_SOURCE_LOCATION (value), + "initializer specified for static member " + "function %qD", value); } } else if (TREE_CODE (value) == FIELD_DECL) Index: testsuite/g++.dg/cpp0x/pr62101.C =================================================================== --- testsuite/g++.dg/cpp0x/pr62101.C (revision 267807) +++ testsuite/g++.dg/cpp0x/pr62101.C (working copy) @@ -3,7 +3,7 @@ struct X { - friend void g(X, int) = 0; // { dg-error "initializer specified for friend function" } + friend void g(X, int) = 0; // { dg-error "15:initializer specified for friend function" } friend void g(X, int) = default; // { dg-error "cannot be defaulted" } // { dg-prune-output "note" } friend void f(X, int) = delete; Index: testsuite/g++.dg/inherit/pure1.C =================================================================== --- testsuite/g++.dg/inherit/pure1.C (revision 267807) +++ testsuite/g++.dg/inherit/pure1.C (working copy) @@ -2,13 +2,13 @@ // Origin: Volker Reichelt // { dg-do compile } -void foo0() = 0; // { dg-error "like a variable" } +void foo0() = 0; // { dg-error "6:function .void foo0\\(\\). is initialized like a variable" } virtual void foo1() = 0; // { dg-error "1:'virtual' outside class" } -// { dg-error "like a variable" "" { target *-*-* } .-1 } +// { dg-error "14:function .void foo1\\(\\). is initialized like a variable" "" { target *-*-* } .-1 } struct A { - void foo2() = 0; // { dg-error "non-virtual" } - static void foo3() = 0; // { dg-error "static member" } + void foo2() = 0; // { dg-error "8:initializer specified for non-virtual method" } + static void foo3() = 0; // { dg-error "15:initializer specified for static member function" } virtual static void foo4() = 0; // { dg-error "both 'virtual' and 'static'" } virtual void foo5() = 0; // { dg-error "base class" } }; @@ -15,5 +15,6 @@ struct A struct B : A { - static void foo5() = 0; // { dg-error "static member|declared" } + static void foo5() = 0; // { dg-error "15:initializer specified for static member function" } +// { dg-error "declared" "" { target *-*-* } .-1 } };