From patchwork Mon Aug 1 20:59:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 107820 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 B0B50B708F for ; Tue, 2 Aug 2011 06:59:47 +1000 (EST) Received: (qmail 13079 invoked by alias); 1 Aug 2011 20:59:44 -0000 Received: (qmail 13066 invoked by uid 22791); 1 Aug 2011 20:59:43 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS 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; Mon, 01 Aug 2011 20:59:15 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p71KxFH6022834 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 1 Aug 2011 16:59:15 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p71KxEdK026798 for ; Mon, 1 Aug 2011 16:59:15 -0400 Received: from [0.0.0.0] ([10.3.113.4]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p71KxDhD031983 for ; Mon, 1 Aug 2011 16:59:14 -0400 Message-ID: <4E3713A1.7050100@redhat.com> Date: Mon, 01 Aug 2011 16:59:13 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:5.0) Gecko/20110719 Thunderbird/5.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/49932 (ICE mangling decltype()::) 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 Needed to add mangling and demangling support for the recently added support for decltype as a nested-name-specifier. Tested x86_64-pc-linux-gnu, applying to trunk. commit fe8dd6eeab2b171504b87937021eb39a13828b77 Author: Jason Merrill Date: Mon Aug 1 16:16:20 2011 -0400 PR c++/49932 gcc/cp/ * mangle.c (write_prefix): Handle decltype. libiberty/ * cp-demangle.c (d_prefix): Handle decltype. diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 4a83c9a..eb3f144 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -952,6 +952,7 @@ write_nested_name (const tree decl) /* ::= ::= ::= + ::= ::= # empty ::= */ @@ -968,6 +969,12 @@ write_prefix (const tree node) MANGLE_TRACE_TREE ("prefix", node); + if (TREE_CODE (node) == DECLTYPE_TYPE) + { + write_type (node); + return; + } + if (find_substitution (node)) return; diff --git a/gcc/testsuite/g++.dg/abi/mangle49.C b/gcc/testsuite/g++.dg/abi/mangle49.C new file mode 100644 index 0000000..a258dc2 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/mangle49.C @@ -0,0 +1,22 @@ +// PR c++/49932 +// { dg-options "-std=c++0x -fabi-version=0" } + +template < typename T > +auto +f1( T x ) // ICE on here + -> typename decltype( x )::type {} + +template < typename T > +typename decltype( T() )::type +f2( T x ) {} // ICE on here + +struct S { typedef void type; }; + +void g() +{ + f1( S() ); + f2( S() ); +} + +// { dg-final { scan-assembler "_Z2f1I1SENDtfp_E4typeET_" } } +// { dg-final { scan-assembler "_Z2f2I1SENDTcvT__EE4typeES1_" } } diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index f41856b..d67a9e7 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -1280,6 +1280,7 @@ d_nested_name (struct d_info *di) /* ::= ::= ::= + ::= ::= ::= @@ -1308,10 +1309,19 @@ d_prefix (struct d_info *di) here. */ comb_type = DEMANGLE_COMPONENT_QUAL_NAME; - if (IS_DIGIT (peek) + if (peek == 'D') + { + char peek2 = d_peek_next_char (di); + if (peek2 == 'T' || peek2 == 't') + /* Decltype. */ + dc = cplus_demangle_type (di); + else + /* Destructor name. */ + dc = d_unqualified_name (di); + } + else if (IS_DIGIT (peek) || IS_LOWER (peek) || peek == 'C' - || peek == 'D' || peek == 'U' || peek == 'L') dc = d_unqualified_name (di); diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected index f9e8447..3737cfd 100644 --- a/libiberty/testsuite/demangle-expected +++ b/libiberty/testsuite/demangle-expected @@ -3901,6 +3901,10 @@ java resource java/util/iso4217.properties --format=gnu-v3 _Z3addIidEDTplfp_fp0_ET_T0_ decltype ({parm#1}+{parm#2}) add(int, double) +# decltype scope test +--format=gnu-v3 +_Z1fI1SENDtfp_E4typeET_ +decltype ({parm#1})::type f(S) # decltype/fn call test --format=gnu-v3 _Z4add3IidEDTclL_Z1gEfp_fp0_EET_T0_