From patchwork Thu Jan 12 17:24:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 135652 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id DD2D9B6EFE for ; Fri, 13 Jan 2012 04:25:24 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1326993926; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: References:In-Reply-To:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=F8etYh4lph5BvDpRYqPvslbcBbQ=; b=S0mW1wczczQY/yA cn7aRLFH9Eui0ZzMhcbf46UDFVsWDiR2HqVi2oJK/Y95PLx5WRWNGbIBkvBYVBSN D21iR342wgVAM3T1S2QoT50vMFg4CVgv5SZDZHb4OA6ZUgtXy12Eh6ncoPmj5DOl C0jnMyKVlZQRO5HK+5ZG8foh2+fM= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:References:In-Reply-To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=RO2ZOX1j6IV7bKcwW5rBRC2YmUKkkP8AH0o675zda/ajZ3YzcbXeBLNduVh2sU 4n1p6AzA0BPlA4F3+u68qhVpgoila5v8uUuOaUadJe9QwXl6pkecKeZQLTu1Ctaz lyRA9F3rbVphRzQkoKvyT2Mr0YjIh4Lc1bSUeXp985gCg=; Received: (qmail 18511 invoked by alias); 12 Jan 2012 17:25:19 -0000 Received: (qmail 18493 invoked by uid 22791); 12 Jan 2012 17:25:17 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 12 Jan 2012 17:24:56 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0CHOuIB032029 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 12 Jan 2012 12:24:56 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q0CHOtao024910 for ; Thu, 12 Jan 2012 12:24:55 -0500 Received: from [0.0.0.0] (ovpn-113-115.phx2.redhat.com [10.3.113.115]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id q0CHOs4i010378 for ; Thu, 12 Jan 2012 12:24:55 -0500 Message-ID: <4F0F1766.6000408@redhat.com> Date: Thu, 12 Jan 2012 12:24:54 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: gcc-patches List Subject: Re: C++/libiberty PATCH for many mangling fixes (6057, 48051, 50855, 51322 and more) References: <4F0769D4.2070802@redhat.com> In-Reply-To: <4F0769D4.2070802@redhat.com> 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 The earlier patch partially fixed 48051, but gave the wrong mangling for explicitly scoped names. Fixed by this patch. Tested x86_64-pc-linux-gnu, applying to trunk. commit 15b9202da53e0bd0c2be55f2f3a91c7de3484cbe Author: Jason Merrill Date: Sat Jan 7 06:15:05 2012 -0500 PR c++/48051 * mangle.c (write_expression): Mangle BASELINK scope if BASELINK_QUALIFIED_P. * search.c (adjust_result_of_qualified_name_lookup): Set BASELINK_QUALIFIED_P. * tree.c (cp_tree_equal) [BASELINK]: Compare BASELINK_QUALIFIED_P. * parser.c (cp_parser_postfix_dot_deref_expression): Don't call adjust_result_of_qualified_name_lookup for non-qualified names. diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 60b1870..5f2fa15 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -2500,7 +2500,9 @@ write_expression (tree expr) code = TREE_CODE (expr); } - if (code == BASELINK) + if (code == BASELINK + && (!type_unknown_p (expr) + || !BASELINK_QUALIFIED_P (expr))) { expr = BASELINK_FUNCTIONS (expr); code = TREE_CODE (expr); @@ -2583,10 +2585,20 @@ write_expression (tree expr) write_string ("at"); write_type (TREE_OPERAND (expr, 0)); } - else if (TREE_CODE (expr) == SCOPE_REF) + else if (code == SCOPE_REF + || code == BASELINK) { - tree scope = TREE_OPERAND (expr, 0); - tree member = TREE_OPERAND (expr, 1); + tree scope, member; + if (code == SCOPE_REF) + { + scope = TREE_OPERAND (expr, 0); + member = TREE_OPERAND (expr, 1); + } + else + { + scope = BINFO_TYPE (BASELINK_ACCESS_BINFO (expr)); + member = BASELINK_FUNCTIONS (expr); + } if (!abi_version_at_least (2) && DECL_P (member)) { diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index f9e1a13..4c85355 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -6045,9 +6045,9 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser, parser->qualifying_scope = NULL_TREE; parser->object_scope = NULL_TREE; } - if (scope && name && BASELINK_P (name)) + if (parser->scope && name && BASELINK_P (name)) adjust_result_of_qualified_name_lookup - (name, BINFO_TYPE (BASELINK_ACCESS_BINFO (name)), scope); + (name, parser->scope, scope); postfix_expression = finish_class_member_access_expr (postfix_expression, name, template_p, diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 45fdafc..e48dcec 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -1550,6 +1550,9 @@ adjust_result_of_qualified_name_lookup (tree decl, } } + if (BASELINK_P (decl)) + BASELINK_QUALIFIED_P (decl) = true; + return decl; } diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 8ef3e25..bf8bc05 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2320,6 +2320,7 @@ cp_tree_equal (tree t1, tree t2) case BASELINK: return (BASELINK_BINFO (t1) == BASELINK_BINFO (t2) && BASELINK_ACCESS_BINFO (t1) == BASELINK_ACCESS_BINFO (t2) + && BASELINK_QUALIFIED_P (t1) == BASELINK_QUALIFIED_P (t2) && cp_tree_equal (BASELINK_FUNCTIONS (t1), BASELINK_FUNCTIONS (t2))); diff --git a/gcc/testsuite/g++.dg/abi/mangle48.C b/gcc/testsuite/g++.dg/abi/mangle48.C index dc9c492..6c0e99c 100644 --- a/gcc/testsuite/g++.dg/abi/mangle48.C +++ b/gcc/testsuite/g++.dg/abi/mangle48.C @@ -13,6 +13,10 @@ struct A template auto f() -> decltype (b.f()); // { dg-final { scan-assembler "_ZN1A1gIiEEDTcldtptfpT1b1fIT_EEEv" } } template auto g() -> decltype (this->b.f()); + // { dg-final { scan-assembler "_ZN1A1hIiEEDTcldtdtdefpT1bsr1B1fIT_EEEv" } } + template auto h() -> decltype (b.B::f()); + // { dg-final { scan-assembler "_ZN1A1iIiEEDTcldtptfpT1bsr1B1fIT_EEEv" } } + template auto i() -> decltype (this->b.B::f()); }; int main() @@ -20,4 +24,6 @@ int main() A a; a.f(); a.g(); + a.h(); + a.i(); } diff --git a/gcc/testsuite/g++.dg/abi/mangle58.C b/gcc/testsuite/g++.dg/abi/mangle58.C index 14e5543..54b16f2 100644 --- a/gcc/testsuite/g++.dg/abi/mangle58.C +++ b/gcc/testsuite/g++.dg/abi/mangle58.C @@ -6,14 +6,20 @@ struct B { static int cmp2(char a, char b); // { dg-final { scan-assembler "_ZN1B1fIcEEvR1AIT_X4cmp1EE" } } template static void f (A &); + // { dg-final { scan-assembler "_ZN1B1gIcEEvR1AIT_XsrS_4cmp1EE" } } + template static void g (A &); // { dg-final { scan-assembler "_ZN1B1fIcEEvR1AIT_L_ZNS_4cmp2EccEE" } } template static void f (A &); + // { dg-final { scan-assembler "_ZN1B1gIcEEvR1AIT_L_ZNS_4cmp2EccEE" } } + template static void g (A &); }; void g() { A a; B::f(a); + B::g(a); A a2; B::f(a2); + B::g(a2); }