diff options
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 19 | ||||
-rw-r--r-- | gcc/cp/cp-tree.def | 10 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 11 | ||||
-rw-r--r-- | gcc/cp/decl.c | 9 | ||||
-rw-r--r-- | gcc/cp/dump.c | 15 | ||||
-rw-r--r-- | gcc/cp/init.c | 10 | ||||
-rw-r--r-- | gcc/cp/pt.c | 4 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 57 | ||||
-rw-r--r-- | gcc/cp/tree.c | 2 |
9 files changed, 37 insertions, 100 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 15e12d6858c..756d2b30c63 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,24 @@ 2002-04-04 Jason Merrill <jason@redhat.com> + * 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. + + PR c++/5636 + * semantics.c (nullify_returns_r): Just set CLEANUP_EH_ONLY on + cleanup for nrv. + PR c++/5104 * typeck.c (comptypes) [FUNCTION_TYPE]: Don't compare exception specifiers. diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def index 38545256114..1bf4c0d2ec6 100644 --- a/gcc/cp/cp-tree.def +++ b/gcc/cp/cp-tree.def @@ -220,16 +220,6 @@ DEFTREECODE (DOTSTAR_EXPR, "dotstar_expr", 'e', 2) DEFTREECODE (TYPEID_EXPR, "typeid_expr", 'e', 1) DEFTREECODE (PSEUDO_DTOR_EXPR, "pseudo_dtor_expr", 'e', 3) -/* A SUBOBJECT statement marks the point at which a sub-object is - fully constructed. After this point, the SUBOBJECT_CLEANUP must be - run if an exception is thrown before the end of the enclosing - function. */ -DEFTREECODE (SUBOBJECT, "subobject", 'e', 1) -/* An CTOR_STMT marks the beginning (if CTOR_BEGIN_P holds) or end of - a constructor (if CTOR_END_P) holds. At the end of a constructor, - the cleanups associated with any SUBOBJECT_CLEANUPS need no longer - be run. */ -DEFTREECODE (CTOR_STMT, "ctor_stmt", 'e', 0) /* CTOR_INITIALIZER is a placeholder in template code for a call to setup_vtbl_pointer (and appears in all functions, not just ctors). */ DEFTREECODE (CTOR_INITIALIZER, "ctor_initializer", 'e', 2) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index dbd95550242..b65467bae1d 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -47,7 +47,6 @@ struct diagnostic_context; ICS_USER_FLAG (in _CONV) CLEANUP_P (in TRY_BLOCK) AGGR_INIT_VIA_CTOR_P (in AGGR_INIT_EXPR) - CTOR_BEGIN_P (in CTOR_STMT) BV_USE_VCALL_INDEX_P (in the BINFO_VIRTUALS TREE_LIST) PTRMEM_OK_P (in ADDR_EXPR, OFFSET_REF) PARMLIST_ELLIPSIS_P (in PARMLIST) @@ -2969,15 +2968,6 @@ enum ptrmemfunc_vbit_where_t #define HANDLER_PARMS(NODE) TREE_OPERAND (HANDLER_CHECK (NODE), 0) #define HANDLER_BODY(NODE) TREE_OPERAND (HANDLER_CHECK (NODE), 1) #define HANDLER_TYPE(NODE) TREE_TYPE (HANDLER_CHECK (NODE)) -#define SUBOBJECT_CLEANUP(NODE) TREE_OPERAND (SUBOBJECT_CHECK (NODE), 0) - -/* Nonzero if this CTOR_STMT is for the beginning of a constructor. */ -#define CTOR_BEGIN_P(NODE) \ - (TREE_LANG_FLAG_0 (CTOR_STMT_CHECK (NODE))) - -/* Nonzero if this CTOR_STMT is for the end of a constructor. */ -#define CTOR_END_P(NODE) \ - (!CTOR_BEGIN_P (NODE)) /* The parameters for a call-declarator. */ #define CALL_DECLARATOR_PARMS(NODE) \ @@ -4217,6 +4207,7 @@ extern tree finish_typeof PARAMS ((tree)); extern tree finish_sizeof PARAMS ((tree)); extern tree finish_alignof PARAMS ((tree)); extern void finish_decl_cleanup PARAMS ((tree, tree)); +extern void finish_eh_cleanup PARAMS ((tree)); extern void finish_named_return_value PARAMS ((tree, tree)); extern void expand_body PARAMS ((tree)); extern tree nullify_returns_r PARAMS ((tree *, int *, void *)); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 840dcff2d50..78f1b14a7f3 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -13948,9 +13948,6 @@ save_function_data (decl) static void begin_constructor_body () { - tree ctor_stmt = build_stmt (CTOR_STMT); - CTOR_BEGIN_P (ctor_stmt) = 1; - add_stmt (ctor_stmt); } /* Add a note to mark the end of the main body of the constructor. This is @@ -13960,12 +13957,6 @@ begin_constructor_body () static void finish_constructor_body () { - /* Mark the end of the cleanups for a partially constructed object. - - ??? These should really be handled automatically by closing the block, - as with the destructor cleanups; the only difference is that these are - only run if an exception is thrown. */ - add_stmt (build_stmt (CTOR_STMT)); } /* Do all the processing for the beginning of a destructor; set up the diff --git a/gcc/cp/dump.c b/gcc/cp/dump.c index 6dd60baf73b..e0bc410bcae 100644 --- a/gcc/cp/dump.c +++ b/gcc/cp/dump.c @@ -390,15 +390,6 @@ cp_dump_tree (dump_info, t) dump_child ("decl", TREE_OPERAND (t, 2)); break; - case CTOR_STMT: - dump_stmt (di, t); - if (CTOR_BEGIN_P (t)) - dump_string (di, "begn"); - else - dump_string (di, "end"); - dump_next_stmt (di, t); - break; - case HANDLER: dump_stmt (di, t); dump_child ("parm", HANDLER_PARMS (t)); @@ -412,12 +403,6 @@ cp_dump_tree (dump_info, t) dump_next_stmt (di, t); break; - case SUBOBJECT: - dump_stmt (di, t); - dump_child ("clnp", TREE_OPERAND (t, 0)); - dump_next_stmt (di, t); - break; - case USING_STMT: dump_stmt (di, t); dump_child ("nmsp", USING_STMT_NAMESPACE (t)); diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 10098e72cfa..8b7e1f239a4 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -296,7 +296,7 @@ perform_member_init (member, init, explicit) LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR, 0); if (expr != error_mark_node) - finish_subobject (expr); + finish_eh_cleanup (expr); } } @@ -844,7 +844,7 @@ expand_cleanup_for_base (binfo, flag) truthvalue_conversion (flag), expr, integer_zero_node)); - finish_subobject (expr); + finish_eh_cleanup (expr); } /* Subroutine of `expand_aggr_vbase_init'. @@ -2498,9 +2498,11 @@ build_new_1 (exp) tree end, sentry, begin; begin = get_target_expr (boolean_true_node); - sentry = TREE_OPERAND (begin, 0); + CLEANUP_EH_ONLY (begin) = 1; - TREE_OPERAND (begin, 2) + sentry = TARGET_EXPR_SLOT (begin); + + TARGET_EXPR_CLEANUP (begin) = build (COND_EXPR, void_type_node, sentry, cleanup, void_zero_node); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d28298a56a3..b7057830686 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -7584,10 +7584,6 @@ tsubst_expr (t, args, complain, in_decl) tsubst (TREE_TYPE (t), args, complain, NULL_TREE); break; - case CTOR_STMT: - add_stmt (copy_node (t)); - break; - default: abort (); } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 8666d7f02c4..ee609f45363 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; diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index c96f0e24d77..e0f73617449 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1030,8 +1030,6 @@ cp_statement_code_p (code) { switch (code) { - case SUBOBJECT: - case CTOR_STMT: case CTOR_INITIALIZER: case RETURN_INIT: case TRY_BLOCK: |