From patchwork Thu Aug 8 09:41:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1143927 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-506489-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="W8EQGfCa"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="aieljcHs"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="5pi2PLoC"; 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 4643Kd5GrCz9sDB for ; Thu, 8 Aug 2019 19:41:23 +1000 (AEST) 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=PIEuzIUIvokGkmyzhh5NZ+vKCd+DQNwylwQ30+cVpO+hArZI3S 8gN8DLknx+6UbqM7wyXl9DW3wVLQtSEnb8yqYXrEPbNgTplyUVCdQZAuCg4ozSCd n7F/LVCn8UZ6S999e5L7iWj6OKFcfL/LSUE4XIEs5ivuxgUD5Po6yvejc= 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=H7LJdvHqIDjBcmcLJVMLtQZAIgs=; b=W8EQGfCaNH8Bv/GOuuKu +eH0zj6XGBQ7xI3QRNG3mbmyQb2ATo75sWcwnreUqyM+pP6Xae+3/Vz49VZ33EOF 1Kjx4b+4/Ob8mb8MXnqnVqw477Kyakxz1KbjPbCAoq8MLKbeWhn7Rtg/KvyJ1Dsd TBRoH9QuIhul3Pi4GMsVu6U= Received: (qmail 113997 invoked by alias); 8 Aug 2019 09:41:15 -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 113982 invoked by uid 89); 8 Aug 2019 09:41:15 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.4 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=infrastructure 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; Thu, 08 Aug 2019 09:41:13 +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 x789ep1L050626; Thu, 8 Aug 2019 09:41:12 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=ewPlhse8NiCO2stcYZC3ohTS2eY0MUGwKXITuJNGOis=; b=aieljcHsPTGpu9X0liSW56COQsMn1fzDdivCubovIcNRxWd6lP0F5nMGnLdwkmuvN1Tp BrUaTR+Ibch87srxiqKY98IyhrCxJHINofWfAdpGHDeg26o0wcY5HgYKVOHf1JeOBbjn fQVgl5e0nqhnjcaAnjw8Afik4Eiftylg5JXMDDUQD9omRaGZo4ne5pzflNcKjJtyFG+v vXNs/rK+AJH7C/+AEcrExuHoI/4x7UeBqMcCYmmhW42Atg9chCnj7DGt24Icv5yiGptV m713ZYFylTCr5j/uk8al9wiMR2z8S9T+FYVIaF1DQK08PonivAjgSHXeNH3R5ScGDp/s 9A== 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=ewPlhse8NiCO2stcYZC3ohTS2eY0MUGwKXITuJNGOis=; b=5pi2PLoC6bgohILk9XkRDX/EUfi7N9kuNJtvbNpu8nmTBirft635M6vVxXMYPSVERfAz q56COTZ8zmYaGdhBJ/Zxn0ghZIHnjhAFfFEVQnkVAtfL4m+ZRO2JSxVRj00A2SHhLmPT SMyipmNlWi8b2B/OFExXahLj5WPyYJpNCHvw/GdEGerxj3wK+nUZkzS5oFdNmcbp2UeK +IvR5Zavc/74Q1kzsMH6LmELd+HeddBza72OwrkP524IKgUygUqL/hCMA0kH3a2/drNi JGYKiI0lZmh59yA9JuhorPgcmwK16L0Q6yFuBW/TOpQxCCEGP3U9SUGdDwQxwCyMxLh4 Yw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2u52wrhhe8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Aug 2019 09:41:11 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x789cD2o086582; Thu, 8 Aug 2019 09:41:11 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2u763k2593-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Aug 2019 09:41:11 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x789f85H010053; Thu, 8 Aug 2019 09:41:08 GMT Received: from [192.168.1.4] (/95.247.231.7) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 08 Aug 2019 02:41:07 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] More grokdeclarator locations fixes Message-ID: <69d03ed6-77cd-522b-3d8c-f87fd0d25db3@oracle.com> Date: Thu, 8 Aug 2019 11:41:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, these are all more or less straightforward, exploit the existing infrastructure. Nits: the first change also removes an 'a' in the wording because all the other error messages - a few - mentioning class or namespace don't have it; the fixes using EXPR_LOCATION also change %qD to %qE because we are dealing with BIT_NOT_EXPRs. Thanks, Paolo. /////////////////// /cp 2019-08-08 Paolo Carlini * decl.c (grokdeclarator): Use id_loc and EXPR_LOCATION in a few error messages. /testsuite 2019-08-08 Paolo Carlini * g++.dg/cpp0x/enum20.C: Test location(s) too. * g++.dg/other/friend3.C: Likewise. * g++.dg/parse/dtor5.C: Likewise. * g++.dg/parse/friend7.C: Likewise. * g++.dg/template/error22.C: Likewise. * g++.old-deja/g++.brendan/err-msg5.C: Likewise. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 274195) +++ cp/decl.c (working copy) @@ -10579,7 +10579,8 @@ grokdeclarator (const cp_declarator *declarator, ctype = qualifying_scope; if (!MAYBE_CLASS_TYPE_P (ctype)) { - error ("%q#T is not a class or a namespace", ctype); + error_at (id_declarator->id_loc, + "%q#T is not a class or namespace", ctype); ctype = NULL_TREE; } else if (innermost_code != cdk_function @@ -10601,13 +10602,15 @@ grokdeclarator (const cp_declarator *declarator, { if (innermost_code != cdk_function) { - error ("declaration of %qD as non-function", decl); + error_at (EXPR_LOCATION (decl), + "declaration of %qE as non-function", decl); return error_mark_node; } else if (!qualifying_scope && !(current_class_type && at_class_scope_p ())) { - error ("declaration of %qD as non-member", decl); + error_at (EXPR_LOCATION (decl), + "declaration of %qE as non-member", decl); return error_mark_node; } @@ -12510,7 +12513,7 @@ grokdeclarator (const cp_declarator *declarator, else if (in_namespace && !friendp) { /* Something like struct S { int N::j; }; */ - error ("invalid use of %<::%>"); + error_at (id_loc, "invalid use of %<::%>"); return error_mark_node; } else if (FUNC_OR_METHOD_TYPE_P (type) && unqualified_id) @@ -12565,15 +12568,15 @@ grokdeclarator (const cp_declarator *declarator, if (!ctype) { gcc_assert (friendp); - error ("expected qualified name in friend declaration " - "for destructor %qD", uqname); + error_at (id_loc, "expected qualified name in friend " + "declaration for destructor %qD", uqname); return error_mark_node; } if (!check_dtor_name (ctype, TREE_OPERAND (uqname, 0))) { - error ("declaration of %qD as member of %qT", - uqname, ctype); + error_at (id_loc, "declaration of %qD as member of %qT", + uqname, ctype); return error_mark_node; } if (concept_p) Index: testsuite/g++.dg/cpp0x/enum20.C =================================================================== --- testsuite/g++.dg/cpp0x/enum20.C (revision 274195) +++ testsuite/g++.dg/cpp0x/enum20.C (working copy) @@ -2,4 +2,4 @@ // { dg-do compile { target c++11 } } enum A { }; -void A::f() { } // { dg-error "not a class" } +void A::f() { } // { dg-error "6:.enum A. is not a class" } Index: testsuite/g++.dg/other/friend3.C =================================================================== --- testsuite/g++.dg/other/friend3.C (revision 274195) +++ testsuite/g++.dg/other/friend3.C (working copy) @@ -4,10 +4,10 @@ struct A { - friend ~A(); // { dg-error "qualified name" } + friend ~A(); // { dg-error "10:expected qualified name" } }; struct B { - friend ~A(); // { dg-error "qualified name" } + friend ~A(); // { dg-error "10:expected qualified name" } }; Index: testsuite/g++.dg/parse/dtor5.C =================================================================== --- testsuite/g++.dg/parse/dtor5.C (revision 274195) +++ testsuite/g++.dg/parse/dtor5.C (working copy) @@ -1,12 +1,12 @@ // PR c++/19732 struct A; -typedef int ~A; // { dg-error "non-function" } +typedef int ~A; // { dg-error "13:declaration of .~ A. as non-function" } struct B { - ~A(); // { dg-error "" } - typedef int ~A; // { dg-error "non-function" } + ~A(); // { dg-error "3:declaration of .~A. as member of .B." } + typedef int ~A; // { dg-error "15:declaration of .~ A. as non-function" } void f() { - extern ~B(); // { dg-error "non-member" } + extern ~B(); // { dg-error "12:declaration of .~ B. as non-member" } } }; -void ~A(); // { dg-error "non-member" } +void ~A(); // { dg-error "6:declaration of .~ A. as non-member" } Index: testsuite/g++.dg/parse/friend7.C =================================================================== --- testsuite/g++.dg/parse/friend7.C (revision 274195) +++ testsuite/g++.dg/parse/friend7.C (working copy) @@ -19,7 +19,8 @@ struct B struct C { friend int C (); - friend int ~C (); // { dg-error "return type|in friend decl" } + friend int ~C (); // { dg-error "10:return type" } + // { dg-error "14:expected qualified name in friend decl" "" { target *-*-* } .-1 } friend int C (const C &); }; @@ -26,7 +27,8 @@ struct C struct D { friend int D () {} - friend int ~D () {} // { dg-error "return type|in friend decl" } + friend int ~D () {} // { dg-error "10:return type" } + // { dg-error "14:expected qualified name in friend decl" "" { target *-*-* } .-1 } friend int D (const D &) {} }; Index: testsuite/g++.dg/template/error22.C =================================================================== --- testsuite/g++.dg/template/error22.C (revision 274195) +++ testsuite/g++.dg/template/error22.C (working copy) @@ -3,7 +3,7 @@ struct A { template struct B {}; - void ::foo(); // { dg-error "invalid use" } + void ::foo(); // { dg-error "10:invalid use" } B<&A::foo> b; // { dg-error "incomplete type|template argument" } }; Index: testsuite/g++.old-deja/g++.brendan/err-msg5.C =================================================================== --- testsuite/g++.old-deja/g++.brendan/err-msg5.C (revision 274195) +++ testsuite/g++.old-deja/g++.brendan/err-msg5.C (working copy) @@ -1,4 +1,4 @@ // { dg-do assemble } // GROUPS passed error-messages class foo {}; -~foo () {}// { dg-error "" } destructors must be member functions.* +~foo () {}// { dg-error "1:declaration of .~ foo. as non-member" } destructors must be member functions.*