[PATCH] Fix PRs 52080, 52097 and 48124, rewrite bitfield expansion, enable the C++ memory model wrt bitfields everywhere

Eric Botcazou ebotcazou@adacore.com
Tue Apr 3 11:09:00 GMT 2012


> For the case in question offset is (D.2640_7 + -1) * 20 + 16.  I wonder
> why DECL_FIELD_OFFSET of the outermost COMPONENT_REF is not added
> to bitpos by get_inner_reference (that is what get_bit_range assumes ...).

DECL_FIELD_OFFSET is added to offset and DECL_FIELD_BIT_OFFSET to bitpos.

> So, how would you make sure this works?  Match the fact that
> get_inner_reference does _not_ add DECL_FIELD_OFFSET to bitpos,
> and, if DECL_FIELD_OFFSET is an INTEGER_CST simply subtract that
> from offset and add it to bitpos?  I suppose that would work.

Yes, but the amount is simply the negative bitstart (which is a multiple of 
BITS_PER_UNIT).  This is the same kind of adjustment now done at the end of 
get_inner_reference to avoid negative bit positions there too.

> Though doing that in get_inner_reference for DECL_BIT_FIELD_TYPE
> fields may make sense as well.

That would be more complicated, as we would need to split the offset into
variable and fixed part.


Tentative patch attached, regtested for Ada on x86 and x86-64.  I'll do a full 
testing cycle if it is approved.


	* expr.c (get_bit_range): Add OFFSET parameter and adjust BITPOS.
	Change type of BITOFFSET to signed.  Make sure the lower bound of
	the computed range is non-negative by adjusting OFFSET and BITPOS.
	(expand_assignment): Adjust call to get_bit_range.


-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: get_bit_range.diff
Type: text/x-diff
Size: 2557 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20120403/4e689763/attachment.bin>


More information about the Gcc-patches mailing list