> bitregion_start == 11 looks bogus. The representative is starting at > > DECL_FIELD_BIT_OFFSET (repr) > = size_binop (BIT_AND_EXPR, > DECL_FIELD_BIT_OFFSET (field), > bitsize_int (~(BITS_PER_UNIT - 1))); > > which looks ok
It cannot be OK if you want it to be on a byte boundary, since the field isn't on a byte boundary itself and they have the same DECL_FIELD_BIT_OFFSET (0). > the size of the representative is (at minimum) > > size = size_diffop (DECL_FIELD_OFFSET (field), > DECL_FIELD_OFFSET (repr)); > gcc_assert (host_integerp (size, 1)); > bitsize = (tree_low_cst (size, 1) * BITS_PER_UNIT > + tree_low_cst (DECL_FIELD_BIT_OFFSET (field), 1) > - tree_low_cst (DECL_FIELD_BIT_OFFSET (repr), 1) > + tree_low_cst (DECL_SIZE (field), 1)); > > /* Round up bitsize to multiples of BITS_PER_UNIT. */ > bitsize = (bitsize + BITS_PER_UNIT - 1) & ~(BITS_PER_UNIT - 1); > > that looks ok to me as well. Is the issue that we, in get_bit_range, > compute bitregion_start relative to the byte-aligned offset of the > representative? The issue is that the representative is assumed to be on a byte boundary in get_bit_range, but it isn't in the case at hand. So either we cope with that (this is the GCC 4.7 approach) or we change the representative somehow. IOW, either we pretend that a bitfield group is entirely contained within a single record type or we acknowledge that a bitfield group can cross a record boundary. -- Eric Botcazou