Commit 5d764395 by Jason Merrill Committed by Jason Merrill

semantics.c (finish_then_clause): Remove redundant assignment.

        * semantics.c (finish_then_clause): Remove redundant assignment.
        (finish_if_stmt, begin_switch_stmt, finish_switch_stmt): Move the
        extra binding level outside the if/switch statement.
        (finish_while_cond, finish_for_cond): Rewrite complex condition
        into the loop body.

From-SVN: r56402
parent 8aa5074e
2002-08-15 Jason Merrill <jason@redhat.com>
* semantics.c (finish_then_clause): Remove redundant assignment.
(finish_if_stmt, begin_switch_stmt, finish_switch_stmt): Move the
extra binding level outside the if/switch statement.
(finish_while_cond, finish_for_cond): Rewrite complex condition
into the loop body.
2002-08-15 Alexandre Oliva <aoliva@redhat.com> 2002-08-15 Alexandre Oliva <aoliva@redhat.com>
* parse.y (sizeof, alignof, typeof): New non-terminals to * parse.y (sizeof, alignof, typeof): New non-terminals to
......
...@@ -266,7 +266,6 @@ finish_then_clause (if_stmt) ...@@ -266,7 +266,6 @@ finish_then_clause (if_stmt)
tree if_stmt; tree if_stmt;
{ {
RECHAIN_STMTS (if_stmt, THEN_CLAUSE (if_stmt)); RECHAIN_STMTS (if_stmt, THEN_CLAUSE (if_stmt));
last_tree = if_stmt;
return if_stmt; return if_stmt;
} }
...@@ -292,21 +291,8 @@ finish_else_clause (if_stmt) ...@@ -292,21 +291,8 @@ finish_else_clause (if_stmt)
void void
finish_if_stmt () finish_if_stmt ()
{ {
do_poplevel ();
finish_stmt (); finish_stmt ();
} do_poplevel ();
void
clear_out_block ()
{
/* If COND wasn't a declaration, clear out the
block we made for it and start a new one here so the
optimization in expand_end_loop will work. */
if (getdecls () == NULL_TREE)
{
do_poplevel ();
do_pushlevel ();
}
} }
/* Begin a while-statement. Returns a newly created WHILE_STMT if /* Begin a while-statement. Returns a newly created WHILE_STMT if
...@@ -331,8 +317,26 @@ finish_while_stmt_cond (cond, while_stmt) ...@@ -331,8 +317,26 @@ finish_while_stmt_cond (cond, while_stmt)
tree while_stmt; tree while_stmt;
{ {
cond = maybe_convert_cond (cond); cond = maybe_convert_cond (cond);
FINISH_COND (cond, while_stmt, WHILE_COND (while_stmt)); if (getdecls () == NULL_TREE)
clear_out_block (); /* It was a simple condition; install it. */
WHILE_COND (while_stmt) = cond;
else
{
/* If there was a declaration in the condition, we can't leave it
there; transform
while (A x = 42) { }
to
while (true) { A x = 42; if (!x) break; } */
tree if_stmt;
WHILE_COND (while_stmt) = boolean_true_node;
if_stmt = begin_if_stmt ();
cond = build_unary_op (TRUTH_NOT_EXPR, cond, 0);
finish_if_stmt_cond (cond, if_stmt);
finish_break_stmt ();
finish_then_clause (if_stmt);
finish_if_stmt ();
}
} }
/* Finish a while-statement, which may be given by WHILE_STMT. */ /* Finish a while-statement, which may be given by WHILE_STMT. */
...@@ -448,8 +452,26 @@ finish_for_cond (cond, for_stmt) ...@@ -448,8 +452,26 @@ finish_for_cond (cond, for_stmt)
tree for_stmt; tree for_stmt;
{ {
cond = maybe_convert_cond (cond); cond = maybe_convert_cond (cond);
FINISH_COND (cond, for_stmt, FOR_COND (for_stmt)); if (getdecls () == NULL_TREE)
clear_out_block (); /* It was a simple condition; install it. */
FOR_COND (for_stmt) = cond;
else
{
/* If there was a declaration in the condition, we can't leave it
there; transform
for (; A x = 42;) { }
to
for (;;) { A x = 42; if (!x) break; } */
tree if_stmt;
FOR_COND (for_stmt) = NULL_TREE;
if_stmt = begin_if_stmt ();
cond = build_unary_op (TRUTH_NOT_EXPR, cond, 0);
finish_if_stmt_cond (cond, if_stmt);
finish_break_stmt ();
finish_then_clause (if_stmt);
finish_if_stmt ();
}
} }
/* Finish the increment-EXPRESSION in a for-statement, which may be /* Finish the increment-EXPRESSION in a for-statement, which may be
...@@ -502,9 +524,9 @@ tree ...@@ -502,9 +524,9 @@ tree
begin_switch_stmt () begin_switch_stmt ()
{ {
tree r; tree r;
do_pushlevel ();
r = build_stmt (SWITCH_STMT, NULL_TREE, NULL_TREE, NULL_TREE); r = build_stmt (SWITCH_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
add_stmt (r); add_stmt (r);
do_pushlevel ();
return r; return r;
} }
...@@ -560,8 +582,8 @@ finish_switch_stmt (switch_stmt) ...@@ -560,8 +582,8 @@ finish_switch_stmt (switch_stmt)
{ {
RECHAIN_STMTS (switch_stmt, SWITCH_BODY (switch_stmt)); RECHAIN_STMTS (switch_stmt, SWITCH_BODY (switch_stmt));
pop_switch (); pop_switch ();
do_poplevel ();
finish_stmt (); finish_stmt ();
do_poplevel ();
} }
/* Generate the RTL for T, which is a TRY_BLOCK. */ /* Generate the RTL for T, which is a TRY_BLOCK. */
......
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