diff options
Diffstat (limited to 'gcc-4.9/gcc/cp/mangle.c')
-rw-r--r-- | gcc-4.9/gcc/cp/mangle.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/gcc-4.9/gcc/cp/mangle.c b/gcc-4.9/gcc/cp/mangle.c index 251edb14d..da82dd6ac 100644 --- a/gcc-4.9/gcc/cp/mangle.c +++ b/gcc-4.9/gcc/cp/mangle.c @@ -180,7 +180,7 @@ static void write_unscoped_template_name (const tree); static void write_nested_name (const tree); static void write_prefix (const tree); static void write_template_prefix (const tree); -static void write_unqualified_name (const tree); +static void write_unqualified_name (tree); static void write_conversion_operator_name (const tree); static void write_source_name (tree); static void write_literal_operator_name (tree); @@ -1195,7 +1195,7 @@ write_unqualified_id (tree identifier) } static void -write_unqualified_name (const tree decl) +write_unqualified_name (tree decl) { MANGLE_TRACE_TREE ("unqualified-name", decl); @@ -1280,10 +1280,21 @@ write_unqualified_name (const tree decl) write_source_name (DECL_NAME (decl)); } - tree attrs = (TREE_CODE (decl) == TYPE_DECL - ? TYPE_ATTRIBUTES (TREE_TYPE (decl)) - : DECL_ATTRIBUTES (decl)); - write_abi_tags (lookup_attribute ("abi_tag", attrs)); + /* We use the ABI tags from the primary template, ignoring tags on any + specializations. This is necessary because C++ doesn't require a + specialization to be declared before it is used unless the use + requires a complete type, but we need to get the tags right on + incomplete types as well. */ + if (tree tmpl = most_general_template (decl)) + decl = DECL_TEMPLATE_RESULT (tmpl); + /* Don't crash on an unbound class template. */ + if (decl) + { + tree attrs = (TREE_CODE (decl) == TYPE_DECL + ? TYPE_ATTRIBUTES (TREE_TYPE (decl)) + : DECL_ATTRIBUTES (decl)); + write_abi_tags (lookup_attribute ("abi_tag", attrs)); + } } /* Write the unqualified-name for a conversion operator to TYPE. */ |