aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.c
diff options
context:
space:
mode:
authorJason Merrill <jason@gcc.gnu.org>2002-04-03 19:11:00 -0500
committerJason Merrill <jason@gcc.gnu.org>2002-04-03 19:11:00 -0500
commit659e5a7aa97fad95cccf792deb73810f906c1a80 (patch)
treee7c013fd4dcc1ce433e1cbcd41032def785b9193 /gcc/cp/semantics.c
parent053d3344d411a28cb7d59ea924e7e81caa0255e8 (diff)
downloadgcc-659e5a7aa97fad95cccf792deb73810f906c1a80.zip
gcc-659e5a7aa97fad95cccf792deb73810f906c1a80.tar.gz
gcc-659e5a7aa97fad95cccf792deb73810f906c1a80.tar.bz2
re PR c++/5636 (gcc-3.0.3, memory leakage: function that take a string as parameter will not call local variable destructors if exception is thrown.)
PR c++/5636 * tree.h (CLEANUP_EH_ONLY): New macro. * stmt.c (expand_decl_cleanup_eh): New fn. (expand_cleanups): Check CLEANUP_EH_ONLY. * c-semantics.c (genrtl_decl_cleanup): Just take the CLEANUP_STMT. Use expand_decl_cleanup_eh. (expand_stmt): Adjust. * c-common.h: Adjust prototype. * cp/semantics.c (nullify_returns_r): Just set CLEANUP_EH_ONLY on cleanup for nrv. * except.c (struct eh_status): Remove protect_list. (begin_protect_partials, end_protect_partials): Remove. (add_partial_entry): Remove. * except.h: Remove prototypes. * expr.c (expand_expr) [WITH_CLEANUP_EXPR, TARGET_EXPR]: Use expand_decl_cleanup_eh. cp/: * semantics.c (finish_eh_cleanup): New fn. * cp-tree.h: Add prototype. * init.c (perform_member_init, expand_cleanup_for_base): Use finish_eh_cleanup. * cp-tree.def (SUBOBJECT, CTOR_STMT): Remove. * cp-tree.h: Remove references. * decl.c (begin_constructor_body, end_constructor_body): Likewise. * dump.c (cp_dump_tree): Likewise. * pt.c (tsubst_expr): Likewise. * semantics.c (genrtl_ctor_stmt, genrtl_subobject): Remove. (cp_expand_stmt): Remove handling of CTOR_STMT and SUBOBJECT. * tree.c (cp_statement_code_p): Likewise. * init.c (build_new_1): Set CLEANUP_EH_ONLY on deleting cleanup. From-SVN: r51827
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r--gcc/cp/semantics.c57
1 files changed, 11 insertions, 46 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 8666d7f..ee609f4 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -56,8 +56,6 @@ static void emit_associated_thunks PARAMS ((tree));
static void genrtl_try_block PARAMS ((tree));
static void genrtl_eh_spec_block PARAMS ((tree));
static void genrtl_handler PARAMS ((tree));
-static void genrtl_ctor_stmt PARAMS ((tree));
-static void genrtl_subobject PARAMS ((tree));
static void genrtl_named_return_value PARAMS ((void));
static void cp_expand_stmt PARAMS ((tree));
static void genrtl_start_function PARAMS ((tree));
@@ -777,21 +775,6 @@ finish_handler (handler)
RECHAIN_STMTS (handler, HANDLER_BODY (handler));
}
-/* Generate the RTL for T, which is a CTOR_STMT. */
-
-static void
-genrtl_ctor_stmt (t)
- tree t;
-{
- if (CTOR_BEGIN_P (t))
- begin_protect_partials ();
- else
- /* After this point, any exceptions will cause the
- destructor to be executed, so we no longer need to worry
- about destroying the various subobjects ourselves. */
- end_protect_partials ();
-}
-
/* Begin a compound-statement. If HAS_NO_SCOPE is non-zero, the
compound-statement does not define a scope. Returns a new
COMPOUND_STMT if appropriate. */
@@ -976,35 +959,25 @@ finish_label_decl (name)
add_decl_stmt (decl);
}
-/* Generate the RTL for a SUBOBJECT. */
-
-static void
-genrtl_subobject (cleanup)
- tree cleanup;
-{
- add_partial_entry (cleanup);
-}
-
-/* We're in a constructor, and have just constructed a a subobject of
- *THIS. CLEANUP is code to run if an exception is thrown before the
- end of the current function is reached. */
+/* When DECL goes out of scope, make sure that CLEANUP is executed. */
void
-finish_subobject (cleanup)
+finish_decl_cleanup (decl, cleanup)
+ tree decl;
tree cleanup;
{
- tree r = build_stmt (SUBOBJECT, cleanup);
- add_stmt (r);
+ add_stmt (build_stmt (CLEANUP_STMT, decl, cleanup));
}
-/* When DECL goes out of scope, make sure that CLEANUP is executed. */
+/* If the current scope exits with an exception, run CLEANUP. */
-void
-finish_decl_cleanup (decl, cleanup)
- tree decl;
+void
+finish_eh_cleanup (cleanup)
tree cleanup;
{
- add_stmt (build_stmt (CLEANUP_STMT, decl, cleanup));
+ tree r = build_stmt (CLEANUP_STMT, NULL_TREE, cleanup);
+ CLEANUP_EH_ONLY (r) = 1;
+ add_stmt (r);
}
/* Generate the RTL for a RETURN_INIT. */
@@ -2130,10 +2103,6 @@ cp_expand_stmt (t)
{
switch (TREE_CODE (t))
{
- case CTOR_STMT:
- genrtl_ctor_stmt (t);
- break;
-
case TRY_BLOCK:
genrtl_try_block (t);
break;
@@ -2146,10 +2115,6 @@ cp_expand_stmt (t)
genrtl_handler (t);
break;
- case SUBOBJECT:
- genrtl_subobject (SUBOBJECT_CLEANUP (t));
- break;
-
case RETURN_INIT:
genrtl_named_return_value ();
break;
@@ -2458,7 +2423,7 @@ nullify_returns_r (tp, walk_subtrees, data)
RETURN_EXPR (*tp) = NULL_TREE;
else if (TREE_CODE (*tp) == CLEANUP_STMT
&& CLEANUP_DECL (*tp) == nrv)
- CLEANUP_EXPR (*tp) = NULL_TREE;
+ CLEANUP_EH_ONLY (*tp) = 1;
/* Keep iterating. */
return NULL_TREE;