aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2015-11-11 20:16:59 -0500
committerJason Merrill <jason@gcc.gnu.org>2015-11-11 20:16:59 -0500
commit9e4c469a24b5a3bb6e72a9bc59009286501ce400 (patch)
tree7250a3da17005c2fab0587043c0dbd9b898a632a /gcc
parentc7360ed2f9b78a0091b6ce60e8ef7411683efae2 (diff)
downloadgcc-9e4c469a24b5a3bb6e72a9bc59009286501ce400.zip
gcc-9e4c469a24b5a3bb6e72a9bc59009286501ce400.tar.gz
gcc-9e4c469a24b5a3bb6e72a9bc59009286501ce400.tar.bz2
decl.c (duplicate_decls): When combining typedefs, remove the new type from the variants list.
* decl.c (duplicate_decls): When combining typedefs, remove the new type from the variants list. From-SVN: r230202
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c17
2 files changed, 21 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9cbda29..d1bf121 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
2015-11-11 Jason Merrill <jason@redhat.com>
+ * decl.c (duplicate_decls): When combining typedefs, remove the
+ new type from the variants list.
+
+2015-11-11 Jason Merrill <jason@redhat.com>
+
* pt.c (instantiate_class_template_1): Set function_depth around
instantiation of lambda op().
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 76cc1d1..383b47d 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -2014,7 +2014,22 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
/* For typedefs use the old type, as the new type's DECL_NAME points
at newdecl, which will be ggc_freed. */
if (TREE_CODE (newdecl) == TYPE_DECL)
- newtype = oldtype;
+ {
+ newtype = oldtype;
+
+ /* And remove the new type from the variants list. */
+ if (TYPE_NAME (TREE_TYPE (newdecl)) == newdecl)
+ {
+ tree remove = TREE_TYPE (newdecl);
+ for (tree t = TYPE_MAIN_VARIANT (remove); ;
+ t = TYPE_NEXT_VARIANT (t))
+ if (TYPE_NEXT_VARIANT (t) == remove)
+ {
+ TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (remove);
+ break;
+ }
+ }
+ }
else
/* Merge the data types specified in the two decls. */
newtype = merge_types (TREE_TYPE (newdecl), TREE_TYPE (olddecl));