> > The patch plugs the hole by invoking it for DECL_FIELD_OFFSET as well
> > (and the effect is spectacular for pathological cases). Tested on
> > x86_64-suse-linux, although this will essentially only affect Ada. OK
> > for the mainline?
>
> Ok.
Thanks. It turns out that the patch was not complete, but the missing bits I
can approve myself so installed as such.
* stor-layout.c (place_field): Finalize non-constant offset for the
field, if any.
ada/
* gcc-interface/decl.c (create_field_decl_from): Finalize non-constant
offset for the field, if any.
--
Eric Botcazou
Index: stor-layout.c
===================================================================
--- stor-layout.c (revision 209334)
+++ stor-layout.c (working copy)
@@ -1417,6 +1417,10 @@ place_field (record_layout_info rli, tre
DECL_FIELD_BIT_OFFSET (field) = rli->bitpos;
SET_DECL_OFFSET_ALIGN (field, rli->offset_align);
+ /* Evaluate nonconstant offsets only once, either now or as soon as safe. */
+ if (TREE_CODE (DECL_FIELD_OFFSET (field)) != INTEGER_CST)
+ DECL_FIELD_OFFSET (field) = variable_size (DECL_FIELD_OFFSET (field));
+
/* If this field ended up more aligned than we thought it would be (we
approximate this by seeing if its position changed), lay out the field
again; perhaps we can use an integral mode for it now. */
Index: ada/gcc-interface/decl.c
===================================================================
--- ada/gcc-interface/decl.c (revision 209334)
+++ ada/gcc-interface/decl.c (working copy)
@@ -8443,7 +8443,8 @@ create_field_decl_from (tree old_field,
if (!new_pos)
{
normalize_offset (&pos, &bitpos, offset_align);
- DECL_FIELD_OFFSET (new_field) = pos;
+ /* Finalize the position. */
+ DECL_FIELD_OFFSET (new_field) = variable_size (pos);
DECL_FIELD_BIT_OFFSET (new_field) = bitpos;
SET_DECL_OFFSET_ALIGN (new_field, offset_align);
DECL_SIZE (new_field) = size;