aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2016-08-01 16:20:12 -0400
committerJason Merrill <jason@gcc.gnu.org>2016-08-01 16:20:12 -0400
commit884929e21dcf4028cfdc852a58d4d8370cfa6b72 (patch)
treefd150ea54854f5f1f2f65351f5cd5804174ac6a8
parent352b8babea0ef7d9995f1cb54a482cedca08987f (diff)
downloadgcc-884929e21dcf4028cfdc852a58d4d8370cfa6b72.zip
gcc-884929e21dcf4028cfdc852a58d4d8370cfa6b72.tar.gz
gcc-884929e21dcf4028cfdc852a58d4d8370cfa6b72.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/mangle.c47
2 files changed, 34 insertions, 17 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 2960579..9d46aaa 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
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.
PR c++/72766
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index e0bbfc9..29be7fd 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -447,6 +447,30 @@ is_std_substitution (const tree node,
== 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,
which may be a decl or a CLASS_TYPE, is the template-id
::std::identifier<char>, where identifier is
@@ -601,7 +625,7 @@ find_substitution (tree node)
tree tags = NULL_TREE;
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
operation. */
if (!abbr || tags) for (i = 0; i < size; ++i)
@@ -667,7 +691,7 @@ unmangled_name_p (const tree decl)
return false;
/* Declarations with ABI tags are mangled. */
- if (lookup_attribute ("abi_tag", DECL_ATTRIBUTES (decl)))
+ if (get_abi_tags (decl))
return false;
/* The names of non-static global variables aren't mangled. */
@@ -1314,12 +1338,7 @@ write_unqualified_name (tree decl)
decl = DECL_TEMPLATE_RESULT (tmpl);
/* Don't crash on an unbound class template. */
if (decl && TREE_CODE (decl) != NAMESPACE_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_abi_tags (get_abi_tags (decl));
}
/* Write the unqualified-name for a conversion operator to TYPE. */
@@ -1371,8 +1390,6 @@ write_abi_tags (tree tags)
if (tags == NULL_TREE)
return;
- tags = TREE_VALUE (tags);
-
vec<tree, va_gc> * vec = make_tree_vector();
for (tree t = tags; t; t = TREE_CHAIN (t))
@@ -4027,16 +4044,12 @@ maybe_check_abi_tags (tree t, tree for_decl)
if (DECL_ASSEMBLER_NAME_SET_P (t))
return;
- tree attr = lookup_attribute ("abi_tag", DECL_ATTRIBUTES (t));
- tree oldtags = NULL_TREE;
- if (attr)
- oldtags = TREE_VALUE (attr);
+ tree oldtags = get_abi_tags (t);
mangle_decl (t);
- if (!attr)
- attr = lookup_attribute ("abi_tag", DECL_ATTRIBUTES (t));
- if (attr && TREE_VALUE (attr) != oldtags
+ tree newtags = get_abi_tags (t);
+ if (newtags && newtags != oldtags
&& abi_version_crosses (10))
{
if (for_decl)