aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1997-11-13 10:11:23 +0000
committerJason Merrill <jason@gcc.gnu.org>1997-11-13 05:11:23 -0500
commit2bb14213a3fac412c17a8efd98002c179ba18e92 (patch)
treeab36013a115b62a05ba29f8fb346d2c7873502ab
parent4699894f5bbe6958e82233d3f5581f0aca4aa67d (diff)
downloadgcc-2bb14213a3fac412c17a8efd98002c179ba18e92.zip
gcc-2bb14213a3fac412c17a8efd98002c179ba18e92.tar.gz
gcc-2bb14213a3fac412c17a8efd98002c179ba18e92.tar.bz2
init.c (build_new): Make the cleanup last longer.
* init.c (build_new): Make the cleanup last longer. (expand_vec_init): Call do_pending_stack_adjust. From-SVN: r16451
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/init.c18
2 files changed, 22 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index aba5147..270602e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+Thu Nov 13 01:52:36 1997 Jason Merrill <jason@yorick.cygnus.com>
+
+ * init.c (build_new): Make the cleanup last longer.
+ (expand_vec_init): Call do_pending_stack_adjust.
+
Wed Nov 12 11:04:33 1997 Jason Merrill <jason@yorick.cygnus.com>
* pt.c (do_type_instantiation): Fix typo.
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 9dd1c7f..c1df1d9 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -2522,7 +2522,16 @@ build_new (placement, decl, init, use_global_new)
TREE_CALLS_NEW (rval) = 1;
}
- if ((flag_exceptions || check_new) && rval)
+ if (flag_exceptions && rval)
+ {
+ /* This must last longer so we can use it in the cleanup.
+ The subexpressions don't need to last, because we won't look at
+ them when expanding the cleanup. */
+ int yes = suspend_momentary ();
+ alloc_expr = rval = save_expr (rval);
+ resume_momentary (yes);
+ }
+ else if (check_new && rval)
alloc_expr = rval = save_expr (rval);
else
alloc_expr = NULL_TREE;
@@ -2715,6 +2724,9 @@ build_new (placement, decl, init, use_global_new)
{
tree cleanup = alloc_expr;
+ /* All cleanups must last longer than normal. */
+ int yes = suspend_momentary ();
+
if (! use_global_new && TYPE_LANG_SPECIFIC (true_type)
&& (TYPE_GETS_DELETE (true_type) & (1 << has_array)))
cleanup = build_opfncall (has_array? VEC_DELETE_EXPR : DELETE_EXPR,
@@ -2723,6 +2735,8 @@ build_new (placement, decl, init, use_global_new)
cleanup = build_builtin_call
(void_type_node, has_array ? BIVD : BID,
build_expr_list (NULL_TREE, cleanup));
+
+ resume_momentary (yes);
rval = build (TRY_CATCH_EXPR, TREE_TYPE (rval), rval, cleanup);
rval = build (COMPOUND_EXPR, TREE_TYPE (rval), alloc_expr, rval);
@@ -3132,6 +3146,7 @@ expand_vec_init (decl, base, maxindex, init, from_array)
TREE_TYPE (cleanup) = void_type_node;
RTL_EXPR_RTL (cleanup) = const0_rtx;
TREE_SIDE_EFFECTS (cleanup) = 1;
+ do_pending_stack_adjust ();
start_sequence_for_rtl_expr (cleanup);
e1 = build_array_eh_cleanup
@@ -3139,6 +3154,7 @@ expand_vec_init (decl, base, maxindex, init, from_array)
build_binary_op (MINUS_EXPR, maxindex, iterator, 1),
type);
expand_expr (e1, const0_rtx, VOIDmode, EXPAND_NORMAL);
+ do_pending_stack_adjust ();
RTL_EXPR_SEQUENCE (cleanup) = get_insns ();
end_sequence ();