aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2014-01-27 23:31:30 -0500
committerJason Merrill <jason@gcc.gnu.org>2014-01-27 23:31:30 -0500
commitb89cc12b9962ea4b8a01d51e506348e3933106c6 (patch)
tree89f30a03fe7a1937cac6a24f588836ec605a6c77
parent9e73c3f3a5fa913452747c9facff9fb2be7e23a0 (diff)
downloadgcc-b89cc12b9962ea4b8a01d51e506348e3933106c6.zip
gcc-b89cc12b9962ea4b8a01d51e506348e3933106c6.tar.gz
gcc-b89cc12b9962ea4b8a01d51e506348e3933106c6.tar.bz2
re PR c++/54652 (ICE with -g)
PR c++/54652 * decl.c (duplicate_decls): Always use oldtype for TYPE_DECL. From-SVN: r207169
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/decl.c6
-rw-r--r--gcc/testsuite/g++.dg/ext/attrib48.C6
3 files changed, 12 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 07f82ad9..214cb57 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2014-01-27 Jason Merrill <jason@redhat.com>
+ PR c++/54652
+ * decl.c (duplicate_decls): Always use oldtype for TYPE_DECL.
+
PR c++/58504
* pt.c (tsubst_copy_and_build) [TRAIT_EXPR]: Use tsubst for
types.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 7ebb05d..c93c783 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1926,9 +1926,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 (VAR_P (newdecl))
diff --git a/gcc/testsuite/g++.dg/ext/attrib48.C b/gcc/testsuite/g++.dg/ext/attrib48.C
new file mode 100644
index 0000000..19a9959
--- /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;