From: jason Date: Thu, 12 Nov 2015 01:16:59 +0000 (+0000) Subject: * decl.c (duplicate_decls): When combining typedefs, remove the X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ccb738ec9d63ce6a189b5795973ae014d82cc3b9;p=thirdparty%2Fgcc.git * decl.c (duplicate_decls): When combining typedefs, remove the new type from the variants list. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230202 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9cbda291ac7a..d1bf1219e00f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-11-11 Jason Merrill + + * decl.c (duplicate_decls): When combining typedefs, remove the + new type from the variants list. + 2015-11-11 Jason Merrill * pt.c (instantiate_class_template_1): Set function_depth around diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 76cc1d176e54..383b47d29edd 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));