From patchwork Fri Sep 26 19:56:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 393945 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 272FF140188 for ; Sat, 27 Sep 2014 05:57:04 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=EZz6LecMMcvqJHKSdFkhYMkXwWiFoZqAC9LFkR15oHb0K/ KTser83f8HQUmeN55ic36mXmbZYPGfygKqad4Dj1XtUGCkffiO9v9k7DpWPoPxOs 4h004PFFkZ5TiViplNvMCrk6YmrpTAMOPScuS1Y4LRgRMONJGMja5uRXzoKzE= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=ERZFjknbArEwz+B2oUfHgezYJPY=; b=pNUzZNyNFPYz5ZjJZ7iy SXEcIrBLa8Pyl0VyBsD6Z1xuq6NGt8zgeOoGldBXgkGfvSSrWiTFOsLZq91CMrhI GEwpLsA5m/RE6ScXicymZm/yGJtU3ioTReVtbKwaHWCfeFbyriK3bhCZNzYB0Cec mDCw5eBDKTUW55c/667Y5zY= Received: (qmail 30462 invoked by alias); 26 Sep 2014 19:56:57 -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 30447 invoked by uid 89); 26 Sep 2014 19:56:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 26 Sep 2014 19:56:55 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8QJus0q028023 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 26 Sep 2014 15:56:54 -0400 Received: from [10.10.116.16] ([10.10.116.16]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8QJurEF006924 for ; Fri, 26 Sep 2014 15:56:53 -0400 Message-ID: <5425C501.3020403@redhat.com> Date: Fri, 26 Sep 2014 15:56:49 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for abi_tag on builtin mangling abbreviations We were ignoring abi_tags on the standard mangling abbreviations, such as Ss = std::string. This patch fixes that so that we append tags to the abbreviation, and add the result as a substitution. Tested x86_64-pc-linux-gnu, applying to trunk. commit 9e8c617e9135989151ba0a8d6f0d38c7913b2f23 Author: Jason Merrill Date: Mon Aug 11 10:13:37 2014 -0400 gcc/cp/ * mangle.c (is_std_substitution): Check for abi_tag. libiberty/ * cp-demangle.c (d_substitution): Handle abi tags on abbreviation. diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 9703d1c..4f94c19 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -512,6 +512,7 @@ find_substitution (tree node) const int size = vec_safe_length (G.substitutions); tree decl; tree type; + const char *abbr = NULL; if (DEBUG_MANGLE) fprintf (stderr, " ++ find_substitution (%s at %p)\n", @@ -530,13 +531,10 @@ find_substitution (tree node) if (decl && is_std_substitution (decl, SUBID_ALLOCATOR) && !CLASSTYPE_USE_TEMPLATE (TREE_TYPE (decl))) - { - write_string ("Sa"); - return 1; - } + abbr = "Sa"; /* Check for std::basic_string. */ - if (decl && is_std_substitution (decl, SUBID_BASIC_STRING)) + else if (decl && is_std_substitution (decl, SUBID_BASIC_STRING)) { if (TYPE_P (node)) { @@ -555,26 +553,20 @@ find_substitution (tree node) SUBID_CHAR_TRAITS) && is_std_substitution_char (TREE_VEC_ELT (args, 2), SUBID_ALLOCATOR)) - { - write_string ("Ss"); - return 1; - } + abbr = "Ss"; } } else /* Substitute for the template name only if this isn't a type. */ - { - write_string ("Sb"); - return 1; - } + abbr = "Sb"; } /* Check for basic_{i,o,io}stream. */ - if (TYPE_P (node) - && cp_type_quals (type) == TYPE_UNQUALIFIED - && CLASS_TYPE_P (type) - && CLASSTYPE_USE_TEMPLATE (type) - && CLASSTYPE_TEMPLATE_INFO (type) != NULL) + else if (TYPE_P (node) + && cp_type_quals (type) == TYPE_UNQUALIFIED + && CLASS_TYPE_P (type) + && CLASSTYPE_USE_TEMPLATE (type) + && CLASSTYPE_TEMPLATE_INFO (type) != NULL) { /* First, check for the template args > . */ @@ -587,35 +579,29 @@ find_substitution (tree node) { /* Got them. Is this basic_istream? */ if (is_std_substitution (decl, SUBID_BASIC_ISTREAM)) - { - write_string ("Si"); - return 1; - } + abbr = "Si"; /* Or basic_ostream? */ else if (is_std_substitution (decl, SUBID_BASIC_OSTREAM)) - { - write_string ("So"); - return 1; - } + abbr = "So"; /* Or basic_iostream? */ else if (is_std_substitution (decl, SUBID_BASIC_IOSTREAM)) - { - write_string ("Sd"); - return 1; - } + abbr = "Sd"; } } /* Check for namespace std. */ - if (decl && DECL_NAMESPACE_STD_P (decl)) + else if (decl && DECL_NAMESPACE_STD_P (decl)) { write_string ("St"); return 1; } + tree tags = NULL_TREE; + if (OVERLOAD_TYPE_P (node)) + tags = lookup_attribute ("abi_tag", TYPE_ATTRIBUTES (type)); /* Now check the list of available substitutions for this mangling operation. */ - for (i = 0; i < size; ++i) + if (!abbr || tags) for (i = 0; i < size; ++i) { tree candidate = (*G.substitutions)[i]; /* NODE is a matched to a candidate if it's the same decl node or @@ -630,8 +616,17 @@ find_substitution (tree node) } } - /* No substitution found. */ - return 0; + if (!abbr) + /* No substitution found. */ + return 0; + + write_string (abbr); + if (tags) + { + write_abi_tags (tags); + add_substitution (node); + } + return 1; } diff --git a/gcc/testsuite/g++.dg/abi/abi-tag9.C b/gcc/testsuite/g++.dg/abi/abi-tag9.C new file mode 100644 index 0000000..9ec78a9 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/abi-tag9.C @@ -0,0 +1,11 @@ +// { dg-final { scan-assembler "_Z1fSsB3fooS_" } } + +namespace std { + template struct char_traits {}; + template struct allocator {}; + template + struct __attribute ((abi_tag ("foo"))) basic_string { }; + typedef basic_string,allocator > string; +} + +void f(std::string,std::string) {} diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index 4ecdb1e..db3d679 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -3702,7 +3702,13 @@ d_substitution (struct d_info *di, int prefix) len = p->simple_len; } di->expansion += len; - return d_make_sub (di, s, len); + struct demangle_component *p = d_make_sub (di, s, len); + if (d_peek_char (di) == 'B') + { + p = d_abi_tags (di, p); + d_add_substitution (di, p); + } + return p; } } diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected index f8420ef..a030685 100644 --- a/libiberty/testsuite/demangle-expected +++ b/libiberty/testsuite/demangle-expected @@ -4353,3 +4353,6 @@ xxx _QueueNotification_QueueController__$4PPPPPPPM_A_INotice___Z _QueueNotification_QueueController__$4PPPPPPPM_A_INotice___Z _QueueNotification_QueueController__$4PPPPPPPM_A_INotice___Z +--format=gnu-v3 +_Z1fSsB3fooS_ +f(std::string[abi:foo], std::string[abi:foo])