OSDN Git Service

PR c++/54652
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 28 Jan 2014 13:51:15 +0000 (13:51 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 28 Jan 2014 13:51:15 +0000 (13:51 +0000)
* decl.c (duplicate_decls): Always use oldtype for TYPE_DECL.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@207192 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 00d18f2..92c49f9 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 db0c233..955fd0f 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;