]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
init.c (expand_cleanup_for_base): New function, split out from ...
authorMark Mitchell <mark@codesourcery.com>
Wed, 16 Jun 1999 10:27:16 +0000 (10:27 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 16 Jun 1999 10:27:16 +0000 (10:27 +0000)
* init.c (expand_cleanup_for_base): New function, split out
from ...
(emit_base_init): Here.
(expand_aggr_vbase_init): Use it.

From-SVN: r27544

gcc/cp/ChangeLog
gcc/cp/init.c

index 538595a1550413f40f3a6cbac294d5861529e010..071fe416072ce313d96bce17cb7a5ab21ce8f3b5 100644 (file)
@@ -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.
index 7fb203007dea9bc2ee6a41272339b376fac3e902..eb5881979a85b9c5e8118973acbe2c86de4521c5 100644 (file)
@@ -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;
@@ -593,18 +594,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);
     }
 
@@ -766,6 +756,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.  */
@@ -817,6 +828,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);
        }
     }
 }