Commit 3c5c0849 by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (start_handler_parms): New function.

	* cp-tree.h (start_handler_parms): New function.
	(expand_start_catch_block): Take only one parameter.
	(start_handler_parms): New function.
	* decl.c (start_handler_parms): Define it.
	* except.c (process_start_catch_block): Take only one parameter.
	Don't call grokdeclarator here.
	(expand_start_catch_block): Don't call grokdeclarator here,
	either.
	* parse.y (handler_args): Adjust call to
	expand_start_catch_block.  Use start_handler_parms.
	* pt.c (push_template_decl_real): Make permanent lists have
	permanent elements.
	(tsubst_expr): Adjust calls to expand_start_catch_block
	appropriately.
	* semantics.c (expand_stmt): Likewise.

From-SVN: r28983
parent 7d53d823
1999-08-30 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (start_handler_parms): New function.
(expand_start_catch_block): Take only one parameter.
(start_handler_parms): New function.
* decl.c (start_handler_parms): Define it.
* except.c (process_start_catch_block): Take only one parameter.
Don't call grokdeclarator here.
(expand_start_catch_block): Don't call grokdeclarator here,
either.
* parse.y (handler_args): Adjust call to
expand_start_catch_block. Use start_handler_parms.
* pt.c (push_template_decl_real): Make permanent lists have
permanent elements.
(tsubst_expr): Adjust calls to expand_start_catch_block
appropriately.
* semantics.c (expand_stmt): Likewise.
1999-08-29 Alex Samuel <samuel@codesourcery.com> 1999-08-29 Alex Samuel <samuel@codesourcery.com>
* pt.c (push_template_decl_real): Use template declaration from * pt.c (push_template_decl_real): Use template declaration from
......
...@@ -2932,6 +2932,7 @@ extern void finish_decl PROTO((tree, tree, tree)); ...@@ -2932,6 +2932,7 @@ extern void finish_decl PROTO((tree, tree, tree));
extern void maybe_inject_for_scope_var PROTO((tree)); extern void maybe_inject_for_scope_var PROTO((tree));
extern void initialize_local_var PROTO((tree, tree, int)); extern void initialize_local_var PROTO((tree, tree, int));
extern void expand_static_init PROTO((tree, tree)); extern void expand_static_init PROTO((tree, tree));
extern void start_handler_parms PROTO((tree, tree));
extern int complete_array_type PROTO((tree, tree, int)); extern int complete_array_type PROTO((tree, tree, int));
extern tree build_ptrmemfunc_type PROTO((tree)); extern tree build_ptrmemfunc_type PROTO((tree));
/* the grokdeclarator prototype is in decl.h */ /* the grokdeclarator prototype is in decl.h */
...@@ -3080,7 +3081,7 @@ extern int cp_line_of PROTO((tree)); ...@@ -3080,7 +3081,7 @@ extern int cp_line_of PROTO((tree));
/* in except.c */ /* in except.c */
extern void init_exception_processing PROTO((void)); extern void init_exception_processing PROTO((void));
extern void expand_start_catch_block PROTO((tree, tree)); extern void expand_start_catch_block PROTO((tree));
extern void expand_end_catch_block PROTO((void)); extern void expand_end_catch_block PROTO((void));
extern void expand_builtin_throw PROTO((void)); extern void expand_builtin_throw PROTO((void));
extern void expand_start_eh_spec PROTO((void)); extern void expand_start_eh_spec PROTO((void));
...@@ -3349,6 +3350,7 @@ extern tree begin_function_try_block PROTO((void)); ...@@ -3349,6 +3350,7 @@ extern tree begin_function_try_block PROTO((void));
extern void finish_function_try_block PROTO((tree)); extern void finish_function_try_block PROTO((tree));
extern void finish_function_handler_sequence PROTO((tree)); extern void finish_function_handler_sequence PROTO((tree));
extern tree begin_handler PROTO((void)); extern tree begin_handler PROTO((void));
extern void start_handler_parms PROTO((tree, tree));
extern void finish_handler_parms PROTO((tree)); extern void finish_handler_parms PROTO((tree));
extern void finish_handler PROTO((tree)); extern void finish_handler PROTO((tree));
extern void finish_cleanup PROTO((tree, tree)); extern void finish_cleanup PROTO((tree, tree));
......
...@@ -8317,6 +8317,27 @@ expand_static_init (decl, init) ...@@ -8317,6 +8317,27 @@ expand_static_init (decl, init)
static_aggregates = perm_tree_cons (init, decl, static_aggregates); static_aggregates = perm_tree_cons (init, decl, static_aggregates);
} }
} }
/* Finish the declaration of a catch-parameter. */
void
start_handler_parms (declspecs, declarator)
tree declspecs;
tree declarator;
{
tree decl;
if (declspecs)
{
decl = grokdeclarator (declarator, declspecs, CATCHPARM,
1, NULL_TREE);
if (decl == NULL_TREE)
error ("invalid catch parameter");
}
else
decl = NULL_TREE;
expand_start_catch_block (decl);
}
/* Make TYPE a complete type based on INITIAL_VALUE. /* Make TYPE a complete type based on INITIAL_VALUE.
Return 0 if successful, 1 if INITIAL_VALUE can't be deciphered, Return 0 if successful, 1 if INITIAL_VALUE can't be deciphered,
......
...@@ -51,7 +51,7 @@ static tree get_eh_caught PROTO((void)); ...@@ -51,7 +51,7 @@ static tree get_eh_caught PROTO((void));
static tree get_eh_handlers PROTO((void)); static tree get_eh_handlers PROTO((void));
#endif #endif
static tree do_pop_exception PROTO((void)); static tree do_pop_exception PROTO((void));
static void process_start_catch_block PROTO((tree, tree)); static void process_start_catch_block PROTO((tree));
static tree build_eh_type_type_ref PROTO((tree)); static tree build_eh_type_type_ref PROTO((tree));
static tree build_terminate_handler PROTO((void)); static tree build_terminate_handler PROTO((void));
static tree alloc_eh_object PROTO((tree)); static tree alloc_eh_object PROTO((tree));
...@@ -513,17 +513,17 @@ build_terminate_handler () ...@@ -513,17 +513,17 @@ build_terminate_handler ()
(ie: it ends up as the "else" clause rather than an "else if" clause) */ (ie: it ends up as the "else" clause rather than an "else if" clause) */
void void
expand_start_catch_block (declspecs, declarator) expand_start_catch_block (decl)
tree declspecs, declarator; tree decl;
{ {
tree decl;
if (building_stmt_tree ()) if (building_stmt_tree ())
{ {
if (declspecs) if (decl)
{ {
decl = grokdeclarator (declarator, declspecs, CATCHPARM, /* We must ensure that DECL_CONTEXT is set up before we call
1, NULL_TREE); push_template_decl; that code depends on DECL_CONTEXT
being set correctly. */
DECL_CONTEXT (decl) = current_function_decl;
if (processing_template_decl) if (processing_template_decl)
decl = push_template_decl (decl); decl = push_template_decl (decl);
pushdecl (decl); pushdecl (decl);
...@@ -535,7 +535,7 @@ expand_start_catch_block (declspecs, declarator) ...@@ -535,7 +535,7 @@ expand_start_catch_block (declspecs, declarator)
if (! doing_eh (1)) if (! doing_eh (1))
return; return;
process_start_catch_block (declspecs, declarator); process_start_catch_block (decl);
} }
/* This function performs the expand_start_catch_block functionality for /* This function performs the expand_start_catch_block functionality for
...@@ -544,10 +544,9 @@ expand_start_catch_block (declspecs, declarator) ...@@ -544,10 +544,9 @@ expand_start_catch_block (declspecs, declarator)
nothing additional. */ nothing additional. */
static void static void
process_start_catch_block (declspecs, declarator) process_start_catch_block (decl)
tree declspecs, declarator; tree decl;
{ {
tree decl = NULL_TREE;
tree init; tree init;
/* Create a binding level for the eh_info and the exception object /* Create a binding level for the eh_info and the exception object
...@@ -555,16 +554,8 @@ process_start_catch_block (declspecs, declarator) ...@@ -555,16 +554,8 @@ process_start_catch_block (declspecs, declarator)
pushlevel (0); pushlevel (0);
expand_start_bindings (0); expand_start_bindings (0);
if (decl && !complete_ptr_ref_or_void_ptr_p (TREE_TYPE (decl), NULL_TREE))
if (declspecs) decl = NULL_TREE;
{
decl = grokdeclarator (declarator, declspecs, CATCHPARM, 1, NULL_TREE);
if (decl == NULL_TREE)
error ("invalid catch parameter");
else if (!complete_ptr_ref_or_void_ptr_p (TREE_TYPE (decl), NULL_TREE))
decl = NULL_TREE;
}
if (decl) if (decl)
start_catch_handler (build_eh_type_type_ref (TREE_TYPE (decl))); start_catch_handler (build_eh_type_type_ref (TREE_TYPE (decl)));
...@@ -701,7 +692,7 @@ expand_end_eh_spec (raises) ...@@ -701,7 +692,7 @@ expand_end_eh_spec (raises)
int count = 0; int count = 0;
expand_start_all_catch (); expand_start_all_catch ();
expand_start_catch_block (NULL_TREE, NULL_TREE); expand_start_catch_block (NULL_TREE);
/* Build up an array of type_infos. */ /* Build up an array of type_infos. */
for (; raises && TREE_VALUE (raises); raises = TREE_CHAIN (raises)) for (; raises && TREE_VALUE (raises); raises = TREE_CHAIN (raises))
......
...@@ -3365,7 +3365,7 @@ type_specifier_seq: ...@@ -3365,7 +3365,7 @@ type_specifier_seq:
handler_args: handler_args:
'(' ELLIPSIS ')' '(' ELLIPSIS ')'
{ expand_start_catch_block (NULL_TREE, NULL_TREE); } { expand_start_catch_block (NULL_TREE); }
/* This doesn't allow reference parameters, the below does. /* This doesn't allow reference parameters, the below does.
| '(' type_specifier_seq absdcl ')' | '(' type_specifier_seq absdcl ')'
{ check_for_new_type ("inside exception declarations", $2); { check_for_new_type ("inside exception declarations", $2);
...@@ -3381,9 +3381,11 @@ handler_args: ...@@ -3381,9 +3381,11 @@ handler_args:
expand_start_catch_block ($2.t, $3); } expand_start_catch_block ($2.t, $3); }
This allows reference parameters... */ This allows reference parameters... */
| '(' parm ')' | '(' parm ')'
{ check_for_new_type ("inside exception declarations", $2); {
expand_start_catch_block (TREE_PURPOSE ($2.t), check_for_new_type ("inside exception declarations", $2);
TREE_VALUE ($2.t)); } start_handler_parms (TREE_PURPOSE ($2.t),
TREE_VALUE ($2.t));
}
; ;
label_colon: label_colon:
......
...@@ -2599,7 +2599,7 @@ push_template_decl_real (decl, is_friend) ...@@ -2599,7 +2599,7 @@ push_template_decl_real (decl, is_friend)
if (primary) if (primary)
DECL_PRIMARY_TEMPLATE (tmpl) = tmpl; DECL_PRIMARY_TEMPLATE (tmpl) = tmpl;
info = perm_tree_cons (tmpl, args, NULL_TREE); info = perm_tree_cons (tmpl, copy_to_permanent (args), NULL_TREE);
if (DECL_IMPLICIT_TYPEDEF_P (decl)) if (DECL_IMPLICIT_TYPEDEF_P (decl))
{ {
...@@ -7465,14 +7465,11 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7465,14 +7465,11 @@ tsubst_expr (t, args, complain, in_decl)
lineno = STMT_LINENO (t); lineno = STMT_LINENO (t);
stmt = begin_handler (); stmt = begin_handler ();
if (HANDLER_PARMS (t)) if (HANDLER_PARMS (t))
{ expand_start_catch_block
tree d = HANDLER_PARMS (t); (tsubst (DECL_STMT_DECL (HANDLER_PARMS (t)),
expand_start_catch_block args, complain, in_decl));
(tsubst (TREE_OPERAND (d, 1), args, complain, in_decl),
tsubst (TREE_OPERAND (d, 0), args, complain, in_decl));
}
else else
expand_start_catch_block (NULL_TREE, NULL_TREE); expand_start_catch_block (NULL_TREE);
finish_handler_parms (stmt); finish_handler_parms (stmt);
tsubst_expr (HANDLER_BODY (t), args, complain, in_decl); tsubst_expr (HANDLER_BODY (t), args, complain, in_decl);
finish_handler (stmt); finish_handler (stmt);
......
...@@ -2182,13 +2182,9 @@ expand_stmt (t) ...@@ -2182,13 +2182,9 @@ expand_stmt (t)
lineno = STMT_LINENO (t); lineno = STMT_LINENO (t);
begin_handler (); begin_handler ();
if (HANDLER_PARMS (t)) if (HANDLER_PARMS (t))
{ expand_start_catch_block (DECL_STMT_DECL (HANDLER_PARMS (t)));
tree d = HANDLER_PARMS (t);
expand_start_catch_block (TREE_OPERAND (d, 1),
TREE_OPERAND (d, 0));
}
else else
expand_start_catch_block (NULL_TREE, NULL_TREE); expand_start_catch_block (NULL_TREE);
finish_handler_parms (NULL_TREE); finish_handler_parms (NULL_TREE);
expand_stmt (HANDLER_BODY (t)); expand_stmt (HANDLER_BODY (t));
finish_handler (NULL_TREE); finish_handler (NULL_TREE);
......
// Build don't link:
// Origin: Mark Mitchell <mark@codesourcery.com>
template <class T = int>
struct S
{
void f ()
{
try {
} catch (int) {
}
}
};
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