Commit 0b8a1e58 by Mark Mitchell Committed by Mark Mitchell

init.c (expand_aggr_vbase_init): Add flag parameter.

	* init.c (expand_aggr_vbase_init): Add flag parameter.
	(build_partial_cleanup_for): Remove, inlining into ..
	(expand_cleanup_for_base): ... here.  Take flag parameter.
	(emit_base_init): Pass the in_chrg parameter to
	emit_aggr_vbase_init.
	(emit_aggr_vbase_init): Pass it to expand_cleanup_for_base.

From-SVN: r27600
parent 34cea4e9
1999-06-18 Mark Mitchell <mark@codesourcery.com>
* init.c (expand_aggr_vbase_init): Add flag parameter.
(build_partial_cleanup_for): Remove, inlining into ..
(expand_cleanup_for_base): ... here. Take flag parameter.
(emit_base_init): Pass the in_chrg parameter to
emit_aggr_vbase_init.
(emit_aggr_vbase_init): Pass it to expand_cleanup_for_base.
1999-06-16 Mark Mitchell <mark@codesourcery.com> 1999-06-16 Mark Mitchell <mark@codesourcery.com>
* decl2.c (import_export_decl): Use same_type_p, rather than * decl2.c (import_export_decl): Use same_type_p, rather than
......
...@@ -44,7 +44,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -44,7 +44,7 @@ Boston, MA 02111-1307, USA. */
tree current_base_init_list, current_member_init_list; tree current_base_init_list, current_member_init_list;
static void expand_aggr_vbase_init_1 PROTO((tree, tree, tree, tree)); static void expand_aggr_vbase_init_1 PROTO((tree, tree, tree, tree));
static void expand_aggr_vbase_init PROTO((tree, tree, tree, tree)); static void expand_aggr_vbase_init PROTO((tree, tree, tree, tree, tree));
static void expand_aggr_init_1 PROTO((tree, tree, tree, tree, int)); static void expand_aggr_init_1 PROTO((tree, tree, tree, tree, int));
static void expand_default_init PROTO((tree, tree, tree, tree, int)); static void expand_default_init PROTO((tree, tree, tree, tree, int));
static tree build_vec_delete_1 PROTO((tree, tree, tree, tree, tree, static tree build_vec_delete_1 PROTO((tree, tree, tree, tree, tree,
...@@ -55,12 +55,11 @@ static tree build_builtin_delete_call PROTO((tree)); ...@@ -55,12 +55,11 @@ static tree build_builtin_delete_call PROTO((tree));
static int member_init_ok_or_else PROTO((tree, tree, const char *)); static int member_init_ok_or_else PROTO((tree, tree, const char *));
static void expand_virtual_init PROTO((tree, tree)); static void expand_virtual_init PROTO((tree, tree));
static tree sort_member_init PROTO((tree)); static tree sort_member_init PROTO((tree));
static tree build_partial_cleanup_for PROTO((tree));
static tree initializing_context PROTO((tree)); static tree initializing_context PROTO((tree));
static void expand_vec_init_try_block PROTO((tree)); static void expand_vec_init_try_block PROTO((tree));
static void expand_vec_init_catch_clause PROTO((tree, tree, tree, tree)); static void expand_vec_init_catch_clause PROTO((tree, tree, tree, tree));
static tree build_java_class_ref PROTO((tree)); static tree build_java_class_ref PROTO((tree));
static void expand_cleanup_for_base PROTO((tree)); static void expand_cleanup_for_base PROTO((tree, tree));
/* Cache the identifier nodes for the magic field of a new cookie. */ /* Cache the identifier nodes for the magic field of a new cookie. */
static tree nc_nelts_field_id; static tree nc_nelts_field_id;
...@@ -483,17 +482,6 @@ sort_base_init (t, rbase_ptr, vbase_ptr) ...@@ -483,17 +482,6 @@ sort_base_init (t, rbase_ptr, vbase_ptr)
*vbase_ptr = vbases; *vbase_ptr = vbases;
} }
/* Perform partial cleanups for a base for exception handling. */
static tree
build_partial_cleanup_for (binfo)
tree binfo;
{
return build_scoped_method_call
(current_class_ref, binfo, dtor_identifier,
build_expr_list (NULL_TREE, integer_zero_node));
}
/* Perform whatever initializations have yet to be done on the base /* Perform whatever initializations have yet to be done on the base
class of the class variable. These actions are in the global class of the class variable. These actions are in the global
variable CURRENT_BASE_INIT_LIST. Such an action could be variable CURRENT_BASE_INIT_LIST. Such an action could be
...@@ -559,7 +547,7 @@ emit_base_init (t, immediately) ...@@ -559,7 +547,7 @@ emit_base_init (t, immediately)
expand_start_cond (first_arg, 0); expand_start_cond (first_arg, 0);
expand_aggr_vbase_init (t_binfo, current_class_ref, current_class_ptr, expand_aggr_vbase_init (t_binfo, current_class_ref, current_class_ptr,
vbase_init_list); vbase_init_list, first_arg);
expand_end_cond (); expand_end_cond ();
} }
...@@ -598,7 +586,7 @@ emit_base_init (t, immediately) ...@@ -598,7 +586,7 @@ emit_base_init (t, immediately)
free_temp_slots (); free_temp_slots ();
} }
expand_cleanup_for_base (base_binfo); expand_cleanup_for_base (base_binfo, NULL_TREE);
rbase_init_list = TREE_CHAIN (rbase_init_list); rbase_init_list = TREE_CHAIN (rbase_init_list);
} }
...@@ -757,11 +745,14 @@ expand_virtual_init (binfo, decl) ...@@ -757,11 +745,14 @@ expand_virtual_init (binfo, decl)
/* If an exception is thrown in a constructor, those base classes already /* If an exception is thrown in a constructor, those base classes already
constructed must be destroyed. This function creates the cleanup constructed must be destroyed. This function creates the cleanup
for BINFO, which has just been constructed. */ for BINFO, which has just been constructed. If FLAG is non-NULL,
it is a DECL which is non-zero when this base needs to be
destroyed. */
static void static void
expand_cleanup_for_base (binfo) expand_cleanup_for_base (binfo, flag)
tree binfo; tree binfo;
tree flag;
{ {
tree expr; tree expr;
...@@ -771,7 +762,16 @@ expand_cleanup_for_base (binfo) ...@@ -771,7 +762,16 @@ expand_cleanup_for_base (binfo)
/* All cleanups must be on the function_obstack. */ /* All cleanups must be on the function_obstack. */
push_obstacks_nochange (); push_obstacks_nochange ();
resume_temporary_allocation (); resume_temporary_allocation ();
expr = build_partial_cleanup_for (binfo);
/* Call the destructor. */
expr = (build_scoped_method_call
(current_class_ref, binfo, dtor_identifier,
build_expr_list (NULL_TREE, integer_zero_node)));
if (flag)
expr = fold (build (COND_EXPR, void_type_node,
truthvalue_conversion (flag),
expr, integer_zero_node));
pop_obstacks (); pop_obstacks ();
add_partial_entry (expr); add_partial_entry (expr);
} }
...@@ -804,11 +804,12 @@ expand_aggr_vbase_init_1 (binfo, exp, addr, init_list) ...@@ -804,11 +804,12 @@ expand_aggr_vbase_init_1 (binfo, exp, addr, init_list)
INIT_LIST is list of initialization for constructor to perform. */ INIT_LIST is list of initialization for constructor to perform. */
static void static void
expand_aggr_vbase_init (binfo, exp, addr, init_list) expand_aggr_vbase_init (binfo, exp, addr, init_list, flag)
tree binfo; tree binfo;
tree exp; tree exp;
tree addr; tree addr;
tree init_list; tree init_list;
tree flag;
{ {
tree type = BINFO_TYPE (binfo); tree type = BINFO_TYPE (binfo);
...@@ -827,7 +828,7 @@ expand_aggr_vbase_init (binfo, exp, addr, init_list) ...@@ -827,7 +828,7 @@ expand_aggr_vbase_init (binfo, exp, addr, init_list)
expand_aggr_vbase_init_1 (vbases, exp, expand_aggr_vbase_init_1 (vbases, exp,
TREE_OPERAND (TREE_VALUE (tmp), 0), TREE_OPERAND (TREE_VALUE (tmp), 0),
init_list); init_list);
expand_cleanup_for_base (vbases); expand_cleanup_for_base (vbases, flag);
} }
} }
} }
......
// Origin: Mark Mitchell <mark@codesourcery.com>
int i;
struct A
{
A () { i++; }
~A () { i--; }
};
struct B : public virtual A
{
B () { throw 1; }
};
struct D: public B, virtual public A
{
};
void f()
{
D d;
}
int main ()
{
try {
f();
} catch (int) {
}
return i;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment