From patchwork Wed Mar 21 04:04:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 147906 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 5FA15B6EEF for ; Wed, 21 Mar 2012 15:04:49 +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=1332907490; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=55MwoOs r8NDc+BxS6wJiIsWKzPs=; b=f20lufymOmw1q4KP7SgbhiF8AOKjp5/SVWJKDpg N4l7KjpcgP3/xjRxsEgjqfLfsZyMlXP+qjZHWedE1uqrWRbxbw3meErGVbatcT59 MhS7Ik4vkeOOu5dA3vLrrn/5hQDXujixJpo8l0iGpNt+/h51AUZiidw58MRGIJS6 FcAA= 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:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=MCqeuhCMGfxFjJJJfF6P5ewP4nG03kaVQzj61MIgFBT6vnvkhw3NTdoRJxhRyS MFH4Fo6qc7cYm9tEoXn9E08lSWOSt5sVFv7S7YHMefbg6NISATwpTfIZWXeiB7wR ch0p0NIr8CxvX4eMQ/I2Zeo9zSTazxj+21IGmJPWrDb3M=; Received: (qmail 27280 invoked by alias); 21 Mar 2012 04:04:40 -0000 Received: (qmail 27264 invoked by uid 22791); 21 Mar 2012 04:04:37 -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; Wed, 21 Mar 2012 04:04:21 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q2L44Kj3029781 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 21 Mar 2012 00:04:20 -0400 Received: from [10.3.113.2] ([10.3.113.2]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q2L44JUN017687; Wed, 21 Mar 2012 00:04:20 -0400 Message-ID: <4F695342.5020208@redhat.com> Date: Wed, 21 Mar 2012 00:04:18 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1 MIME-Version: 1.0 To: gcc-patches List , Jakub Jelinek Subject: C++ PATCH to mangling of 'new auto' 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 GCC 4.7 adds mangling for new-expressions in a function signature, but I now notice it produces wrong mangling for 'new auto' in simple cases. This patch fixes it. Tested x86_64-pc-linux-gnu, applying to trunk. This also seems like it might be a candidate for 4.7.0. What do you think, Jakub? commit 96472bd7b10415d61a3d5e0d640825baf80eb576 Author: Jason Merrill Date: Wed Mar 7 19:28:34 2012 -0500 gcc/cp/ * mangle.c (write_type): Handle 'auto'. * init.c (build_new): Don't do auto deduction where it might affect template mangling. libiberty/ * cp-demangle.c (cplus_demangle_type): Handle 'auto'. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 1b2a1ef..bcb5ab7 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2774,7 +2774,9 @@ build_new (VEC(tree,gc) **placement, tree type, tree nelts, if (type == error_mark_node) return error_mark_node; - if (nelts == NULL_TREE && VEC_length (tree, *init) == 1) + if (nelts == NULL_TREE && VEC_length (tree, *init) == 1 + /* Don't do auto deduction where it might affect mangling. */ + && (!processing_template_decl || at_function_scope_p ())) { tree auto_node = type_uses_auto (type); if (auto_node) diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 5d6beb5..1536828 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -1933,6 +1933,13 @@ write_type (tree type) break; case TEMPLATE_TYPE_PARM: + if (is_auto (type)) + { + write_identifier ("Da"); + ++is_builtin_type; + break; + } + /* else fall through. */ case TEMPLATE_PARM_INDEX: write_template_param (type); break; diff --git a/gcc/testsuite/g++.dg/cpp0x/auto32.C b/gcc/testsuite/g++.dg/cpp0x/auto32.C new file mode 100644 index 0000000..2aad34e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto32.C @@ -0,0 +1,9 @@ +// { dg-do compile { target c++11 } } + +// { dg-final { scan-assembler "_Z1fIiEDTnw_Dapifp_EET_" } } +template auto f(T t) -> decltype (new auto(t)); + +int main() +{ + f(1); +} diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index 2b3d182..d95b56c 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -2270,6 +2270,11 @@ cplus_demangle_type (struct d_info *di) cplus_demangle_type (di), NULL); can_subst = 1; break; + + case 'a': + /* auto */ + ret = d_make_name (di, "auto", 4); + break; case 'f': /* 32-bit decimal floating point */ diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected index 036c481..d489692 100644 --- a/libiberty/testsuite/demangle-expected +++ b/libiberty/testsuite/demangle-expected @@ -4075,6 +4075,12 @@ decltype (new int{}) f1(int) --format=gnu-v3 _Zli2_wPKc operator"" _w(char const*) +--format=gnu-v3 +_Z1fIiEDTnw_Dapifp_EET_ +decltype (new auto({parm#1})) f(int) +--format=gnu-v3 +_Z1fIiERDaRKT_S1_ +auto& f(int const&, int) # # Ada (GNAT) tests. #