public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* c++: better fixup_type_variants
@ 2020-07-28 15:56 Nathan Sidwell
  0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2020-07-28 15:56 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 346 bytes --]

fixup_type_variants was almost doing all that finish_struct needs. May 
as well make it do it all.  That this is helpful for modules is entirely 
coincidental :)

             gcc/cp/
             * class.c (fixup_type_variants): Copy TYPE_SIZE and
             TYPE_SIZE_UINIT.
             (finish_struct): Call it.

nathan

-- 
Nathan Sidwell

[-- Attachment #2: fixup.diff --]
[-- Type: text/x-patch, Size: 865 bytes --]

diff --git i/gcc/cp/class.c w/gcc/cp/class.c
index ba96113bc88..7a25d8fc76c 100644
--- i/gcc/cp/class.c
+++ w/gcc/cp/class.c
@@ -1967,6 +1967,9 @@ fixup_type_variants (tree t)
       /* Copy whatever these are holding today.  */
       TYPE_VFIELD (variants) = TYPE_VFIELD (t);
       TYPE_FIELDS (variants) = TYPE_FIELDS (t);
+
+      TYPE_SIZE (variants) = TYPE_SIZE (t);
+      TYPE_SIZE_UNIT (variants) = TYPE_SIZE_UNIT (t);
     }
 }
 
@@ -7610,12 +7613,7 @@ finish_struct (tree t, tree attributes)
 	CLASSTYPE_NON_AGGREGATE (t) = 1;
 
       /* Fix up any variants we've already built.  */
-      for (x = TYPE_NEXT_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
-	{
-	  TYPE_SIZE (x) = TYPE_SIZE (t);
-	  TYPE_SIZE_UNIT (x) = TYPE_SIZE_UNIT (t);
-	  TYPE_FIELDS (x) = TYPE_FIELDS (t);
-	}
+      fixup_type_variants (t);
     }
   else
     finish_struct_1 (t);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-28 15:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-28 15:56 c++: better fixup_type_variants Nathan Sidwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).