From ca3d44f55ae70733502ecf609dd93d5faec2940b Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 28 Jan 2014 08:51:15 -0500 Subject: [PATCH] re PR c++/54652 (ICE with -g) PR c++/54652 * decl.c (duplicate_decls): Always use oldtype for TYPE_DECL. From-SVN: r207192 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/decl.c | 6 +++--- gcc/testsuite/g++.dg/ext/attrib48.C | 6 ++++++ 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/attrib48.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 00d18f23387c..92c49f9a4d3b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2014-01-27 Jason Merrill + PR c++/54652 + * decl.c (duplicate_decls): Always use oldtype for TYPE_DECL. + PR c++/58639 * call.c (build_aggr_conv): Reject value-initialization of reference. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index db0c233b8e17..955fd0f0d538 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1815,9 +1815,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) /* Merge the data types specified in the two decls. */ newtype = merge_types (TREE_TYPE (newdecl), TREE_TYPE (olddecl)); - /* If merge_types produces a non-typedef type, just use the old type. */ - if (TREE_CODE (newdecl) == TYPE_DECL - && newtype == DECL_ORIGINAL_TYPE (newdecl)) + /* 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; if (TREE_CODE (newdecl) == VAR_DECL) diff --git a/gcc/testsuite/g++.dg/ext/attrib48.C b/gcc/testsuite/g++.dg/ext/attrib48.C new file mode 100644 index 000000000000..19a9959109d7 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib48.C @@ -0,0 +1,6 @@ +// PR c++/54652 + +typedef unsigned L __attribute__ ((aligned)); +typedef unsigned L __attribute__ ((aligned)); + +L l; -- 2.47.2