From ce1d55bbf289b69e962027fc234603c0af188c1d Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Thu, 2 Jul 2015 21:27:19 +0000 Subject: [PATCH] * stor-layout.c (finish_record_layout): Also propagate the TYPE_REVERSE_STORAGE_ORDER flag to the variants. c/ * c-decl.c (finish_struct): Adjust latest change. cp/ * class.c (finish_struct_1): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/scalar-storage-order@225355 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c/c-decl.c | 4 ++-- gcc/cp/class.c | 3 +-- gcc/stor-layout.c | 11 ++++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 493036fc36b..a94d3f743fb 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -7724,6 +7724,8 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, TYPE_FIELDS (t) = fieldlist; + maybe_apply_pragma_scalar_storage_order (t); + layout_type (t); if (TYPE_SIZE_UNIT (t) @@ -7732,8 +7734,6 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, && !valid_constant_size_p (TYPE_SIZE_UNIT (t))) error ("type %qT is too large", t); - maybe_apply_pragma_scalar_storage_order (t); - /* Give bit-fields their proper types and rewrite the type of array fields with scalar component if the enclosing type has reverse storage order. */ for (tree field = fieldlist; field; field = DECL_CHAIN (field)) diff --git a/gcc/cp/class.c b/gcc/cp/class.c index d75f6b11c73..032239927aa 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -6596,6 +6596,7 @@ finish_struct_1 (tree t) } /* Layout the class itself. */ + maybe_apply_pragma_scalar_storage_order (t); layout_class_type (t, &virtuals); if (CLASSTYPE_AS_BASE (t) != t) /* We use the base type for trivial assignments, and hence it @@ -6658,8 +6659,6 @@ finish_struct_1 (tree t) finish_struct_bits (t); set_method_tm_attributes (t); - maybe_apply_pragma_scalar_storage_order (t); - /* Complete the rtl for any static member objects of the type we're working on and rewrite the type of array fields with scalar component if the enclosing type has reverse storage order. */ diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 30f97a836d4..fa638dc95fb 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -2063,11 +2063,16 @@ finish_record_layout (record_layout_info rli, int free_p) /* Compute bitfield representatives. */ finish_bitfield_layout (rli->t); - /* Propagate TYPE_PACKED to variants. With C++ templates, - handle_packed_attribute is too early to do this. */ + /* Propagate TYPE_PACKED and TYPE_REVERSE_STORAGE_ORDER to variants. + With C++ templates, it is too early to do this when the attribute + is being parsed. */ for (variant = TYPE_NEXT_VARIANT (rli->t); variant; variant = TYPE_NEXT_VARIANT (variant)) - TYPE_PACKED (variant) = TYPE_PACKED (rli->t); + { + TYPE_PACKED (variant) = TYPE_PACKED (rli->t); + TYPE_REVERSE_STORAGE_ORDER (variant) + = TYPE_REVERSE_STORAGE_ORDER (rli->t); + } /* Lay out any static members. This is done now because their type may use the record's type. */ -- 2.11.4.GIT