diff options
author | Mark Mitchell <mark@codesourcery.com> | 1999-12-21 02:11:10 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 1999-12-21 02:11:10 +0000 |
commit | 3ef397c1c6defdd895e5b1f41931176fe7706133 (patch) | |
tree | 1baa694ed75cd886a2915d1c87150fa270a1062e /gcc/cp/tree.c | |
parent | 4c6b7393dcb6c97b57b5268dc84542369d5b367f (diff) | |
download | gcc-3ef397c1c6defdd895e5b1f41931176fe7706133.zip gcc-3ef397c1c6defdd895e5b1f41931176fe7706133.tar.gz gcc-3ef397c1c6defdd895e5b1f41931176fe7706133.tar.bz2 |
cp-tree.h (CLASSTYPE_VFIELD_PARENT): Update comments.
1999-12-20 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (CLASSTYPE_VFIELD_PARENT): Update comments.
(CLASSTYPE_HAS_PRIMARY_BASE_P): New macro.
(CLASSTYPE_PRIMARY_BINFO): Likewise.
* class.c (check_methods): Don't set TYPE_HAS_COMPLEX_INIT_REF,
TYPE_NEEDS_CONSTRUCTING, and CLASSTYPE_NON_AGGREGATE here.
(check_bases_and_members): Set them here instead.
(create_vtable_ptr): New function, split out from ...
(finish_struct_1): ... here. Use it. Tidy. Use
CLASSTYPE_HAS_PRIMARY_BASE_P and CLASSTYPE_PRIMARY_BINFO.
* search.c (dfs_init_vbase_pointers): Handle seeing TYPE_VFIELD as
the first field in the class.
* tree.c (layout_basetypes): Use CLASSTYPE_N_BASECLASSES. Handle
seeing TYPE_VFIELD as the first field in the class.
From-SVN: r31042
Diffstat (limited to 'gcc/cp/tree.c')
-rw-r--r-- | gcc/cp/tree.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index cd837e6..39447ee 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -693,15 +693,7 @@ propagate_binfo_offsets (binfo, offset) break; } -#if 0 - if (BINFO_OFFSET_ZEROP (base_binfo)) - BINFO_OFFSET (base_binfo) = offset; - else - BINFO_OFFSET (base_binfo) - = size_binop (PLUS_EXPR, BINFO_OFFSET (base_binfo), offset); -#else BINFO_OFFSET (base_binfo) = offset; -#endif propagate_binfo_offsets (base_binfo, offset); @@ -759,9 +751,9 @@ layout_basetypes (rec, max) int max; { tree binfos = TYPE_BINFO_BASETYPES (rec); - int i, n_baseclasses = binfos ? TREE_VEC_LENGTH (binfos) : 0; - + int i, n_baseclasses = CLASSTYPE_N_BASECLASSES (rec); tree vbase_types; + tree *field; unsigned int record_align = MAX (BITS_PER_UNIT, TYPE_ALIGN (rec)); unsigned int desired_align; @@ -835,27 +827,43 @@ layout_basetypes (rec, max) size_int (BITS_PER_UNIT)); } - /* Now propagate offset information throughout the lattice. */ + /* Now propagate offset information throughout the lattice. + Simultaneously, remove the temporary FIELD_DECLS we created in + build_base_fields to refer to base types. */ + field = &TYPE_FIELDS (rec); + if (TYPE_VFIELD (rec) == *field) + { + /* If this class did not have a primary base, we create a + virtual function table pointer. It will be the first thing + in the class, under the new ABI. Skip it; the base fields + will follow it. */ + my_friendly_assert (flag_new_abi + && !CLASSTYPE_HAS_PRIMARY_BASE_P (rec), + 19991218); + field = &TREE_CHAIN (*field); + } + for (i = 0; i < n_baseclasses; i++) { register tree base_binfo = TREE_VEC_ELT (binfos, i); register tree basetype = BINFO_TYPE (base_binfo); - tree field = TYPE_FIELDS (rec); if (TREE_VIA_VIRTUAL (base_binfo)) continue; - my_friendly_assert (TREE_TYPE (field) == basetype, 23897); + my_friendly_assert (TREE_TYPE (*field) == basetype, 23897); if (get_base_distance (basetype, rec, 0, (tree*)0) == -2) cp_warning ("direct base `%T' inaccessible in `%T' due to ambiguity", basetype, rec); BINFO_OFFSET (base_binfo) - = size_int (CEIL (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field)), + = size_int (CEIL (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (*field)), BITS_PER_UNIT)); propagate_binfo_offsets (base_binfo, BINFO_OFFSET (base_binfo)); - TYPE_FIELDS (rec) = TREE_CHAIN (field); + + /* Remove this field. */ + *field = TREE_CHAIN (*field); } for (vbase_types = CLASSTYPE_VBASECLASSES (rec); vbase_types; |