diff options
author | Mark Mitchell <mark@codesourcery.com> | 1999-06-16 10:15:35 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 1999-06-16 10:15:35 +0000 |
commit | f33e32a8ccd4963e4f5b0616f6f08502c2a7df72 (patch) | |
tree | adc23bf6c9b959ce6ce06b4649c61cb83d76b9c3 /gcc/cp | |
parent | 8c225122ffcee090ea1afa0b333afbf09241e19c (diff) | |
download | gcc-f33e32a8ccd4963e4f5b0616f6f08502c2a7df72.zip gcc-f33e32a8ccd4963e4f5b0616f6f08502c2a7df72.tar.gz gcc-f33e32a8ccd4963e4f5b0616f6f08502c2a7df72.tar.bz2 |
init.c (expand_cleanup_for_base): New function, split out from ...
* init.c (expand_cleanup_for_base): New function, split out
from ...
(emit_base_init): Here.
(expand_aggr_vbase_init): Use it.
From-SVN: r27543
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/init.c | 36 |
2 files changed, 31 insertions, 12 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0f87c30..53e5f614 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +1999-06-16 Mark Mitchell <mark@codesourcery.com> + + * init.c (expand_cleanup_for_base): New function, split out + from ... + (emit_base_init): Here. + (expand_aggr_vbase_init): Use it. + 1999-06-15 Mark Mitchell <mark@codesourcery.com> * cp-tree.h (class_cache_firstobj): Declare. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index fc500e6..852bb0b 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -60,6 +60,7 @@ static tree initializing_context PROTO((tree)); static void expand_vec_init_try_block PROTO((tree)); static void expand_vec_init_catch_clause PROTO((tree, tree, tree, tree)); static tree build_java_class_ref PROTO((tree)); +static void expand_cleanup_for_base PROTO((tree)); /* Cache the identifier nodes for the magic field of a new cookie. */ static tree nc_nelts_field_id; @@ -597,18 +598,7 @@ emit_base_init (t, immediately) free_temp_slots (); } - if (TYPE_NEEDS_DESTRUCTOR (BINFO_TYPE (base_binfo))) - { - tree expr; - - /* All cleanups must be on the function_obstack. */ - push_obstacks_nochange (); - resume_temporary_allocation (); - expr = build_partial_cleanup_for (base_binfo); - pop_obstacks (); - add_partial_entry (expr); - } - + expand_cleanup_for_base (base_binfo); rbase_init_list = TREE_CHAIN (rbase_init_list); } @@ -765,6 +755,27 @@ expand_virtual_init (binfo, decl) expand_expr_stmt (build_modify_expr (vtbl_ptr, NOP_EXPR, vtbl)); } +/* If an exception is thrown in a constructor, those base classes already + constructed must be destroyed. This function creates the cleanup + for BINFO, which has just been constructed. */ + +static void +expand_cleanup_for_base (binfo) + tree binfo; +{ + tree expr; + + if (!TYPE_NEEDS_DESTRUCTOR (BINFO_TYPE (binfo))) + return; + + /* All cleanups must be on the function_obstack. */ + push_obstacks_nochange (); + resume_temporary_allocation (); + expr = build_partial_cleanup_for (binfo); + pop_obstacks (); + add_partial_entry (expr); +} + /* Subroutine of `expand_aggr_vbase_init'. BINFO is the binfo of the type that is being initialized. INIT_LIST is the list of initializers for the virtual baseclass. */ @@ -816,6 +827,7 @@ expand_aggr_vbase_init (binfo, exp, addr, init_list) expand_aggr_vbase_init_1 (vbases, exp, TREE_OPERAND (TREE_VALUE (tmp), 0), init_list); + expand_cleanup_for_base (vbases); } } } |