aboutsummaryrefslogtreecommitdiff
path: root/gcc/stor-layout.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2018-09-05 10:04:58 +0000
committerNathan Sidwell <nathan@acm.org>2018-09-05 10:04:58 +0000
commit46003600f4f9faf5fcfaa748d98bbb25f5d0652d (patch)
tree1564152cd9bc6dc7b9152e736ab8f3ce0ec15693 /gcc/stor-layout.c
parent08be8f1f7223733800a5774d01413d2ceaa54a05 (diff)
PR c++/87137] GCC-8 Fix
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01966.html PR c++/87137 * stor-layout.c (place_field): Scan forwards to check last bitfield when ms_bitfield_placement is in effect. gcc/testsuite/ * g++.dg/abi/pr87137.C: New. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@264119 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r--gcc/stor-layout.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 088f3606a0d..58a3aa369fa 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -1686,14 +1686,21 @@ place_field (record_layout_info rli, tree field)
{
rli->bitpos = size_binop (PLUS_EXPR, rli->bitpos, DECL_SIZE (field));
- /* If we ended a bitfield before the full length of the type then
- pad the struct out to the full length of the last type. */
- if ((DECL_CHAIN (field) == NULL
- || TREE_CODE (DECL_CHAIN (field)) != FIELD_DECL)
- && DECL_BIT_FIELD_TYPE (field)
+ /* If FIELD is the last field and doesn't end at the full length
+ of the type then pad the struct out to the full length of the
+ last type. */
+ if (DECL_BIT_FIELD_TYPE (field)
&& !integer_zerop (DECL_SIZE (field)))
- rli->bitpos = size_binop (PLUS_EXPR, rli->bitpos,
- bitsize_int (rli->remaining_in_alignment));
+ {
+ /* We have to scan, because non-field DECLS are also here. */
+ tree probe = field;
+ while ((probe = DECL_CHAIN (probe)))
+ if (TREE_CODE (probe) == FIELD_DECL)
+ break;
+ if (!probe)
+ rli->bitpos = size_binop (PLUS_EXPR, rli->bitpos,
+ bitsize_int (rli->remaining_in_alignment));
+ }
normalize_rli (rli);
}