From patchwork Tue Jun 4 14:31:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1109950 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-502303-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="FufIaBeA"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="CTDC6UC7"; 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 45JDsG6LDSz9s3l for ; Wed, 5 Jun 2019 00:32:16 +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=myUkwiGlCYYF7Ie4H0LNdja//09douZtBOUzsWFAr2bmRaF8TZ 3/CU72g3w6nDAT6hvbXh1Ykuhab1iNVG84sceLl30o8DQupjdJq6PbUWtXVX/fca Qqau5OlsGB+oBXR1RqPjHnvx2A5vddD8eNt3E5ekKNl4flF8VraNvUhiw= 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=Da4uEMy133n160rRnNbdE+32VBE=; b=FufIaBeAwwid2qYCobuA uO83r1+pZUruJDWF0hx3KILPMlrR/BKpsajWlS5pTPemcC8P0eFl6LRVnj+qvSsJ CFpqbR7y/Bs9QGHq/QONe7rmfzNHg6qaUGVvb9rZaJdGzBH6jxVRVqzMJUEmzT7A uhG0EYp0GCXNnllY4yfltLs= Received: (qmail 106795 invoked by alias); 4 Jun 2019 14:32:08 -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 106787 invoked by uid 89); 4 Jun 2019 14:32:08 -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=input_location X-HELO: userp2130.oracle.com Received: from userp2130.oracle.com (HELO userp2130.oracle.com) (156.151.31.86) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 04 Jun 2019 14:32:06 +0000 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x54EJUTq071531; Tue, 4 Jun 2019 14:32:03 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=hk4vo5JbkuRkztlYIjSgijzvoGAxfJpzNcoVk8LMR7E=; b=CTDC6UC7MA4LjjJ5y54jFuawY1eBif0pyzJ+f6aFU8oHoO5qUQQXjz3idSCTC5D6zjGF y77VC0SFxeVi9NM/Bn0hKedmQ839hBsLVJSKdTsaS/pQSNriHDtfW9k7+S3+zxI7ycco hGjl8yuCL+mGgg2blPkdmYWd6Z2KPCfwEP+1CIf+E5zismRZjRV7XSeTBz6LdyZXzv1t fl8DJp8qN/pK51mUFdKi674WqIHQ+Cx7ZWpUJKwLy62y1sOkQX8/+2YUF5qogMzWgU4/ a9Sb1gze3I4R+CQaqUSy1NgOXE9rzGUqFmk7MzI41gxUW0c0jBhCTxWleFzw1+7Ymmlv yQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2sugstdfen-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 04 Jun 2019 14:32:03 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x54EVoCM086629; Tue, 4 Jun 2019 14:32:02 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2swnghcmkr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 04 Jun 2019 14:32:02 +0000 Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x54EW03M031824; Tue, 4 Jun 2019 14:32:01 GMT Received: from [192.168.1.4] (/79.42.221.26) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 04 Jun 2019 07:31:59 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Use declarator->id_loc in three additional places Message-ID: <59ac4b84-5400-8c6f-7666-95e5e900faf6@oracle.com> Date: Tue, 4 Jun 2019 16:31:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, tested x86_64-linux, as usual. Thanks, Paolo. /////////////////////// /cp 2019-06-04 Paolo Carlini * decl.c (grokdeclarator): Use declarator->id_loc in three additional places. /testsuite 2019-06-04 Paolo Carlini * g++.dg/concepts/pr60573.C: Test locations too. * g++.dg/cpp0x/deleted13.C: Likewise. * g++.dg/other/friend4.C: Likewise. * g++.dg/other/friend5.C: Likewise. * g++.dg/other/friend7.C: Likewise. * g++.dg/parse/error29.C: Likewise. * g++.dg/parse/friend7.C: Likewise. * g++.dg/parse/qualified4.C: Likewise. * g++.dg/template/crash96.C Likewise. * g++.old-deja/g++.brendan/crash22.C Likewise. * g++.old-deja/g++.brendan/crash23.C Likewise. * g++.old-deja/g++.law/visibility10.C Likewise. * g++.old-deja/g++.other/decl5.C: Likewise. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 271899) +++ cp/decl.c (working copy) @@ -11873,6 +11873,8 @@ grokdeclarator (const cp_declarator *declarator, unqualified_id = dname; } + location_t loc = declarator ? declarator->id_loc : input_location; + /* If TYPE is a FUNCTION_TYPE, but the function name was explicitly qualified with a class-name, turn it into a METHOD_TYPE, unless we know that the function is static. We take advantage of this @@ -11893,13 +11895,12 @@ grokdeclarator (const cp_declarator *declarator, { if (friendp) { - permerror (input_location, "member functions are implicitly " - "friends of their class"); + permerror (loc, "member functions are implicitly " + "friends of their class"); friendp = 0; } else - permerror (declarator->id_loc, - "extra qualification %<%T::%> on member %qs", + permerror (loc, "extra qualification %<%T::%> on member %qs", ctype, name); } else if (/* If the qualifying type is already complete, then we @@ -11928,19 +11929,19 @@ grokdeclarator (const cp_declarator *declarator, if (current_class_type && (!friendp || funcdef_flag || initialized)) { - error (funcdef_flag || initialized - ? G_("cannot define member function %<%T::%s%> " - "within %qT") - : G_("cannot declare member function %<%T::%s%> " - "within %qT"), - ctype, name, current_class_type); + error_at (loc, funcdef_flag || initialized + ? G_("cannot define member function %<%T::%s%> " + "within %qT") + : G_("cannot declare member function %<%T::%s%> " + "within %qT"), + ctype, name, current_class_type); return error_mark_node; } } else if (typedef_p && current_class_type) { - error ("cannot declare member %<%T::%s%> within %qT", - ctype, name, current_class_type); + error_at (loc, "cannot declare member %<%T::%s%> within %qT", + ctype, name, current_class_type); return error_mark_node; } } @@ -12053,8 +12054,6 @@ grokdeclarator (const cp_declarator *declarator, } } - location_t loc = declarator ? declarator->id_loc : input_location; - /* If this is declaring a typedef name, return a TYPE_DECL. */ if (typedef_p && decl_context != TYPENAME) { Index: testsuite/g++.dg/concepts/pr60573.C =================================================================== --- testsuite/g++.dg/concepts/pr60573.C (revision 271899) +++ testsuite/g++.dg/concepts/pr60573.C (working copy) @@ -9,7 +9,7 @@ struct A void foo(auto); }; - void B::foo(auto) {} // { dg-error "cannot define" } + void B::foo(auto) {} // { dg-error "8:cannot define" } struct X { @@ -21,8 +21,8 @@ struct A }; }; - void Y::Z::foo(auto) {} // { dg-error "cannot define" } + void Y::Z::foo(auto) {} // { dg-error "10:cannot define" } }; - void X::Y::Z::foo(auto) {} // { dg-error "cannot define" } + void X::Y::Z::foo(auto) {} // { dg-error "8:cannot define" } }; Index: testsuite/g++.dg/cpp0x/deleted13.C =================================================================== --- testsuite/g++.dg/cpp0x/deleted13.C (revision 271899) +++ testsuite/g++.dg/cpp0x/deleted13.C (working copy) @@ -8,5 +8,5 @@ struct A struct B { - template friend void A::foo() = delete; // { dg-error "" } + template friend void A::foo() = delete; // { dg-error "34:cannot define" } }; Index: testsuite/g++.dg/other/friend4.C =================================================================== --- testsuite/g++.dg/other/friend4.C (revision 271899) +++ testsuite/g++.dg/other/friend4.C (working copy) @@ -3,6 +3,6 @@ struct A { - friend void A::foo(); // { dg-error "implicitly friends" } - friend A::~A(); // { dg-error "implicitly friends" } + friend void A::foo(); // { dg-error "15:member functions are implicitly friends" } + friend A::~A(); // { dg-error "10:member functions are implicitly friends" } }; Index: testsuite/g++.dg/other/friend5.C =================================================================== --- testsuite/g++.dg/other/friend5.C (revision 271899) +++ testsuite/g++.dg/other/friend5.C (working copy) @@ -5,5 +5,5 @@ struct A { - friend A::~A() {} /* { dg-error "implicitly friends of their class" } */ + friend A::~A() {} /* { dg-error "10:member functions are implicitly friends of their class" } */ }; Index: testsuite/g++.dg/other/friend7.C =================================================================== --- testsuite/g++.dg/other/friend7.C (revision 271899) +++ testsuite/g++.dg/other/friend7.C (working copy) @@ -5,5 +5,5 @@ struct A { - friend A::~A() {} // { dg-error "implicitly friends of their class" } + friend A::~A() {} // { dg-error "10:member functions are implicitly friends of their class" } }; Index: testsuite/g++.dg/parse/error29.C =================================================================== --- testsuite/g++.dg/parse/error29.C (revision 271899) +++ testsuite/g++.dg/parse/error29.C (working copy) @@ -7,7 +7,7 @@ struct A { void operator delete(void *); }; struct B { - friend void A::foo() {} // { dg-error "22:cannot define member function 'A::foo' within 'B'" } - friend void A::operator delete(void*) {} // { dg-error "39:cannot define member function 'A::operator delete' within 'B'" } - friend A::A() {} // { dg-error "15:cannot define member function 'A::A' within 'B'" } + friend void A::foo() {} // { dg-error "15:cannot define member function 'A::foo' within 'B'" } + friend void A::operator delete(void*) {} // { dg-error "15:cannot define member function 'A::operator delete' within 'B'" } + friend A::A() {} // { dg-error "10:cannot define member function 'A::A' within 'B'" } }; Index: testsuite/g++.dg/parse/friend7.C =================================================================== --- testsuite/g++.dg/parse/friend7.C (revision 271899) +++ testsuite/g++.dg/parse/friend7.C (working copy) @@ -32,7 +32,7 @@ struct D struct E { - friend A::A () {} // { dg-error "cannot define member" } - friend A::~A () {} // { dg-error "cannot define member" } - friend A::A (const A &) {} // { dg-error "cannot define member" } + friend A::A () {} // { dg-error "10:cannot define member" } + friend A::~A () {} // { dg-error "10:cannot define member" } + friend A::A (const A &) {} // { dg-error "10:cannot define member" } }; Index: testsuite/g++.dg/parse/qualified4.C =================================================================== --- testsuite/g++.dg/parse/qualified4.C (revision 271899) +++ testsuite/g++.dg/parse/qualified4.C (working copy) @@ -2,5 +2,5 @@ // { dg-options "" } struct X { - void X::bar() {} // { dg-error "" } + void X::bar() {} // { dg-error "8:extra qualification" } }; Index: testsuite/g++.dg/template/crash96.C =================================================================== --- testsuite/g++.dg/template/crash96.C (revision 271899) +++ testsuite/g++.dg/template/crash96.C (working copy) @@ -2,5 +2,5 @@ template struct A { - template template void A::foo() {} // { dg-error "extra qualification" } + template template void A::foo() {} // { dg-error "36:extra qualification" } }; Index: testsuite/g++.old-deja/g++.brendan/crash22.C =================================================================== --- testsuite/g++.old-deja/g++.brendan/crash22.C (revision 271899) +++ testsuite/g++.old-deja/g++.brendan/crash22.C (working copy) @@ -6,6 +6,6 @@ struct A { }; struct B { - void A::a1(); // this used to die in chainon(), now grokdeclarator should// { dg-error "" } cannot declare.* - void A::a2(); // should be fixed by the 930629 change.// { dg-error "" } cannot declare.* + void A::a1(); // this used to die in chainon(), now grokdeclarator should// { dg-error "10:cannot declare" } cannot declare.* + void A::a2(); // should be fixed by the 930629 change.// { dg-error "10:cannot declare" } cannot declare.* }; Index: testsuite/g++.old-deja/g++.brendan/crash23.C =================================================================== --- testsuite/g++.old-deja/g++.brendan/crash23.C (revision 271899) +++ testsuite/g++.old-deja/g++.brendan/crash23.C (working copy) @@ -10,6 +10,6 @@ class A void f (); void g (int); }; - void B::f () {}// { dg-error "" } .* - void B::g (int val) {}// { dg-error "" } .* + void B::f () {}// { dg-error "8:cannot define" } .* + void B::g (int val) {}// { dg-error "8:cannot define" } .* }; Index: testsuite/g++.old-deja/g++.law/visibility10.C =================================================================== --- testsuite/g++.old-deja/g++.law/visibility10.C (revision 271899) +++ testsuite/g++.old-deja/g++.law/visibility10.C (working copy) @@ -10,7 +10,7 @@ class base { }; class deriv : public base { - void base :: f1();// { dg-error "" } .* + void base :: f1();// { dg-error "8:cannot declare" } .* }; int main () Index: testsuite/g++.old-deja/g++.other/decl5.C =================================================================== --- testsuite/g++.old-deja/g++.other/decl5.C (revision 271899) +++ testsuite/g++.old-deja/g++.other/decl5.C (working copy) @@ -35,7 +35,7 @@ struct B { struct ::Q { // { dg-error "global qual" } ::Q not a member of B int m; }; - int A::fn() { // { dg-error "cannot define member" } A::fn not a member of B + int A::fn() { // { dg-error "7:cannot define member" } A::fn not a member of B return 0; } void fn(struct ::Q &);