summaryrefslogtreecommitdiff
path: root/gcc/cp/init.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2001-02-05 11:45:16 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2001-02-05 11:45:16 +0000
commit9965d119133a5cb80938b829d28fa45777667a0c (patch)
treee552da6fa53e49d793b63acc246a7fe949765502 /gcc/cp/init.c
parent36ca672c97a7f1d07e274626eab0dabb5710b49a (diff)
downloadgcc-9965d119133a5cb80938b829d28fa45777667a0c.tar.gz
invoke.texi (-fdump-class-layout): Document.
gcc: * invoke.texi (-fdump-class-layout): Document. (-fdump-translation-unit): Use `=' as filename separator. cp: Fix specification and implementation bugs in V3 ABI construction vtables. * cp-tree.h (flag_dump_class_layout): New flag. (BINFO_OVERRIDE_ALONG_VIRTUAL_PATH_P): Remove. (BINFO_LOST_PRIMARY_P): New flag. (SET_BINFO_NEW_VTABLE_MARKED): Adjust asserts. (BINFO_PRIMARY_MARKED_P): Rename to ... (BINFO_PRIMARY_P): ... here. (binfo_via_virtual): New prototype. * decl2.c (flag_dump_class_layout): New flag. (cxx_decode_option): Set it. Adjust -fdump-translation-unit to use `=' as a file name separator. * init.c (dfs_initialize_vtbl_ptrs): Walk into virtual primary bases. (build_vtbl_address): If this is a virtual primary base, then get the vtbl of what it is ultimately primary for. * search.c (dfs_skip_nonprimary_vbases_unmarkedp): Adjust for BINFO_PRIMARY_P. (dfs_skip_nonprimary_vbases_markedp): Likewise. (get_shared_vbase_if_not_primary): Likewise. (dfs_get_pure_virtuals): Likewise. (expand_upcast_fixups): Likewise. (fixup_virtual_upcast_offsets): Likewise. (dfs_find_vbase_instance): Likewise. (find_vbase_instance): Likewise. (binfo_from_vbase): Adjust comment to reflect reality. (binfo_via_virtual): New function. * class.c (VTT_TOP_LEVEL_P, VTT_MARKED_BINFO_P): New macros for binfo walking during VTT construction. (dfs_mark_primary_bases): Remove. (force_canonical_binfo_r): New function. (force_canonical_binfo): New function. (mark_primary_virtual_base): New function. (mark_primary_bases): Walk in inheritance graph order, use mark_primary_virtual_base. (determine_primary_base): Use some more intermediate variables. (dfs_find_final_overrider): Don't check for overriding along a virtual path. (dfs_modify_vtables): Walk into primary virtual bases too. (walk_subobject_offsets): Adjust for BINFO_PRIMARY_P. (build_base_fields): Likewise. (dfs_set_offset_for_unshared_vbases): Likewise. (layout_virtual_bases): Likewise. (end_of_class): Likewise. (finish_struct_1): Call dump_class_hierarchy, if requested. (dfs_get_primary_binfo): Use BINFO_TYPE for binfos. (dump_class_hierarchy_r): Add stream parameter. Emit more information. (dump_class_hierarchy): Add file parameter. Append to file, if required. (finish_vtbls): Adjust accumulate_vtbl_inits call. Use canonical base for virtual bases. (build_vtt): Add more comments. Adjust build_vtt_inits call. (build_vtt_inits): Remove VIRTUAL_VTTS_P parm. Only set BINFO_VPTR_INDEX on top level. Use VTT_TOP_LEVEL_P, VTT_MARKED_BINFO_P for binfo walking. Use canonical vbase for virtual VTTs. (dfs_build_secondary_vptr_vtt_inits): Extract VTT_TOP_LEVEL_P from DATA. We want virtual primary bases and all bases via virtual. Only set BINFO_VPTR_INDEX for top level. Look up from a primary virtual base when not a construction vtable. (dfs_ctor_vtable_bases_queue_p): New DFS predicate. (build_ctor_vtbl_group): Adjust accumulate_vtbl_inits call. Use canonical bases when processing virtual bases. (accumulate_vtbl_inits): We're interested in any base via a virtual path. (dfs_accumulate_vtbl_inits): If this is a primary virtual base within a construction vtable, determine what is being overridden. (build_vtbl_initializer): Add more comments (add_vcall_offset_vtbl_entries_1): Adjust comment. (build_rtti_vtbl_entries): Check if the base has lost its primary. testsuite: * g++.old-deja/g++.abi/primary2.C: New test. * g++.old-deja/g++.abi/primary3.C: New test. * g++.old-deja/g++.abi/primary4.C: New test. * g++.old-deja/g++.abi/primary5.C: New test. * g++.old-deja/g++.abi/vtable3.h: New test. * g++.old-deja/g++.abi/vtable3a.C: New test. * g++.old-deja/g++.abi/vtable3b.C: New test. * g++.old-deja/g++.abi/vtable3c.C: New test. * g++.old-deja/g++.abi/vtable3d.C: New test. * g++.old-deja/g++.abi/vtable3e.C: New test. * g++.old-deja/g++.abi/vtable3f.C: New test. * g++.old-deja/g++.abi/vtable3g.C: New test. * g++.old-deja/g++.abi/vtable3h.C: New test. * g++.old-deja/g++.abi/vtable3i.C: New test. * g++.old-deja/g++.abi/vtable3j.C: New test. * g++.old-deja/g++.oliva/thunk1.C: Remove XFAIL. From-SVN: r39455
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r--gcc/cp/init.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 7cd6c5739d6..e7d62934d6d 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -137,7 +137,7 @@ dfs_initialize_vtbl_ptrs (binfo, data)
tree binfo;
void *data;
{
- if (!BINFO_PRIMARY_MARKED_P (binfo)
+ if ((!BINFO_PRIMARY_P (binfo) || TREE_VIA_VIRTUAL (binfo))
&& CLASSTYPE_VFIELDS (BINFO_TYPE (binfo)))
{
tree base_ptr = TREE_VALUE ((tree) data);
@@ -802,16 +802,27 @@ static tree
build_vtbl_address (binfo)
tree binfo;
{
+ tree binfo_for = binfo;
tree vtbl;
+ if (BINFO_VPTR_INDEX (binfo) && TREE_VIA_VIRTUAL (binfo)
+ && BINFO_PRIMARY_P (binfo))
+ /* If this is a virtual primary base, then the vtable we want to store
+ is that for the base this is being used as the primary base of. We
+ can't simply skip the initialization, because we may be expanding the
+ inits of a subobject constructor where the virtual base layout
+ can be different. */
+ while (BINFO_PRIMARY_BASE_OF (binfo_for))
+ binfo_for = BINFO_PRIMARY_BASE_OF (binfo_for);
+
/* Figure out what vtable BINFO's vtable is based on, and mark it as
used. */
- vtbl = get_vtbl_decl_for_binfo (binfo);
+ vtbl = get_vtbl_decl_for_binfo (binfo_for);
assemble_external (vtbl);
TREE_USED (vtbl) = 1;
/* Now compute the address to use when initializing the vptr. */
- vtbl = BINFO_VTABLE (binfo);
+ vtbl = BINFO_VTABLE (binfo_for);
if (TREE_CODE (vtbl) == VAR_DECL)
{
vtbl = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (vtbl)), vtbl);