Commit 62409b39 by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (FN_TRY_BLOCK_P): New macro.

	* cp-tree.h (FN_TRY_BLOCK_P): New macro.
	* init.c (perform_member_init): Remove obstack machinations.
	(expand_cleanup_for_base): Likewise.
	(finish_init_stmts): Mark the statement-expression as used.
	* method.c (emit_thunk): Use tree-generating functions, not
	RTL.
	(do_build_copy_constructor): Likewise.
	(do_build_assign_ref): Likewise.
	(synthesize_method): Likewise.  Keep track of line numbers.
	* pt.c (tsubst_expr): Handle various kinds of try blocks.
	* semantics.c (expand_stmts): Remove.
	(begin_function_try_block): Set FN_TRY_BLOCK_P.
	(finish_function_try_block): Be careful rechaining
	function try blocks.
	(expand_stmt): Loop through all the statements at a given level.
	(exapnd_body): Be careful with line-numbers here too.  Prepare for
	being called directly from the parser.

From-SVN: r29263
parent ca5b5533
1999-09-10 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (FN_TRY_BLOCK_P): New macro.
* init.c (perform_member_init): Remove obstack machinations.
(expand_cleanup_for_base): Likewise.
(finish_init_stmts): Mark the statement-expression as used.
* method.c (emit_thunk): Use tree-generating functions, not
RTL.
(do_build_copy_constructor): Likewise.
(do_build_assign_ref): Likewise.
(synthesize_method): Likewise. Keep track of line numbers.
* pt.c (tsubst_expr): Handle various kinds of try blocks.
* semantics.c (expand_stmts): Remove.
(begin_function_try_block): Set FN_TRY_BLOCK_P.
(finish_function_try_block): Be careful rechaining
function try blocks.
(expand_stmt): Loop through all the statements at a given level.
(exapnd_body): Be careful with line-numbers here too. Prepare for
being called directly from the parser.
* cp-tree.h (finish_function): Adjust prototype.
* decl.c (finish_function): Return the function compiled.
* pt.c (instantiate_decl): Don't play games with obstacks.
......
......@@ -63,6 +63,7 @@ Boston, MA 02111-1307, USA. */
BINFO_PUSHDECLS_MARKED.
(TREE_REFERENCE_EXPR) (in NON_LVALUE_EXPR) (commented-out).
ICS_BAD_FLAG (in _CONV)
FN_TRY_BLOCK_P (in TRY_BLOCK)
4: BINFO_NEW_VTABLE_MARKED.
TREE_HAS_CONSTRUCTOR (in INDIRECT_REF, SAVE_EXPR, CONSTRUCTOR,
or FIELD_DECL).
......@@ -2429,6 +2430,8 @@ extern int flag_new_for_scope;
#define TRY_STMTS(NODE) TREE_OPERAND (NODE, 0)
#define TRY_HANDLERS(NODE) TREE_OPERAND (NODE, 1)
#define CLEANUP_P(NODE) TREE_LANG_FLAG_0 (NODE)
/* Nonzero if this try block is a function try block. */
#define FN_TRY_BLOCK_P(NODE) TREE_LANG_FLAG_3 (NODE)
#define HANDLER_PARMS(NODE) TREE_OPERAND (NODE, 0)
#define HANDLER_BODY(NODE) TREE_OPERAND (NODE, 1)
#define COMPOUND_BODY(NODE) TREE_OPERAND (NODE, 0)
......
......@@ -225,10 +225,6 @@ perform_member_init (member, name, init, explicit)
{
tree expr;
/* All cleanups must be on the function_obstack. */
push_obstacks_nochange ();
resume_temporary_allocation ();
expr = build_component_ref (current_class_ref, name, NULL_TREE,
explicit);
expr = build_delete (type, expr, integer_zero_node,
......@@ -236,8 +232,6 @@ perform_member_init (member, name, init, explicit)
if (expr != error_mark_node)
finish_subobject (expr);
pop_obstacks ();
}
}
......@@ -699,10 +693,6 @@ expand_cleanup_for_base (binfo, flag)
if (!TYPE_NEEDS_DESTRUCTOR (BINFO_TYPE (binfo)))
return;
/* All cleanups must be on the function_obstack. */
push_obstacks_nochange ();
resume_temporary_allocation ();
/* Call the destructor. */
expr = (build_scoped_method_call
(current_class_ref, binfo, dtor_identifier,
......@@ -712,7 +702,6 @@ expand_cleanup_for_base (binfo, flag)
truthvalue_conversion (flag),
expr, integer_zero_node));
pop_obstacks ();
finish_subobject (expr);
}
......@@ -1009,9 +998,17 @@ finish_init_stmts (stmt_expr, compound_stmt)
tree compound_stmt;
{
pop_momentary ();
return finish_stmt_expr (stmt_expr,
finish_compound_stmt (/*has_no_scope=*/1,
compound_stmt));
stmt_expr
= finish_stmt_expr (stmt_expr,
finish_compound_stmt (/*has_no_scope=*/1,
compound_stmt));
/* To avoid spurious warnings about unused values, we set
TREE_USED. */
if (stmt_expr)
TREE_USED (stmt_expr) = 1;
return stmt_expr;
}
/* This is like `expand_member_init', only it stores one aggregate
......
......@@ -2147,7 +2147,7 @@ emit_thunk (thunk_fndecl)
t = tree_cons (NULL_TREE, a, t);
t = nreverse (t);
t = build_call (function, TREE_TYPE (TREE_TYPE (function)), t);
c_expand_return (t);
finish_return_stmt (t);
finish_function (lineno, 0);
......@@ -2172,7 +2172,6 @@ do_build_copy_constructor (fndecl)
tree fndecl;
{
tree parm = TREE_CHAIN (DECL_ARGUMENTS (fndecl));
tree compound_stmt;
tree t;
if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type))
......@@ -2249,9 +2248,6 @@ do_build_copy_constructor (fndecl)
current_base_init_list = nreverse (current_base_init_list);
setup_vtbl_ptr ();
}
compound_stmt = begin_compound_stmt (/*has_no_scope=*/0);
finish_compound_stmt (/*has_no_scope=*/0, compound_stmt);
}
static void
......@@ -2290,7 +2286,7 @@ do_build_assign_ref (fndecl)
p = convert_from_reference (p);
p = build_member_call (basetype, ansi_opname [MODIFY_EXPR],
build_expr_list (NULL_TREE, p));
expand_expr_stmt (p);
finish_expr_stmt (p);
}
for (; fields; fields = TREE_CHAIN (fields))
{
......@@ -2342,10 +2338,10 @@ do_build_assign_ref (fndecl)
comp = build (COMPONENT_REF, TREE_TYPE (field), comp, field);
init = build (COMPONENT_REF, TREE_TYPE (field), init, field);
expand_expr_stmt (build_modify_expr (comp, NOP_EXPR, init));
finish_expr_stmt (build_modify_expr (comp, NOP_EXPR, init));
}
}
c_expand_return (current_class_ref);
finish_return_stmt (current_class_ref);
finish_compound_stmt (/*has_no_scope=*/0, compound_stmt);
}
......@@ -2355,6 +2351,7 @@ synthesize_method (fndecl)
{
int nested = (current_function_decl != NULL_TREE);
tree context = hack_decl_function_context (fndecl);
int need_body = 1;
if (at_eof)
import_export_decl (fndecl);
......@@ -2364,13 +2361,25 @@ synthesize_method (fndecl)
else if (nested)
push_function_context_to (context);
/* Put the function definition at the position where it is needed,
rather than within the body of the class. That way, an error
during the generation of the implicit body points at the place
where the attempt to generate the function occurs, giving the
user a hint as to why we are attempting to generate the
function. */
DECL_SOURCE_LINE (fndecl) = lineno;
DECL_SOURCE_FILE (fndecl) = input_filename;
interface_unknown = 1;
start_function (NULL_TREE, fndecl, NULL_TREE, SF_DEFAULT | SF_PRE_PARSED);
store_parm_decls ();
clear_last_expr ();
if (DECL_NAME (fndecl) == ansi_opname[MODIFY_EXPR])
do_build_assign_ref (fndecl);
{
do_build_assign_ref (fndecl);
need_body = 0;
}
else if (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (fndecl)))
;
else
......@@ -2381,13 +2390,16 @@ synthesize_method (fndecl)
if (arg_chain != void_list_node)
do_build_copy_constructor (fndecl);
else if (TYPE_NEEDS_CONSTRUCTING (current_class_type))
{
tree compound_stmt;
setup_vtbl_ptr ();
}
setup_vtbl_ptr ();
compound_stmt = begin_compound_stmt (/*has_no_scope=*/0);
finish_compound_stmt (/*has_no_scope=*/0, compound_stmt);
}
/* If we haven't yet generated the body of the function, just
generate an empty compound statement. */
if (need_body)
{
tree compound_stmt;
compound_stmt = begin_compound_stmt (/*has_no_scope=*/0);
finish_compound_stmt (/*has_no_scope=*/0, compound_stmt);
}
finish_function (lineno, 0);
......
......@@ -7443,16 +7443,32 @@ tsubst_expr (t, args, complain, in_decl)
case TRY_BLOCK:
prep_stmt (t);
stmt = begin_try_block ();
tsubst_expr (TRY_STMTS (t), args, complain, in_decl);
finish_try_block (stmt);
if (CLEANUP_P (t))
finish_cleanup (tsubst_expr (TRY_HANDLERS (t), args,
complain, in_decl),
stmt);
{
begin_try_block ();
tsubst_expr (TRY_STMTS (t), args, complain, in_decl);
finish_cleanup_try_block (stmt);
finish_cleanup (tsubst_expr (TRY_HANDLERS (t), args,
complain, in_decl),
stmt);
}
else
{
tree handler = TRY_HANDLERS (t);
tree handler;
if (FN_TRY_BLOCK_P (t))
stmt = begin_function_try_block ();
else
stmt = begin_try_block ();
tsubst_expr (TRY_STMTS (t), args, complain, in_decl);
if (FN_TRY_BLOCK_P (t))
finish_function_try_block (stmt);
else
finish_try_block (stmt);
handler = TRY_HANDLERS (t);
for (; handler; handler = TREE_CHAIN (handler))
tsubst_expr (handler, args, complain, in_decl);
finish_handler_sequence (stmt);
......
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