Commit 884929e2 by Jason Merrill Committed by Jason Merrill

mangle.c (get_abi_tags): New.

	* mangle.c (get_abi_tags): New.

	(find_substitution, write_unqualified_name, write_abi_tags)
	(maybe_check_abi_tags): Use it.

From-SVN: r238965
parent 352b8bab
2016-08-01 Jason Merrill <jason@redhat.com> 2016-08-01 Jason Merrill <jason@redhat.com>
* mangle.c (get_abi_tags): New.
(find_substitution, write_unqualified_name, write_abi_tags)
(maybe_check_abi_tags): Use it.
* mangle.c (mangle_decl): Fix mangled name change warning. * mangle.c (mangle_decl): Fix mangled name change warning.
PR c++/72766 PR c++/72766
......
...@@ -447,6 +447,30 @@ is_std_substitution (const tree node, ...@@ -447,6 +447,30 @@ is_std_substitution (const tree node,
== subst_identifiers[index])); == subst_identifiers[index]));
} }
/* Return the ABI tags (the TREE_VALUE of the "abi_tag" attribute entry) for T,
which can be a decl or type. */
static tree
get_abi_tags (tree t)
{
if (!t || TREE_CODE (t) == NAMESPACE_DECL)
return NULL_TREE;
if (DECL_P (t) && DECL_DECLARES_TYPE_P (t))
t = TREE_TYPE (t);
tree attrs;
if (TYPE_P (t))
attrs = TYPE_ATTRIBUTES (t);
else
attrs = DECL_ATTRIBUTES (t);
tree tags = lookup_attribute ("abi_tag", attrs);
if (tags)
tags = TREE_VALUE (tags);
return tags;
}
/* Helper function for find_substitution. Returns nonzero if NODE, /* Helper function for find_substitution. Returns nonzero if NODE,
which may be a decl or a CLASS_TYPE, is the template-id which may be a decl or a CLASS_TYPE, is the template-id
::std::identifier<char>, where identifier is ::std::identifier<char>, where identifier is
...@@ -601,7 +625,7 @@ find_substitution (tree node) ...@@ -601,7 +625,7 @@ find_substitution (tree node)
tree tags = NULL_TREE; tree tags = NULL_TREE;
if (OVERLOAD_TYPE_P (node) || DECL_CLASS_TEMPLATE_P (node)) if (OVERLOAD_TYPE_P (node) || DECL_CLASS_TEMPLATE_P (node))
tags = lookup_attribute ("abi_tag", TYPE_ATTRIBUTES (type)); tags = get_abi_tags (type);
/* Now check the list of available substitutions for this mangling /* Now check the list of available substitutions for this mangling
operation. */ operation. */
if (!abbr || tags) for (i = 0; i < size; ++i) if (!abbr || tags) for (i = 0; i < size; ++i)
...@@ -667,7 +691,7 @@ unmangled_name_p (const tree decl) ...@@ -667,7 +691,7 @@ unmangled_name_p (const tree decl)
return false; return false;
/* Declarations with ABI tags are mangled. */ /* Declarations with ABI tags are mangled. */
if (lookup_attribute ("abi_tag", DECL_ATTRIBUTES (decl))) if (get_abi_tags (decl))
return false; return false;
/* The names of non-static global variables aren't mangled. */ /* The names of non-static global variables aren't mangled. */
...@@ -1314,12 +1338,7 @@ write_unqualified_name (tree decl) ...@@ -1314,12 +1338,7 @@ write_unqualified_name (tree decl)
decl = DECL_TEMPLATE_RESULT (tmpl); decl = DECL_TEMPLATE_RESULT (tmpl);
/* Don't crash on an unbound class template. */ /* Don't crash on an unbound class template. */
if (decl && TREE_CODE (decl) != NAMESPACE_DECL) if (decl && TREE_CODE (decl) != NAMESPACE_DECL)
{ write_abi_tags (get_abi_tags (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. */ /* Write the unqualified-name for a conversion operator to TYPE. */
...@@ -1371,8 +1390,6 @@ write_abi_tags (tree tags) ...@@ -1371,8 +1390,6 @@ write_abi_tags (tree tags)
if (tags == NULL_TREE) if (tags == NULL_TREE)
return; return;
tags = TREE_VALUE (tags);
vec<tree, va_gc> * vec = make_tree_vector(); vec<tree, va_gc> * vec = make_tree_vector();
for (tree t = tags; t; t = TREE_CHAIN (t)) for (tree t = tags; t; t = TREE_CHAIN (t))
...@@ -4027,16 +4044,12 @@ maybe_check_abi_tags (tree t, tree for_decl) ...@@ -4027,16 +4044,12 @@ maybe_check_abi_tags (tree t, tree for_decl)
if (DECL_ASSEMBLER_NAME_SET_P (t)) if (DECL_ASSEMBLER_NAME_SET_P (t))
return; return;
tree attr = lookup_attribute ("abi_tag", DECL_ATTRIBUTES (t)); tree oldtags = get_abi_tags (t);
tree oldtags = NULL_TREE;
if (attr)
oldtags = TREE_VALUE (attr);
mangle_decl (t); mangle_decl (t);
if (!attr) tree newtags = get_abi_tags (t);
attr = lookup_attribute ("abi_tag", DECL_ATTRIBUTES (t)); if (newtags && newtags != oldtags
if (attr && TREE_VALUE (attr) != oldtags
&& abi_version_crosses (10)) && abi_version_crosses (10))
{ {
if (for_decl) if (for_decl)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment