Commit a7e4cfa0 by Mark Mitchell Committed by Mark Mitchell

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

	* cp-tree.h (EXPR_STMT_ASSIGNS_THIS): New macro.
	(STMT_IS_FULL_EXPR_P): Likewise.
	(STMT_LINENO_FOR_FN_P): Likewise.
	(prep_stmt): New function.
	(building_stmt_tree): Tweak for safety.
	* pt.c (tsubst_expr): Use prep_stmt throughout.
	(add_tree): Move it to semantics.c
	* semantics.c (add_tree): Move it here.
	(finish_expr_stmt_real): New function.
	(finish_expr_stmt): Use it.
	(finish_if_stmt_cond): Use FINISH_COND.
	(finish_while_stmt_cond): Likewise.
	(finish_for_cond): Likewise.
	(finish_stmt_tree): Tweak line-number handling.
	(prep_stmt): New function.
	(expand_stmt): Use it.

From-SVN: r29249
parent 3b71623b
1999-09-09 Mark Mitchell <mark@codesourcery.com> 1999-09-09 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (EXPR_STMT_ASSIGNS_THIS): New macro.
(STMT_IS_FULL_EXPR_P): Likewise.
(STMT_LINENO_FOR_FN_P): Likewise.
(prep_stmt): New function.
(building_stmt_tree): Tweak for safety.
* pt.c (tsubst_expr): Use prep_stmt throughout.
(add_tree): Move it to semantics.c
* semantics.c (add_tree): Move it here.
(finish_expr_stmt_real): New function.
(finish_expr_stmt): Use it.
(finish_if_stmt_cond): Use FINISH_COND.
(finish_while_stmt_cond): Likewise.
(finish_for_cond): Likewise.
(finish_stmt_tree): Tweak line-number handling.
(prep_stmt): New function.
(expand_stmt): Use it.
* cp-tree.h (begin_switch_stmt): Adjust prototype. * cp-tree.h (begin_switch_stmt): Adjust prototype.
(finish_switch_cond): Likewise. (finish_switch_cond): Likewise.
* parse.y (simple_stmt): Adjust accordingly. * parse.y (simple_stmt): Adjust accordingly.
......
...@@ -29,6 +29,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -29,6 +29,7 @@ Boston, MA 02111-1307, USA. */
/* Usage of TREE_LANG_FLAG_?: /* Usage of TREE_LANG_FLAG_?:
0: BINFO_MARKED (BINFO nodes). 0: BINFO_MARKED (BINFO nodes).
COMPOUND_STMT_NO_SCOPE (in COMPOUND_STMT). COMPOUND_STMT_NO_SCOPE (in COMPOUND_STMT).
EXPR_STMT_ASSIGNS_THIS (in EXPR_STMT).
NEW_EXPR_USE_GLOBAL (in NEW_EXPR). NEW_EXPR_USE_GLOBAL (in NEW_EXPR).
DELETE_EXPR_USE_GLOBAL (in DELETE_EXPR). DELETE_EXPR_USE_GLOBAL (in DELETE_EXPR).
LOOKUP_EXPR_GLOBAL (in LOOKUP_EXPR). LOOKUP_EXPR_GLOBAL (in LOOKUP_EXPR).
...@@ -49,12 +50,14 @@ Boston, MA 02111-1307, USA. */ ...@@ -49,12 +50,14 @@ Boston, MA 02111-1307, USA. */
INHERITED_VALUE_BINDING_P (in CPLUS_BINDING) INHERITED_VALUE_BINDING_P (in CPLUS_BINDING)
BASELINK_P (in TREE_LIST) BASELINK_P (in TREE_LIST)
ICS_ELLIPSIS_FLAG (in _CONV) ICS_ELLIPSIS_FLAG (in _CONV)
STMT_IS_FULL_EXPR_P (in _STMT)
2: IDENTIFIER_OPNAME_P. 2: IDENTIFIER_OPNAME_P.
BINFO_VBASE_MARKED. BINFO_VBASE_MARKED.
BINFO_FIELDS_MARKED. BINFO_FIELDS_MARKED.
TYPE_VIRTUAL_P. TYPE_VIRTUAL_P.
ICS_THIS_FLAG (in _CONV) ICS_THIS_FLAG (in _CONV)
BINDING_HAS_LEVEL_P (In CPLUS_BINDING) STMT_LINENO_FOR_FN_P (in _STMT)
BINDING_HAS_LEVEL_P (in CPLUS_BINDING)
3: TYPE_USES_VIRTUAL_BASECLASSES (in a class TYPE). 3: TYPE_USES_VIRTUAL_BASECLASSES (in a class TYPE).
BINFO_VTABLE_PATH_MARKED. BINFO_VTABLE_PATH_MARKED.
BINFO_PUSHDECLS_MARKED. BINFO_PUSHDECLS_MARKED.
...@@ -1816,6 +1819,15 @@ struct lang_decl ...@@ -1816,6 +1819,15 @@ struct lang_decl
constructor call, rather than an ordinary function call. */ constructor call, rather than an ordinary function call. */
#define AGGR_INIT_VIA_CTOR_P(NODE) TREE_LANG_FLAG_0 (NODE) #define AGGR_INIT_VIA_CTOR_P(NODE) TREE_LANG_FLAG_0 (NODE)
/* Nonzero if this statement contained the first assigned to `this' in
the current function. (Of course, one cannot assign to `this' in
ANSI/ISO C++, but we still support assignments to this with
-fthis-is-variable.) */
#define EXPR_STMT_ASSIGNS_THIS(NODE) TREE_LANG_FLAG_0 ((NODE))
/* Nonzero if this statement should be considered a full-expression. */
#define STMT_IS_FULL_EXPR_P(NODE) TREE_LANG_FLAG_1 ((NODE))
/* The TYPE_MAIN_DECL for a class template type is a TYPE_DECL, not a /* The TYPE_MAIN_DECL for a class template type is a TYPE_DECL, not a
TEMPLATE_DECL. This macro determines whether or not a given class TEMPLATE_DECL. This macro determines whether or not a given class
type is really a template type, as opposed to an instantiation or type is really a template type, as opposed to an instantiation or
...@@ -2430,10 +2442,17 @@ extern int flag_new_for_scope; ...@@ -2430,10 +2442,17 @@ extern int flag_new_for_scope;
#define ASM_VOLATILE_P(NODE) \ #define ASM_VOLATILE_P(NODE) \
(ASM_CV_QUAL ((NODE)) != NULL_TREE) (ASM_CV_QUAL ((NODE)) != NULL_TREE)
/* The line-number at which a statement began. */ /* The line-number at which a statement began. But if
STMT_LINENO_FOR_FN_P does holds, then this macro gives the
line number for the end of the current function instead. */
#define STMT_LINENO(NODE) \ #define STMT_LINENO(NODE) \
(TREE_COMPLEXITY ((NODE))) (TREE_COMPLEXITY ((NODE)))
/* If non-zero, the STMT_LINENO for NODE is the line at which the
function ended. */
#define STMT_LINENO_FOR_FN_P(NODE) \
(TREE_LANG_FLAG_2 ((NODE)))
/* The parameters for a call-declarator. */ /* The parameters for a call-declarator. */
#define CALL_DECLARATOR_PARMS(NODE) \ #define CALL_DECLARATOR_PARMS(NODE) \
(TREE_PURPOSE (TREE_OPERAND ((NODE), 1))) (TREE_PURPOSE (TREE_OPERAND ((NODE), 1)))
...@@ -3635,10 +3654,11 @@ extern tree expand_stmt PROTO((tree)); ...@@ -3635,10 +3654,11 @@ extern tree expand_stmt PROTO((tree));
extern void expand_body PROTO((tree)); extern void expand_body PROTO((tree));
extern void begin_stmt_tree PROTO((tree)); extern void begin_stmt_tree PROTO((tree));
extern void finish_stmt_tree PROTO((tree)); extern void finish_stmt_tree PROTO((tree));
extern void prep_stmt PROTO((tree));
/* Non-zero if we are presently building a statement tree, rather /* Non-zero if we are presently building a statement tree, rather
than expanding each statement as we encounter it. */ than expanding each statement as we encounter it. */
#define building_stmt_tree() \ #define building_stmt_tree() \
(processing_template_decl || !expanding_p) (current_function && (processing_template_decl || !expanding_p))
/* in spew.c */ /* in spew.c */
extern void init_spew PROTO((void)); extern void init_spew PROTO((void));
......
...@@ -7235,6 +7235,7 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7235,6 +7235,7 @@ tsubst_expr (t, args, complain, in_decl)
switch (TREE_CODE (t)) switch (TREE_CODE (t))
{ {
case RETURN_INIT: case RETURN_INIT:
prep_stmt (t);
finish_named_return_value finish_named_return_value
(TREE_OPERAND (t, 0), (TREE_OPERAND (t, 0),
tsubst_expr (TREE_OPERAND (t, 1), args, /*complain=*/1, in_decl)); tsubst_expr (TREE_OPERAND (t, 1), args, /*complain=*/1, in_decl));
...@@ -7242,6 +7243,7 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7242,6 +7243,7 @@ tsubst_expr (t, args, complain, in_decl)
break; break;
case CTOR_INITIALIZER: case CTOR_INITIALIZER:
prep_stmt (t);
current_member_init_list current_member_init_list
= tsubst_expr_values (TREE_OPERAND (t, 0), args); = tsubst_expr_values (TREE_OPERAND (t, 0), args);
current_base_init_list current_base_init_list
...@@ -7251,13 +7253,18 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7251,13 +7253,18 @@ tsubst_expr (t, args, complain, in_decl)
break; break;
case RETURN_STMT: case RETURN_STMT:
lineno = STMT_LINENO (t); prep_stmt (t);
finish_return_stmt (tsubst_expr (RETURN_EXPR (t), finish_return_stmt (tsubst_expr (RETURN_EXPR (t),
args, complain, in_decl)); args, complain, in_decl));
break; break;
case EXPR_STMT: case EXPR_STMT:
lineno = STMT_LINENO (t); prep_stmt (t);
/* If we're doing tsubst'ing, then we should not yet have done
semantic analysisy, so we should not know that this statement
assigns to the `this' pointer. */
my_friendly_assert (EXPR_STMT_ASSIGNS_THIS (t) == 0,
19990831);
finish_expr_stmt (tsubst_expr (EXPR_STMT_EXPR (t), finish_expr_stmt (tsubst_expr (EXPR_STMT_EXPR (t),
args, complain, in_decl)); args, complain, in_decl));
break; break;
...@@ -7268,7 +7275,7 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7268,7 +7275,7 @@ tsubst_expr (t, args, complain, in_decl)
tree decl; tree decl;
tree init; tree init;
lineno = STMT_LINENO (t); prep_stmt (t);
decl = DECL_STMT_DECL (t); decl = DECL_STMT_DECL (t);
if (TREE_CODE (decl) == LABEL_DECL) if (TREE_CODE (decl) == LABEL_DECL)
finish_label_decl (DECL_NAME (decl)); finish_label_decl (DECL_NAME (decl));
...@@ -7296,7 +7303,7 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7296,7 +7303,7 @@ tsubst_expr (t, args, complain, in_decl)
case FOR_STMT: case FOR_STMT:
{ {
tree tmp; tree tmp;
lineno = STMT_LINENO (t); prep_stmt (t);
stmt = begin_for_stmt (); stmt = begin_for_stmt ();
for (tmp = FOR_INIT_STMT (t); tmp; tmp = TREE_CHAIN (tmp)) for (tmp = FOR_INIT_STMT (t); tmp; tmp = TREE_CHAIN (tmp))
...@@ -7314,7 +7321,7 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7314,7 +7321,7 @@ tsubst_expr (t, args, complain, in_decl)
case WHILE_STMT: case WHILE_STMT:
{ {
lineno = STMT_LINENO (t); prep_stmt (t);
stmt = begin_while_stmt (); stmt = begin_while_stmt ();
finish_while_stmt_cond (tsubst_expr (WHILE_COND (t), finish_while_stmt_cond (tsubst_expr (WHILE_COND (t),
args, complain, in_decl), args, complain, in_decl),
...@@ -7326,7 +7333,7 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7326,7 +7333,7 @@ tsubst_expr (t, args, complain, in_decl)
case DO_STMT: case DO_STMT:
{ {
lineno = STMT_LINENO (t); prep_stmt (t);
stmt = begin_do_stmt (); stmt = begin_do_stmt ();
tsubst_expr (DO_BODY (t), args, complain, in_decl); tsubst_expr (DO_BODY (t), args, complain, in_decl);
finish_do_body (stmt); finish_do_body (stmt);
...@@ -7340,7 +7347,7 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7340,7 +7347,7 @@ tsubst_expr (t, args, complain, in_decl)
{ {
tree tmp; tree tmp;
lineno = STMT_LINENO (t); prep_stmt (t);
stmt = begin_if_stmt (); stmt = begin_if_stmt ();
finish_if_stmt_cond (tsubst_expr (IF_COND (t), finish_if_stmt_cond (tsubst_expr (IF_COND (t),
args, complain, in_decl), args, complain, in_decl),
...@@ -7367,7 +7374,7 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7367,7 +7374,7 @@ tsubst_expr (t, args, complain, in_decl)
{ {
tree substmt; tree substmt;
lineno = STMT_LINENO (t); prep_stmt (t);
stmt = begin_compound_stmt (COMPOUND_STMT_NO_SCOPE (t)); stmt = begin_compound_stmt (COMPOUND_STMT_NO_SCOPE (t));
for (substmt = COMPOUND_BODY (t); for (substmt = COMPOUND_BODY (t);
substmt != NULL_TREE; substmt != NULL_TREE;
...@@ -7378,12 +7385,12 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7378,12 +7385,12 @@ tsubst_expr (t, args, complain, in_decl)
break; break;
case BREAK_STMT: case BREAK_STMT:
lineno = STMT_LINENO (t); prep_stmt (t);
finish_break_stmt (); finish_break_stmt ();
break; break;
case CONTINUE_STMT: case CONTINUE_STMT:
lineno = STMT_LINENO (t); prep_stmt (t);
finish_continue_stmt (); finish_continue_stmt ();
break; break;
...@@ -7391,7 +7398,7 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7391,7 +7398,7 @@ tsubst_expr (t, args, complain, in_decl)
{ {
tree val; tree val;
lineno = STMT_LINENO (t); prep_stmt (t);
stmt = begin_switch_stmt (); stmt = begin_switch_stmt ();
val = tsubst_expr (SWITCH_COND (t), args, complain, in_decl); val = tsubst_expr (SWITCH_COND (t), args, complain, in_decl);
finish_switch_cond (val, stmt); finish_switch_cond (val, stmt);
...@@ -7401,6 +7408,7 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7401,6 +7408,7 @@ tsubst_expr (t, args, complain, in_decl)
break; break;
case CASE_LABEL: case CASE_LABEL:
prep_stmt (t);
finish_case_label (tsubst_expr (CASE_LOW (t), args, complain, in_decl), finish_case_label (tsubst_expr (CASE_LOW (t), args, complain, in_decl),
tsubst_expr (CASE_HIGH (t), args, complain, in_decl)); tsubst_expr (CASE_HIGH (t), args, complain, in_decl));
break; break;
...@@ -7411,7 +7419,7 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7411,7 +7419,7 @@ tsubst_expr (t, args, complain, in_decl)
break; break;
case GOTO_STMT: case GOTO_STMT:
lineno = STMT_LINENO (t); prep_stmt (t);
t = GOTO_DESTINATION (t); t = GOTO_DESTINATION (t);
if (TREE_CODE (t) != LABEL_DECL) if (TREE_CODE (t) != LABEL_DECL)
/* Computed goto's must be tsubst'd into. On the other hand, /* Computed goto's must be tsubst'd into. On the other hand,
...@@ -7424,7 +7432,7 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7424,7 +7432,7 @@ tsubst_expr (t, args, complain, in_decl)
break; break;
case ASM_STMT: case ASM_STMT:
lineno = STMT_LINENO (t); prep_stmt (t);
finish_asm_stmt (ASM_CV_QUAL (t), finish_asm_stmt (ASM_CV_QUAL (t),
tsubst_expr (ASM_STRING (t), args, complain, in_decl), tsubst_expr (ASM_STRING (t), args, complain, in_decl),
tsubst_expr (ASM_OUTPUTS (t), args, complain, in_decl), tsubst_expr (ASM_OUTPUTS (t), args, complain, in_decl),
...@@ -7434,7 +7442,7 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7434,7 +7442,7 @@ tsubst_expr (t, args, complain, in_decl)
break; break;
case TRY_BLOCK: case TRY_BLOCK:
lineno = STMT_LINENO (t); prep_stmt (t);
stmt = begin_try_block (); stmt = begin_try_block ();
tsubst_expr (TRY_STMTS (t), args, complain, in_decl); tsubst_expr (TRY_STMTS (t), args, complain, in_decl);
finish_try_block (stmt); finish_try_block (stmt);
...@@ -7452,7 +7460,7 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7452,7 +7460,7 @@ tsubst_expr (t, args, complain, in_decl)
break; break;
case HANDLER: case HANDLER:
lineno = STMT_LINENO (t); prep_stmt (t);
stmt = begin_handler (); stmt = begin_handler ();
if (HANDLER_PARMS (t)) if (HANDLER_PARMS (t))
expand_start_catch_block expand_start_catch_block
...@@ -7466,7 +7474,7 @@ tsubst_expr (t, args, complain, in_decl) ...@@ -7466,7 +7474,7 @@ tsubst_expr (t, args, complain, in_decl)
break; break;
case TAG_DEFN: case TAG_DEFN:
lineno = STMT_LINENO (t); prep_stmt (t);
t = TREE_TYPE (t); t = TREE_TYPE (t);
if (TREE_CODE (t) == ENUMERAL_TYPE) if (TREE_CODE (t) == ENUMERAL_TYPE)
tsubst (t, args, complain, NULL_TREE); tsubst (t, args, complain, NULL_TREE);
...@@ -9854,14 +9862,6 @@ tsubst_expr_values (t, argvec) ...@@ -9854,14 +9862,6 @@ tsubst_expr_values (t, argvec)
} }
void void
add_tree (t)
tree t;
{
last_tree = TREE_CHAIN (last_tree) = t;
}
void
begin_tree () begin_tree ()
{ {
if (current_function) if (current_function)
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
static void expand_stmts PROTO((tree)); static void expand_stmts PROTO((tree));
static void do_pushlevel PROTO((void)); static void do_pushlevel PROTO((void));
static tree do_poplevel PROTO((void)); static tree do_poplevel PROTO((void));
static void finish_expr_stmt_real PROTO((tree, int));
static tree expand_cond PROTO((tree)); static tree expand_cond PROTO((tree));
/* When parsing a template, LAST_TREE contains the last statement /* When parsing a template, LAST_TREE contains the last statement
...@@ -75,11 +76,29 @@ static tree expand_cond PROTO((tree)); ...@@ -75,11 +76,29 @@ static tree expand_cond PROTO((tree));
substmt = cond; \ substmt = cond; \
} while (0) } while (0)
/* Finish an expression-statement, whose EXPRESSION is as indicated. */ /* T is a statement. Add it to the statement-tree. */
void void
finish_expr_stmt (expr) add_tree (t)
tree t;
{
/* Add T to the statement-tree. */
last_tree = TREE_CHAIN (last_tree) = t;
/* When we expand a statement-tree, we must know whether or not the
statements are full-expresions. We record that fact here. */
if (building_stmt_tree ())
STMT_IS_FULL_EXPR_P (last_tree) = stmts_are_full_exprs_p;
}
/* Finish an expression-statement, whose EXPRESSION is as indicated.
If ASSIGNED_THIS is non-zero, then this statement just assigned to
the `this' pointer. */
static void
finish_expr_stmt_real (expr, assigned_this)
tree expr; tree expr;
int assigned_this;
{ {
if (expr != NULL_TREE) if (expr != NULL_TREE)
{ {
...@@ -109,6 +128,11 @@ finish_expr_stmt (expr) ...@@ -109,6 +128,11 @@ finish_expr_stmt (expr)
} }
} }
/* If this statement assigned to the `this' pointer, record that
fact for finish_stmt. */
if (assigned_this)
current_function_just_assigned_this = 1;
finish_stmt (); finish_stmt ();
/* This was an expression-statement, so we save the type of the /* This was an expression-statement, so we save the type of the
...@@ -116,6 +140,15 @@ finish_expr_stmt (expr) ...@@ -116,6 +140,15 @@ finish_expr_stmt (expr)
last_expr_type = expr ? TREE_TYPE (expr) : NULL_TREE; last_expr_type = expr ? TREE_TYPE (expr) : NULL_TREE;
} }
/* Like finish_expr_stmt_real, but ASSIGNS_THIS is always zero. */
void
finish_expr_stmt (expr)
tree expr;
{
finish_expr_stmt_real (expr, /*assigns_this=*/0);
}
/* Begin an if-statement. Returns a newly created IF_STMT if /* Begin an if-statement. Returns a newly created IF_STMT if
appropriate. */ appropriate. */
...@@ -146,12 +179,7 @@ finish_if_stmt_cond (cond, if_stmt) ...@@ -146,12 +179,7 @@ finish_if_stmt_cond (cond, if_stmt)
tree if_stmt; tree if_stmt;
{ {
if (building_stmt_tree ()) if (building_stmt_tree ())
{ FINISH_COND (cond, if_stmt, IF_COND (if_stmt));
if (last_tree != if_stmt)
RECHAIN_STMTS_FROM_LAST (if_stmt, IF_COND (if_stmt));
else
IF_COND (if_stmt) = cond;
}
else else
{ {
emit_line_note (input_filename, lineno); emit_line_note (input_filename, lineno);
...@@ -244,12 +272,7 @@ finish_while_stmt_cond (cond, while_stmt) ...@@ -244,12 +272,7 @@ finish_while_stmt_cond (cond, while_stmt)
tree while_stmt; tree while_stmt;
{ {
if (building_stmt_tree ()) if (building_stmt_tree ())
{ FINISH_COND (cond, while_stmt, WHILE_COND (while_stmt));
if (last_tree != while_stmt)
RECHAIN_STMTS_FROM_LAST (while_stmt, WHILE_COND (while_stmt));
else
TREE_OPERAND (while_stmt, 0) = cond;
}
else else
{ {
emit_line_note (input_filename, lineno); emit_line_note (input_filename, lineno);
...@@ -409,12 +432,7 @@ finish_for_cond (cond, for_stmt) ...@@ -409,12 +432,7 @@ finish_for_cond (cond, for_stmt)
tree for_stmt; tree for_stmt;
{ {
if (building_stmt_tree ()) if (building_stmt_tree ())
{ FINISH_COND (cond, for_stmt, FOR_COND (for_stmt));
if (last_tree != for_stmt)
RECHAIN_STMTS_FROM_LAST (for_stmt, FOR_COND (for_stmt));
else
FOR_COND (for_stmt) = cond;
}
else else
{ {
emit_line_note (input_filename, lineno); emit_line_note (input_filename, lineno);
...@@ -1973,7 +1991,28 @@ void ...@@ -1973,7 +1991,28 @@ void
finish_stmt_tree (fn) finish_stmt_tree (fn)
tree fn; tree fn;
{ {
DECL_SAVED_TREE (fn) = TREE_CHAIN (DECL_SAVED_TREE (fn)); tree stmt;
/* Remove the fake extra statement added in begin_stmt_tree. */
stmt = TREE_CHAIN (DECL_SAVED_TREE (fn));
DECL_SAVED_TREE (fn) = stmt;
/* The line-number recorded in the outermost statement in a function
is the line number of the end of the function. */
STMT_LINENO (stmt) = lineno;
STMT_LINENO_FOR_FN_P (stmt) = 1;
}
/* We're about to expand T, a statement. Set up appropriate context
for the substitution. */
void
prep_stmt (t)
tree t;
{
if (!STMT_LINENO_FOR_FN_P (t))
lineno = STMT_LINENO (t);
stmts_are_full_exprs_p = STMT_IS_FULL_EXPR_P (t);
} }
/* Some statements, like for-statements or if-statements, require a /* Some statements, like for-statements or if-statements, require a
...@@ -2013,19 +2052,28 @@ tree ...@@ -2013,19 +2052,28 @@ tree
expand_stmt (t) expand_stmt (t)
tree t; tree t;
{ {
int saved_stmts_are_full_exprs_p;
tree rval;
if (t == NULL_TREE || t == error_mark_node) if (t == NULL_TREE || t == error_mark_node)
return NULL_TREE; return NULL_TREE;
/* Assume we'll have nothing to return. */
rval = NULL_TREE;
/* Set up context appropriately for handling this statement. */
saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p;
prep_stmt (t);
switch (TREE_CODE (t)) switch (TREE_CODE (t))
{ {
case RETURN_STMT: case RETURN_STMT:
lineno = STMT_LINENO (t);
finish_return_stmt (RETURN_EXPR (t)); finish_return_stmt (RETURN_EXPR (t));
break; break;
case EXPR_STMT: case EXPR_STMT:
lineno = STMT_LINENO (t); finish_expr_stmt_real (EXPR_STMT_EXPR (t),
finish_expr_stmt (EXPR_STMT_EXPR (t)); EXPR_STMT_ASSIGNS_THIS (t));
break; break;
case DECL_STMT: case DECL_STMT:
...@@ -2064,7 +2112,6 @@ expand_stmt (t) ...@@ -2064,7 +2112,6 @@ expand_stmt (t)
{ {
tree tmp; tree tmp;
lineno = STMT_LINENO (t);
begin_for_stmt (); begin_for_stmt ();
for (tmp = FOR_INIT_STMT (t); tmp; tmp = TREE_CHAIN (tmp)) for (tmp = FOR_INIT_STMT (t); tmp; tmp = TREE_CHAIN (tmp))
expand_stmt (tmp); expand_stmt (tmp);
...@@ -2079,7 +2126,6 @@ expand_stmt (t) ...@@ -2079,7 +2126,6 @@ expand_stmt (t)
case WHILE_STMT: case WHILE_STMT:
{ {
lineno = STMT_LINENO (t);
begin_while_stmt (); begin_while_stmt ();
finish_while_stmt_cond (expand_cond (WHILE_COND (t)), NULL_TREE); finish_while_stmt_cond (expand_cond (WHILE_COND (t)), NULL_TREE);
expand_stmt (WHILE_BODY (t)); expand_stmt (WHILE_BODY (t));
...@@ -2089,7 +2135,6 @@ expand_stmt (t) ...@@ -2089,7 +2135,6 @@ expand_stmt (t)
case DO_STMT: case DO_STMT:
{ {
lineno = STMT_LINENO (t);
begin_do_stmt (); begin_do_stmt ();
expand_stmt (DO_BODY (t)); expand_stmt (DO_BODY (t));
finish_do_body (NULL_TREE); finish_do_body (NULL_TREE);
...@@ -2098,7 +2143,6 @@ expand_stmt (t) ...@@ -2098,7 +2143,6 @@ expand_stmt (t)
break; break;
case IF_STMT: case IF_STMT:
lineno = STMT_LINENO (t);
begin_if_stmt (); begin_if_stmt ();
finish_if_stmt_cond (expand_cond (IF_COND (t)), NULL_TREE); finish_if_stmt_cond (expand_cond (IF_COND (t)), NULL_TREE);
if (THEN_CLAUSE (t)) if (THEN_CLAUSE (t))
...@@ -2116,19 +2160,17 @@ expand_stmt (t) ...@@ -2116,19 +2160,17 @@ expand_stmt (t)
break; break;
case COMPOUND_STMT: case COMPOUND_STMT:
lineno = STMT_LINENO (t);
begin_compound_stmt (COMPOUND_STMT_NO_SCOPE (t)); begin_compound_stmt (COMPOUND_STMT_NO_SCOPE (t));
expand_stmts (COMPOUND_BODY (t)); expand_stmts (COMPOUND_BODY (t));
return finish_compound_stmt (COMPOUND_STMT_NO_SCOPE (t), rval = finish_compound_stmt (COMPOUND_STMT_NO_SCOPE (t),
NULL_TREE); NULL_TREE);
break;
case BREAK_STMT: case BREAK_STMT:
lineno = STMT_LINENO (t);
finish_break_stmt (); finish_break_stmt ();
break; break;
case CONTINUE_STMT: case CONTINUE_STMT:
lineno = STMT_LINENO (t);
finish_continue_stmt (); finish_continue_stmt ();
break; break;
...@@ -2136,7 +2178,6 @@ expand_stmt (t) ...@@ -2136,7 +2178,6 @@ expand_stmt (t)
{ {
tree cond; tree cond;
lineno = STMT_LINENO (t);
begin_switch_stmt (); begin_switch_stmt ();
cond = expand_cond (SWITCH_COND (t)); cond = expand_cond (SWITCH_COND (t));
finish_switch_cond (cond, NULL_TREE); finish_switch_cond (cond, NULL_TREE);
...@@ -2150,12 +2191,10 @@ expand_stmt (t) ...@@ -2150,12 +2191,10 @@ expand_stmt (t)
break; break;
case LABEL_STMT: case LABEL_STMT:
lineno = STMT_LINENO (t);
finish_label_stmt (DECL_NAME (LABEL_STMT_LABEL (t))); finish_label_stmt (DECL_NAME (LABEL_STMT_LABEL (t)));
break; break;
case GOTO_STMT: case GOTO_STMT:
lineno = STMT_LINENO (t);
if (TREE_CODE (GOTO_DESTINATION (t)) == LABEL_DECL) if (TREE_CODE (GOTO_DESTINATION (t)) == LABEL_DECL)
finish_goto_stmt (DECL_NAME (GOTO_DESTINATION (t))); finish_goto_stmt (DECL_NAME (GOTO_DESTINATION (t)));
else else
...@@ -2163,13 +2202,11 @@ expand_stmt (t) ...@@ -2163,13 +2202,11 @@ expand_stmt (t)
break; break;
case ASM_STMT: case ASM_STMT:
lineno = STMT_LINENO (t);
finish_asm_stmt (ASM_CV_QUAL (t), ASM_STRING (t), ASM_OUTPUTS finish_asm_stmt (ASM_CV_QUAL (t), ASM_STRING (t), ASM_OUTPUTS
(t), ASM_INPUTS (t), ASM_CLOBBERS (t)); (t), ASM_INPUTS (t), ASM_CLOBBERS (t));
break; break;
case TRY_BLOCK: case TRY_BLOCK:
lineno = STMT_LINENO (t);
if (CLEANUP_P (t)) if (CLEANUP_P (t))
{ {
expand_eh_region_start (); expand_eh_region_start ();
...@@ -2187,7 +2224,6 @@ expand_stmt (t) ...@@ -2187,7 +2224,6 @@ expand_stmt (t)
break; break;
case HANDLER: case HANDLER:
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))); expand_start_catch_block (DECL_STMT_DECL (HANDLER_PARMS (t)));
...@@ -2199,7 +2235,6 @@ expand_stmt (t) ...@@ -2199,7 +2235,6 @@ expand_stmt (t)
break; break;
case SUBOBJECT: case SUBOBJECT:
lineno = STMT_LINENO (t);
finish_subobject (SUBOBJECT_CLEANUP (t)); finish_subobject (SUBOBJECT_CLEANUP (t));
break; break;
...@@ -2208,7 +2243,10 @@ expand_stmt (t) ...@@ -2208,7 +2243,10 @@ expand_stmt (t)
break; break;
} }
return NULL_TREE; /* Restore saved state. */
stmts_are_full_exprs_p = saved_stmts_are_full_exprs_p;
return rval;
} }
/* Generate RTL for FN. */ /* Generate RTL for FN. */
......
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