* tree-inline.c (remap_decl): Preserve DECL_ORIGINAL_TYPE invariant.
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 23 Jun 2016 15:04:25 +0000 (15:04 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 23 Jun 2016 15:04:25 +0000 (15:04 +0000)
From-SVN: r237734

gcc/ChangeLog
gcc/tree-inline.c

index 9a1f732d259c586aa007968a2d9e07f2ab0d639a..ffa702a73f644915004c2381287fd6d8f4603bf0 100644 (file)
@@ -1,3 +1,7 @@
+2016-06-23  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * tree-inline.c (remap_decl): Preserve DECL_ORIGINAL_TYPE invariant.
+
 2016-06-23  Andi Kleen  <ak@linux.intel.com>
 
        * Makefile.in: Regenerate.
index 07f6a83ff7c61ffc5bd4a44df15bcc888381e011..a0d9e934e6d94271a0fd9f5cfb06935a9c48aa30 100644 (file)
@@ -367,7 +367,20 @@ remap_decl (tree decl, copy_body_data *id)
       /* Remap types, if necessary.  */
       TREE_TYPE (t) = remap_type (TREE_TYPE (t), id);
       if (TREE_CODE (t) == TYPE_DECL)
-        DECL_ORIGINAL_TYPE (t) = remap_type (DECL_ORIGINAL_TYPE (t), id);
+       {
+         DECL_ORIGINAL_TYPE (t) = remap_type (DECL_ORIGINAL_TYPE (t), id);
+
+         /* Preserve the invariant that DECL_ORIGINAL_TYPE != TREE_TYPE,
+            which is enforced in gen_typedef_die when DECL_ABSTRACT_ORIGIN
+            is not set on the TYPE_DECL, for example in LTO mode.  */
+         if (DECL_ORIGINAL_TYPE (t) == TREE_TYPE (t))
+           {
+             tree x = build_variant_type_copy (TREE_TYPE (t));
+             TYPE_STUB_DECL (x) = TYPE_STUB_DECL (TREE_TYPE (t));
+             TYPE_NAME (x) = t;
+             DECL_ORIGINAL_TYPE (t) = x;
+           }
+       }
 
       /* Remap sizes as necessary.  */
       walk_tree (&DECL_SIZE (t), copy_tree_body_r, id, NULL);