]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/54652 (ICE with -g)
authorJason Merrill <jason@redhat.com>
Tue, 28 Jan 2014 13:51:15 +0000 (08:51 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 28 Jan 2014 13:51:15 +0000 (08:51 -0500)
PR c++/54652
* decl.c (duplicate_decls): Always use oldtype for TYPE_DECL.

From-SVN: r207192

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/ext/attrib48.C [new file with mode: 0644]

index 00d18f23387c9f248ad75d3645e24d90295aae6c..92c49f9a4d3b0b6eee8ecbb932beb9b5525cfcda 100644 (file)
@@ -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++/58639
        * call.c (build_aggr_conv): Reject value-initialization of reference.
 
index db0c233b8e173441649b561bf1f1dfc5612fa41c..955fd0f0d538e8ca5441ea257cbba733f3088515 100644 (file)
@@ -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 (file)
index 0000000..19a9959
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/54652
+
+typedef unsigned L __attribute__ ((aligned));
+typedef unsigned L __attribute__ ((aligned));
+
+L l;