Commit 1a6025b4 by Jason Merrill Committed by Jason Merrill

cp-tree.def (START_CATCH_STMT): Lose.

        * cp-tree.def (START_CATCH_STMT): Lose.
        * dump.c (cp_dump_tree): Don't dump it.  Do dump HANDLER_PARMS.
        * tree.c (cp_statement_code_p): Don't case it.
        * semantics.c (cp_expand_stmt): Likewise.
        * except.c (expand_start_catch_block): Don't start any blocks.
        Return the type.
        (expand_end_catch_block): Don't end any blocks.
        * parse.y (handler): Don't pass anything from finish_handler_parms
        to finish_handler.
        * pt.c (tsubst_expr): Likewise.
        * semantics.c (begin_handler): Call note_level_for_catch here.
        (finish_handler_parms): Don't return anything.
        (genrtl_catch_block, begin_catch_block): Lose.
        (genrtl_handler): Call expand_start_catch here.
        * cp-tree.h (START_CATCH_TYPE): Lose.
        (HANDLER_TYPE): New.

From-SVN: r42388
parent 0fd0b7ee
2001-05-21 Jason Merrill <jason_merrill@redhat.com>
* cp-tree.def (START_CATCH_STMT): Lose.
* dump.c (cp_dump_tree): Don't dump it. Do dump HANDLER_PARMS.
* tree.c (cp_statement_code_p): Don't case it.
* semantics.c (cp_expand_stmt): Likewise.
* cp-tree.h (START_CATCH_TYPE): Lose.
(HANDLER_TYPE): New.
* except.c (expand_start_catch_block): Don't start any blocks.
Return the type.
(expand_end_catch_block): Don't end any blocks.
* parse.y (handler): Don't pass anything from finish_handler_parms
to finish_handler.
* pt.c (tsubst_expr): Likewise.
* semantics.c (begin_handler): Call note_level_for_catch here.
(finish_handler_parms): Don't return anything.
(genrtl_catch_block, begin_catch_block): Lose.
(genrtl_handler): Call expand_start_catch here.
2001-05-18 Jason Merrill <jason_merrill@redhat.com>
* class.c (build_vtable): Set DECL_ASSEMBLER_NAME for vtables here.
(get_vtable_decl, build_vtt): Not here.
2001-05-20 Nathan Sidwell <nathan@codesourcery.com> 2001-05-20 Nathan Sidwell <nathan@codesourcery.com>
PR c++/2781 PR c++/2781
......
...@@ -229,14 +229,14 @@ DEFTREECODE (CTOR_STMT, "ctor_stmt", 'e', 0) ...@@ -229,14 +229,14 @@ DEFTREECODE (CTOR_STMT, "ctor_stmt", 'e', 0)
constructed. If, after this point, the CLEANUP_DECL goes out of constructed. If, after this point, the CLEANUP_DECL goes out of
scope, the CLEANUP_EXPR must be run. */ scope, the CLEANUP_EXPR must be run. */
DEFTREECODE (CLEANUP_STMT, "cleanup_stmt", 'e', 2) DEFTREECODE (CLEANUP_STMT, "cleanup_stmt", 'e', 2)
/* A START_CATCH_STMT marks the beginning of a catch handler for the
the START_CATCH_TYPE. If this is CATCH_ALL_TYPE, then the handler
catches all types. */
DEFTREECODE (START_CATCH_STMT, "start_catch_stmt", 'e', 0)
DEFTREECODE (CTOR_INITIALIZER, "ctor_initializer", 'e', 2) DEFTREECODE (CTOR_INITIALIZER, "ctor_initializer", 'e', 2)
DEFTREECODE (RETURN_INIT, "return_init", 'e', 2) DEFTREECODE (RETURN_INIT, "return_init", 'e', 2)
DEFTREECODE (TRY_BLOCK, "try_block", 'e', 2) DEFTREECODE (TRY_BLOCK, "try_block", 'e', 2)
DEFTREECODE (EH_SPEC_BLOCK, "eh_spec_block", 'e', 2) DEFTREECODE (EH_SPEC_BLOCK, "eh_spec_block", 'e', 2)
/* A HANDLER wraps a catch handler for the HANDLER_TYPE. If this is
CATCH_ALL_TYPE, then the handler catches all types. The declaration of
the catch variable is in HANDLER_PARMS, and the body block in
HANDLER_BODY. */
DEFTREECODE (HANDLER, "handler", 'e', 2) DEFTREECODE (HANDLER, "handler", 'e', 2)
/* A MUST_NOT_THROW_EXPR wraps an expression that may not /* A MUST_NOT_THROW_EXPR wraps an expression that may not
......
...@@ -3061,8 +3061,8 @@ enum ptrmemfunc_vbit_where_t ...@@ -3061,8 +3061,8 @@ enum ptrmemfunc_vbit_where_t
#define FN_TRY_BLOCK_P(NODE) TREE_LANG_FLAG_3 (TRY_BLOCK_CHECK (NODE)) #define FN_TRY_BLOCK_P(NODE) TREE_LANG_FLAG_3 (TRY_BLOCK_CHECK (NODE))
#define HANDLER_PARMS(NODE) TREE_OPERAND (HANDLER_CHECK (NODE), 0) #define HANDLER_PARMS(NODE) TREE_OPERAND (HANDLER_CHECK (NODE), 0)
#define HANDLER_BODY(NODE) TREE_OPERAND (HANDLER_CHECK (NODE), 1) #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) #define SUBOBJECT_CLEANUP(NODE) TREE_OPERAND (SUBOBJECT_CHECK (NODE), 0)
#define START_CATCH_TYPE(NODE) TREE_TYPE (START_CATCH_STMT_CHECK (NODE))
/* Nonzero if this CTOR_STMT is for the beginning of a constructor. */ /* Nonzero if this CTOR_STMT is for the beginning of a constructor. */
#define CTOR_BEGIN_P(NODE) \ #define CTOR_BEGIN_P(NODE) \
...@@ -4005,7 +4005,7 @@ extern cp_printer *cp_printers[256]; ...@@ -4005,7 +4005,7 @@ extern cp_printer *cp_printers[256];
/* in except.c */ /* in except.c */
extern void init_exception_processing PARAMS ((void)); extern void init_exception_processing PARAMS ((void));
extern tree expand_start_catch_block PARAMS ((tree)); extern tree expand_start_catch_block PARAMS ((tree));
extern void expand_end_catch_block PARAMS ((tree)); extern void expand_end_catch_block PARAMS ((void));
extern void expand_builtin_throw PARAMS ((void)); extern void expand_builtin_throw PARAMS ((void));
extern void expand_eh_spec_block PARAMS ((tree)); extern void expand_eh_spec_block PARAMS ((tree));
extern void expand_exception_blocks PARAMS ((void)); extern void expand_exception_blocks PARAMS ((void));
...@@ -4271,9 +4271,9 @@ extern void finish_function_try_block PARAMS ((tree)); ...@@ -4271,9 +4271,9 @@ extern void finish_function_try_block PARAMS ((tree));
extern void finish_function_handler_sequence PARAMS ((tree)); extern void finish_function_handler_sequence PARAMS ((tree));
extern void finish_cleanup_try_block PARAMS ((tree)); extern void finish_cleanup_try_block PARAMS ((tree));
extern tree begin_handler PARAMS ((void)); extern tree begin_handler PARAMS ((void));
extern tree finish_handler_parms PARAMS ((tree, tree)); extern void finish_handler_parms PARAMS ((tree, tree));
extern void begin_catch_block PARAMS ((tree)); extern void begin_catch_block PARAMS ((tree));
extern void finish_handler PARAMS ((tree, tree)); extern void finish_handler PARAMS ((tree));
extern void finish_cleanup PARAMS ((tree, tree)); extern void finish_cleanup PARAMS ((tree, tree));
extern tree begin_compound_stmt PARAMS ((int)); extern tree begin_compound_stmt PARAMS ((int));
extern tree finish_compound_stmt PARAMS ((int, tree)); extern tree finish_compound_stmt PARAMS ((int, tree));
......
...@@ -230,6 +230,7 @@ cp_dump_tree (di, t) ...@@ -230,6 +230,7 @@ cp_dump_tree (di, t)
case HANDLER: case HANDLER:
dump_stmt (di, t); dump_stmt (di, t);
dump_child ("parm", HANDLER_PARMS (t));
dump_child ("body", HANDLER_BODY (t)); dump_child ("body", HANDLER_BODY (t));
dump_next_stmt (di, t); dump_next_stmt (di, t);
break; break;
...@@ -246,12 +247,6 @@ cp_dump_tree (di, t) ...@@ -246,12 +247,6 @@ cp_dump_tree (di, t)
dump_next_stmt (di, t); dump_next_stmt (di, t);
break; break;
case START_CATCH_STMT:
dump_stmt (di, t);
queue_and_dump_type (di, t);
dump_next_stmt (di, t);
break;
case USING_STMT: case USING_STMT:
dump_stmt (di, t); dump_stmt (di, t);
dump_child ("nmsp", USING_STMT_NAMESPACE (t)); dump_child ("nmsp", USING_STMT_NAMESPACE (t));
......
...@@ -391,8 +391,6 @@ tree ...@@ -391,8 +391,6 @@ tree
expand_start_catch_block (decl) expand_start_catch_block (decl)
tree decl; tree decl;
{ {
tree compound_stmt_1;
tree compound_stmt_2;
tree exp = NULL_TREE; tree exp = NULL_TREE;
tree type; tree type;
bool is_java; bool is_java;
...@@ -404,16 +402,10 @@ expand_start_catch_block (decl) ...@@ -404,16 +402,10 @@ expand_start_catch_block (decl)
if (decl && !complete_ptr_ref_or_void_ptr_p (TREE_TYPE (decl), NULL_TREE)) if (decl && !complete_ptr_ref_or_void_ptr_p (TREE_TYPE (decl), NULL_TREE))
decl = NULL_TREE; decl = NULL_TREE;
/* Create a binding level for the eh_info and the exception object
cleanup. */
compound_stmt_1 = begin_compound_stmt (/*has_no_scope=*/0);
note_level_for_catch ();
if (decl) if (decl)
type = prepare_eh_type (TREE_TYPE (decl)); type = prepare_eh_type (TREE_TYPE (decl));
else else
type = NULL_TREE; type = NULL_TREE;
begin_catch_block (type);
is_java = false; is_java = false;
if (decl) if (decl)
...@@ -452,13 +444,10 @@ expand_start_catch_block (decl) ...@@ -452,13 +444,10 @@ expand_start_catch_block (decl)
if (! is_java) if (! is_java)
push_eh_cleanup (type); push_eh_cleanup (type);
/* Create a binding level for the parm. */
compound_stmt_2 = begin_compound_stmt (/*has_no_scope=*/0);
if (decl) if (decl)
initialize_handler_parm (decl, exp); initialize_handler_parm (decl, exp);
return build_tree_list (compound_stmt_1, compound_stmt_2); return type;
} }
...@@ -467,12 +456,8 @@ expand_start_catch_block (decl) ...@@ -467,12 +456,8 @@ expand_start_catch_block (decl)
the label to jump to if this catch block didn't match. */ the label to jump to if this catch block didn't match. */
void void
expand_end_catch_block (blocks) expand_end_catch_block ()
tree blocks;
{ {
tree compound_stmt_1 = blocks ? TREE_PURPOSE (blocks): NULL_TREE;
tree compound_stmt_2 = blocks ? TREE_VALUE (blocks): NULL_TREE;
if (! doing_eh (1)) if (! doing_eh (1))
return; return;
...@@ -482,11 +467,6 @@ expand_end_catch_block (blocks) ...@@ -482,11 +467,6 @@ expand_end_catch_block (blocks)
&& (DECL_CONSTRUCTOR_P (current_function_decl) && (DECL_CONSTRUCTOR_P (current_function_decl)
|| DECL_DESTRUCTOR_P (current_function_decl))) || DECL_DESTRUCTOR_P (current_function_decl)))
finish_expr_stmt (build_throw (NULL_TREE)); finish_expr_stmt (build_throw (NULL_TREE));
/* Cleanup the EH parameter. */
finish_compound_stmt (/*has_no_scope=*/0, compound_stmt_2);
/* Cleanup the EH object. */
finish_compound_stmt (/*has_no_scope=*/0, compound_stmt_1);
} }
tree tree
......
...@@ -3518,11 +3518,11 @@ handler_seq: ...@@ -3518,11 +3518,11 @@ handler_seq:
handler: handler:
CATCH CATCH
{ $<ttype>$ = begin_handler(); } { $<ttype>$ = begin_handler (); }
handler_args handler_args
{ $<ttype>$ = finish_handler_parms ($3, $<ttype>2); } { finish_handler_parms ($3, $<ttype>2); }
compstmt compstmt
{ finish_handler ($<ttype>4, $<ttype>2); } { finish_handler ($<ttype>2); }
; ;
type_specifier_seq: type_specifier_seq:
......
...@@ -7448,7 +7448,6 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7448,7 +7448,6 @@ tsubst_expr (t, args, complain, in_decl)
case HANDLER: case HANDLER:
{ {
tree decl; tree decl;
tree blocks;
prep_stmt (t); prep_stmt (t);
stmt = begin_handler (); stmt = begin_handler ();
...@@ -7463,9 +7462,9 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7463,9 +7462,9 @@ tsubst_expr (t, args, complain, in_decl)
} }
else else
decl = NULL_TREE; decl = NULL_TREE;
blocks = finish_handler_parms (decl, stmt); finish_handler_parms (decl, stmt);
tsubst_expr (HANDLER_BODY (t), args, complain, in_decl); tsubst_expr (HANDLER_BODY (t), args, complain, in_decl);
finish_handler (blocks, stmt); finish_handler (stmt);
} }
break; break;
......
...@@ -54,7 +54,6 @@ static void emit_associated_thunks PARAMS ((tree)); ...@@ -54,7 +54,6 @@ static void emit_associated_thunks PARAMS ((tree));
static void genrtl_try_block PARAMS ((tree)); static void genrtl_try_block PARAMS ((tree));
static void genrtl_eh_spec_block PARAMS ((tree)); static void genrtl_eh_spec_block PARAMS ((tree));
static void genrtl_handler PARAMS ((tree)); static void genrtl_handler PARAMS ((tree));
static void genrtl_catch_block PARAMS ((tree));
static void genrtl_ctor_stmt PARAMS ((tree)); static void genrtl_ctor_stmt PARAMS ((tree));
static void genrtl_subobject PARAMS ((tree)); static void genrtl_subobject PARAMS ((tree));
static void genrtl_named_return_value PARAMS ((void)); static void genrtl_named_return_value PARAMS ((void));
...@@ -721,6 +720,8 @@ genrtl_handler (t) ...@@ -721,6 +720,8 @@ genrtl_handler (t)
tree t; tree t;
{ {
genrtl_do_pushlevel (); genrtl_do_pushlevel ();
if (!processing_template_decl)
expand_start_catch (HANDLER_TYPE (t));
expand_stmt (HANDLER_BODY (t)); expand_stmt (HANDLER_BODY (t));
if (!processing_template_decl) if (!processing_template_decl)
expand_end_catch (); expand_end_catch ();
...@@ -734,7 +735,10 @@ begin_handler () ...@@ -734,7 +735,10 @@ begin_handler ()
tree r; tree r;
r = build_stmt (HANDLER, NULL_TREE, NULL_TREE); r = build_stmt (HANDLER, NULL_TREE, NULL_TREE);
add_stmt (r); add_stmt (r);
/* Create a binding level for the eh_info and the exception object
cleanup. */
do_pushlevel (); do_pushlevel ();
note_level_for_catch ();
return r; return r;
} }
...@@ -742,13 +746,12 @@ begin_handler () ...@@ -742,13 +746,12 @@ begin_handler ()
HANDLER. DECL is the declaration for the catch parameter, or NULL HANDLER. DECL is the declaration for the catch parameter, or NULL
if this is a `catch (...)' clause. */ if this is a `catch (...)' clause. */
tree void
finish_handler_parms (decl, handler) finish_handler_parms (decl, handler)
tree decl; tree decl;
tree handler; tree handler;
{ {
tree blocks = NULL_TREE; tree type = NULL_TREE;
if (processing_template_decl) if (processing_template_decl)
{ {
if (decl) if (decl)
...@@ -757,47 +760,24 @@ finish_handler_parms (decl, handler) ...@@ -757,47 +760,24 @@ finish_handler_parms (decl, handler)
decl = push_template_decl (decl); decl = push_template_decl (decl);
add_decl_stmt (decl); add_decl_stmt (decl);
RECHAIN_STMTS (handler, HANDLER_PARMS (handler)); RECHAIN_STMTS (handler, HANDLER_PARMS (handler));
type = TREE_TYPE (decl);
} }
} }
else else
blocks = expand_start_catch_block (decl); type = expand_start_catch_block (decl);
if (decl)
TREE_TYPE (handler) = TREE_TYPE (decl);
return blocks; HANDLER_TYPE (handler) = type;
}
/* Generate the RTL for a START_CATCH_STMT. */
static void
genrtl_catch_block (type)
tree type;
{
expand_start_catch (type);
}
/* Note the beginning of a handler for TYPE. This function is called
at the point to which control should be transferred when an
appropriately-typed exception is thrown. */
void
begin_catch_block (type)
tree type;
{
add_stmt (build (START_CATCH_STMT, type));
} }
/* Finish a handler, which may be given by HANDLER. The BLOCKs are /* Finish a handler, which may be given by HANDLER. The BLOCKs are
the return value from the matching call to finish_handler_parms. */ the return value from the matching call to finish_handler_parms. */
void void
finish_handler (blocks, handler) finish_handler (handler)
tree blocks;
tree handler; tree handler;
{ {
if (!processing_template_decl) if (!processing_template_decl)
expand_end_catch_block (blocks); expand_end_catch_block ();
do_poplevel (); do_poplevel ();
RECHAIN_STMTS (handler, HANDLER_BODY (handler)); RECHAIN_STMTS (handler, HANDLER_BODY (handler));
} }
...@@ -2167,10 +2147,6 @@ cp_expand_stmt (t) ...@@ -2167,10 +2147,6 @@ cp_expand_stmt (t)
genrtl_decl_cleanup (CLEANUP_DECL (t), CLEANUP_EXPR (t)); genrtl_decl_cleanup (CLEANUP_DECL (t), CLEANUP_EXPR (t));
break; break;
case START_CATCH_STMT:
genrtl_catch_block (TREE_TYPE (t));
break;
case CTOR_STMT: case CTOR_STMT:
genrtl_ctor_stmt (t); genrtl_ctor_stmt (t);
break; break;
......
...@@ -1031,7 +1031,6 @@ cp_statement_code_p (code) ...@@ -1031,7 +1031,6 @@ cp_statement_code_p (code)
{ {
case SUBOBJECT: case SUBOBJECT:
case CLEANUP_STMT: case CLEANUP_STMT:
case START_CATCH_STMT:
case CTOR_STMT: case CTOR_STMT:
case CTOR_INITIALIZER: case CTOR_INITIALIZER:
case RETURN_INIT: case RETURN_INIT:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment