summaryrefslogtreecommitdiff
path: root/gcc/cp/class.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r--gcc/cp/class.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 16d566682a6..f88914d3c22 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5216,6 +5216,11 @@ layout_class_type (tree t, tree *virtuals_p)
build_decl (input_location,
FIELD_DECL, NULL_TREE, char_type_node));
+ /* If this is a non-POD, declaring it packed makes a difference to how it
+ can be used as a field; don't let finalize_record_size undo it. */
+ if (TYPE_PACKED (t) && !layout_pod_type_p (t))
+ rli->packed_maybe_necessary = true;
+
/* Let the back end lay out the type. */
finish_record_layout (rli, /*free_p=*/true);