aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1993-04-11 06:41:55 -0400
committerRichard Kenner <kenner@gcc.gnu.org>1993-04-11 06:41:55 -0400
commitcbcf989d7f0543b2c391268bd625b6624c198608 (patch)
treee39f2dcb2d72bb374752915aa99acabc270ffeb2 /gcc
parent0a5cbff6d4d8aaae40d37e526e1fcbfdc42c12b3 (diff)
downloadgcc-cbcf989d7f0543b2c391268bd625b6624c198608.zip
gcc-cbcf989d7f0543b2c391268bd625b6624c198608.tar.gz
gcc-cbcf989d7f0543b2c391268bd625b6624c198608.tar.bz2
(layout_record): After copying the offsets of a field that is an anonymous union to the offsets of the fields of that union...
(layout_record): After copying the offsets of a field that is an anonymous union to the offsets of the fields of that union, zero the offset of the anonymous field in case it is used to access the inner fields. From-SVN: r4083
Diffstat (limited to 'gcc')
-rw-r--r--gcc/stor-layout.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 7db340c..f57c69e 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -435,7 +435,17 @@ layout_record (rec)
DECL_FIELD_BITPOS (field) = size_int (const_size);
/* If this field is an anonymous union,
- give each union-member the same position as the union has. */
+ give each union-member the same position as the union has.
+
+ ??? This is a real kludge because it makes the structure
+ of the types look strange. This feature is only used by
+ C++, which should have build_component_ref build two
+ COMPONENT_REF operations, one for the union and one for
+ the inner field. We set the offset of this field to zero
+ so that either the old or the correct method will work.
+ Setting DECL_FIELD_CONTEXT is wrong unless the inner fields are
+ moved into the type of this field, but nothing seems to break
+ by doing this. This kludge should be removed after 2.4. */
if (DECL_NAME (field) == 0
&& TREE_CODE (TREE_TYPE (field)) == UNION_TYPE)
@@ -446,6 +456,8 @@ layout_record (rec)
DECL_FIELD_CONTEXT (uelt) = DECL_FIELD_CONTEXT (field);
DECL_FIELD_BITPOS (uelt) = DECL_FIELD_BITPOS (field);
}
+
+ DECL_FIELD_BITPOS (field) = integer_zero_node;
}
/* Now add size of this field to the size of the record. */