From bbd15aac6fc179e9cb610f89f681c574a68f038c Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Mon, 17 Jan 2000 04:08:01 +0000 Subject: cp-tree.h (flag_new_abi): Move. * cp-tree.h (flag_new_abi): Move. (flag_use_cxa_atexit): Likewise. (flag_honor_std): Likewise. (flag_rtti): Likewise. (vbase_offsets_in_vtable_p): Define. (vptrs_present_everywhere_p): Likewise. (TYPE_CONTAINS_VPTR_P): Likewise. (dfs_walk_real): Declare. * class.c (build_vbase_pointer_fields): Check vbase_offsets_in_vtable_p. (dfs_build_vbase_offset_vtbl_entries): Record the vbase indices in BINFO_VPTR_FIELD. (build_vbase_offset_vtbl_entries): Simplify. (build_vbase_offset_vtbl_entries): Adjust. (build_vbase_pointer): Add ability to look up vbase offsets in vtable. (start_vtable): New function. (add_virtual_function): Use it. (determine_primary_base): Use TYPE_CONTAINS_VPTR_P. (num_extra_vtbl_entries): Use vbase_offsets_in_vtable_p. (build_vtbl_initializer): Take the type of the complete object as input. Use it to correctly calculate vbase offsets. (dfs_finish_vtbls): Pass the complete type to build_vtbl_initializer. (check_bases_and_members): Use TYPE_CONTAINS_VPTR_P. (create_vtable_ptr): Create a vtable even if there are no new virtual functions, under the new ABI. (finish_struct_1): Likewise. (get_vfield_name): Use TYPE_CONTAINS_VPTR_P. * decl.c (exapnd_static_init): Remove call to preserve_initializer. * decl2.c (mark_vtable_entries): Tweak to handle vbase offsets in vtables. * init.c (initialize_vtbl_ptrs): Initialize them in pre-order. (expand_virtual_init): Use vbase_offsets_in_vtable_p. (construct_virtual_bases): Don't initialize virtual base pointers under the new ABI. (build_aggr_init): Clean up comment. (expand_aggr_init_1): Likewise. * rtti.c (expand_class_desc): Store the virtual function table index where the vbase offset lives in the offset field. * search.c (dfs_walk_real): Make it global. (dfs_debug_mark): Use TYPE_CONTAINS_VPTR_P. * tree.c (make_binfo): Don't clear BINFO_VPTR_FIELD. * tinfo.h (USItype): Make it signed under the new ABI. * tinfo.cc (convert_to_base): New function. Encapsulate base conversion logic here. (__class_type_info::do_upcast): Use it. (__class_type_info::do_dyncast): Likewise. (__class_type_info::do_find_public_subobj): Likewise. From-SVN: r31452 --- gcc/cp/init.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'gcc/cp/init.c') diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 3828ddf..b5a1ac4 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -119,8 +119,12 @@ initialize_vtbl_ptrs (type, addr) { tree list = build_tree_list (type, addr); - dfs_walk (TYPE_BINFO (type), dfs_initialize_vtbl_ptrs, - dfs_unmarked_real_bases_queue_p, list); + /* Walk through the hierarchy, initializing the vptr in each base + class. We do these in pre-order because under the new ABI we + can't find the virtual bases for a class until we've initialized + the vtbl for that class. */ + dfs_walk_real (TYPE_BINFO (type), dfs_initialize_vtbl_ptrs, + NULL, dfs_unmarked_real_bases_queue_p, list); dfs_walk (TYPE_BINFO (type), dfs_unmark, dfs_marked_real_bases_queue_p, type); if (TYPE_USES_VIRTUAL_BASECLASSES (type)) @@ -657,7 +661,7 @@ expand_virtual_init (binfo, decl) 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) + if (vbase_offsets_in_vtable_p ()) vtbl = build (PLUS_EXPR, TREE_TYPE (vtbl), vtbl, size_extra_vtbl_entries (binfo)); @@ -720,7 +724,7 @@ expand_aggr_vbase_init_1 (binfo, exp, addr, init_list) /* Construct the virtual base-classes of THIS_REF (whose address is THIS_PTR). The object has the indicated TYPE. The construction actually takes place only if FLAG is non-zero. INIT_LIST is list - of initialization for constructor to perform. */ + of initializations for constructors to perform. */ static void construct_virtual_bases (type, this_ref, this_ptr, init_list, flag) @@ -731,21 +735,25 @@ construct_virtual_bases (type, this_ref, this_ptr, init_list, flag) tree flag; { tree vbases; - tree result; - tree if_stmt; /* If there are no virtual baseclasses, we shouldn't even be here. */ my_friendly_assert (TYPE_USES_VIRTUAL_BASECLASSES (type), 19990621); /* First set the pointers in our object that tell us where to find our virtual baseclasses. */ - if_stmt = begin_if_stmt (); - finish_if_stmt_cond (flag, if_stmt); - result = init_vbase_pointers (type, this_ptr); - if (result) - finish_expr_stmt (build_compound_expr (result)); - finish_then_clause (if_stmt); - finish_if_stmt (); + if (!vbase_offsets_in_vtable_p ()) + { + tree if_stmt; + tree result; + + if_stmt = begin_if_stmt (); + finish_if_stmt_cond (flag, if_stmt); + result = init_vbase_pointers (type, this_ptr); + if (result) + finish_expr_stmt (build_compound_expr (result)); + finish_then_clause (if_stmt); + finish_if_stmt (); + } /* Now, run through the baseclasses, initializing each. */ for (vbases = CLASSTYPE_VBASECLASSES (type); vbases; @@ -1019,11 +1027,6 @@ finish_init_stmts (stmt_expr, compound_stmt) If `init' is a CONSTRUCTOR, then we emit a warning message, explaining that such initializations are invalid. - ALIAS_THIS is nonzero iff we are initializing something which is - essentially an alias for current_class_ref. In this case, the base - constructor may move it on us, and we must keep track of such - deviations. - If INIT resolves to a CALL_EXPR which happens to return something of the type we are looking for, then we know that we can safely use that call to perform the @@ -1217,8 +1220,6 @@ expand_default_init (binfo, true_exp, exp, init, flags) from TRUE_EXP. In constructors, we don't know anything about the value being initialized. - ALIAS_THIS serves the same purpose it serves for expand_aggr_init. - FLAGS is just passes to `build_method_call'. See that function for its description. */ -- cgit v1.1