From 70ae32012466e09d67dd4eed3f74ea74f9c2629e Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Sun, 16 Jan 2000 16:59:44 +0000 Subject: cp-tree.h (num_extra_vtbl_entries): New function. * cp-tree.h (num_extra_vtbl_entries): New function. (size_extra_vtbl_entries): Likewise. (dfs_vtable_path_unmark): Likewise. (dfs_vtable_path_unmarked_real_bases_queue_p): Likewise. (dfs_vtable_path_marked_real_bases_queue_p): Likewise. * class.c (num_extra_vtbl_entries): New function. (size_extra_vtbl_entries): Likewise. (dfs_build_vbase_offset_vtbl_entries): New function. (build_vbase_offset_vtbl_entries): Likewise. (build_vtbl_initializer): Use it. (finish_struct_1): Adjust vtable sizes (using num_extra_vtbl_entries). * expr.c (cplus_expand_expr): Assert that the DECL_RTL for a THUNK_DECL is non-NULL before expanding it. * init.c (expand_virtual_init): Adjust the vtable pointer by size_extra_vtbl_entries before storing it. * search.c (get_shared_vase_if_not_primary): Adjust prototype. Handle TREE_LIST parameters here, not in the dfs_* functions. (dfs_unmarked_real_bases_queue_p): Adjust. (dfs_marked_real_bases_queue_p): Likewise. (dfs_vtable_path_unmarked_real_bases_queue_p): New function. (dfs_vtable_path_marked_real_bases_queue_p): New function. (dfs_vtable_path_unmark): Likewise. From-SVN: r31439 --- gcc/cp/init.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'gcc/cp/init.c') diff --git a/gcc/cp/init.c b/gcc/cp/init.c index ed2a3d7..12815e4 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -648,21 +648,26 @@ expand_virtual_init (binfo, decl) tree vtbl, vtbl_ptr; tree vtype, vtype_binfo; - /* This code is crusty. Should be simple, like: - vtbl = BINFO_VTABLE (binfo); - */ + /* Compute the location of the vtable. */ vtype = DECL_CONTEXT (TYPE_VFIELD (type)); vtype_binfo = get_binfo (vtype, TREE_TYPE (TREE_TYPE (decl)), 0); vtbl = BINFO_VTABLE (binfo_value (DECL_FIELD_CONTEXT (TYPE_VFIELD (type)), binfo)); assemble_external (vtbl); TREE_USED (vtbl) = 1; vtbl = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (vtbl)), vtbl); + /* Under the new ABI, we need to point into the middle of the + vtable. */ + if (flag_new_abi) + vtbl = build (PLUS_EXPR, TREE_TYPE (vtbl), vtbl, + size_extra_vtbl_entries (binfo)); + + /* Compute the location of the vtpr. */ decl = convert_pointer_to_real (vtype_binfo, decl); vtbl_ptr = build_vfield_ref (build_indirect_ref (decl, NULL_PTR), vtype); if (vtbl_ptr == error_mark_node) return; - /* Have to convert VTBL since array sizes may be different. */ + /* Assign the vtable to the vptr. */ vtbl = convert_force (TREE_TYPE (vtbl_ptr), vtbl, 0); finish_expr_stmt (build_modify_expr (vtbl_ptr, NOP_EXPR, vtbl)); } -- cgit v1.1