c-semantics.c (expand_unreachable_stmt): Return a tree.

* c-semantics.c (expand_unreachable_stmt): Return a tree.
	(expand_stmt): Update for change to expand_unreachable_stmt.
	(expand_unreachable_if_stmt): Likewise.

From-SVN: r66252
This commit is contained in:
Geoffrey Keating 2003-04-29 20:39:12 +00:00 committed by Geoffrey Keating
parent b9538b2e88
commit e55614cab2
2 changed files with 52 additions and 44 deletions

View File

@ -1,5 +1,9 @@
2003-04-29 Geoffrey Keating <geoffk@apple.com> 2003-04-29 Geoffrey Keating <geoffk@apple.com>
* c-semantics.c (expand_unreachable_stmt): Return a tree.
(expand_stmt): Update for change to expand_unreachable_stmt.
(expand_unreachable_if_stmt): Likewise.
* Makefile.in (quickstrap): Pass BOOT_CFLAGS to submake. * Makefile.in (quickstrap): Pass BOOT_CFLAGS to submake.
2003-04-29 Jason Merrill <jason@redhat.com> 2003-04-29 Jason Merrill <jason@redhat.com>

View File

@ -55,7 +55,7 @@ void (*lang_expand_decl_stmt) PARAMS ((tree));
static tree find_reachable_label_1 PARAMS ((tree *, int *, void *)); static tree find_reachable_label_1 PARAMS ((tree *, int *, void *));
static tree find_reachable_label PARAMS ((tree)); static tree find_reachable_label PARAMS ((tree));
static bool expand_unreachable_if_stmt PARAMS ((tree)); static bool expand_unreachable_if_stmt PARAMS ((tree));
static bool expand_unreachable_stmt PARAMS ((tree, int)); static tree expand_unreachable_stmt PARAMS ((tree, int));
/* Create an empty statement tree rooted at T. */ /* Create an empty statement tree rooted at T. */
@ -823,8 +823,8 @@ expand_stmt (t)
case RETURN_STMT: case RETURN_STMT:
genrtl_return_stmt (t); genrtl_return_stmt (t);
expand_unreachable_stmt (TREE_CHAIN (t), warn_notreached); t = expand_unreachable_stmt (TREE_CHAIN (t), warn_notreached);
return; goto process_t;
case EXPR_STMT: case EXPR_STMT:
genrtl_expr_stmt_value (EXPR_STMT_EXPR (t), TREE_ADDRESSABLE (t), genrtl_expr_stmt_value (EXPR_STMT_EXPR (t), TREE_ADDRESSABLE (t),
@ -859,13 +859,13 @@ expand_stmt (t)
case BREAK_STMT: case BREAK_STMT:
genrtl_break_stmt (); genrtl_break_stmt ();
expand_unreachable_stmt (TREE_CHAIN (t), warn_notreached); t = expand_unreachable_stmt (TREE_CHAIN (t), warn_notreached);
return; goto process_t;
case CONTINUE_STMT: case CONTINUE_STMT:
genrtl_continue_stmt (); genrtl_continue_stmt ();
expand_unreachable_stmt (TREE_CHAIN (t), warn_notreached); t = expand_unreachable_stmt (TREE_CHAIN (t), warn_notreached);
return; goto process_t;
case SWITCH_STMT: case SWITCH_STMT:
genrtl_switch_stmt (t); genrtl_switch_stmt (t);
@ -890,8 +890,8 @@ expand_stmt (t)
NOTE_PREDICTION (note) = NOTE_PREDICT (PRED_GOTO, NOT_TAKEN); NOTE_PREDICTION (note) = NOTE_PREDICT (PRED_GOTO, NOT_TAKEN);
} }
genrtl_goto_stmt (GOTO_DESTINATION (t)); genrtl_goto_stmt (GOTO_DESTINATION (t));
expand_unreachable_stmt (TREE_CHAIN (t), warn_notreached); t = expand_unreachable_stmt (TREE_CHAIN (t), warn_notreached);
return; goto process_t;
case ASM_STMT: case ASM_STMT:
genrtl_asm_stmt (ASM_CV_QUAL (t), ASM_STRING (t), genrtl_asm_stmt (ASM_CV_QUAL (t), ASM_STRING (t),
@ -915,12 +915,13 @@ expand_stmt (t)
break; break;
} }
/* Go on to the next statement in this scope. */
t = TREE_CHAIN (t);
process_t:
/* Restore saved state. */ /* Restore saved state. */
current_stmt_tree ()->stmts_are_full_exprs_p current_stmt_tree ()->stmts_are_full_exprs_p
= saved_stmts_are_full_exprs_p; = saved_stmts_are_full_exprs_p;
/* Go on to the next statement in this scope. */
t = TREE_CHAIN (t);
} }
} }
@ -964,6 +965,8 @@ static bool
expand_unreachable_if_stmt (t) expand_unreachable_if_stmt (t)
tree t; tree t;
{ {
tree n;
if (find_reachable_label (IF_COND (t)) != NULL_TREE) if (find_reachable_label (IF_COND (t)) != NULL_TREE)
{ {
genrtl_if_stmt (t); genrtl_if_stmt (t);
@ -972,31 +975,38 @@ expand_unreachable_if_stmt (t)
if (THEN_CLAUSE (t) && ELSE_CLAUSE (t)) if (THEN_CLAUSE (t) && ELSE_CLAUSE (t))
{ {
if (expand_unreachable_stmt (THEN_CLAUSE (t), 0)) n = expand_unreachable_stmt (THEN_CLAUSE (t), 0);
if (n != NULL_TREE)
{ {
rtx label; rtx label;
expand_stmt (n);
label = gen_label_rtx (); label = gen_label_rtx ();
emit_jump (label); emit_jump (label);
expand_unreachable_stmt (ELSE_CLAUSE (t), 0); expand_stmt (expand_unreachable_stmt (ELSE_CLAUSE (t), 0));
emit_label (label); emit_label (label);
return true; return true;
} }
else else
return expand_unreachable_stmt (ELSE_CLAUSE (t), 0); n = expand_unreachable_stmt (ELSE_CLAUSE (t), 0);
} }
else if (THEN_CLAUSE (t)) else if (THEN_CLAUSE (t))
return expand_unreachable_stmt (THEN_CLAUSE (t), 0); n = expand_unreachable_stmt (THEN_CLAUSE (t), 0);
else if (ELSE_CLAUSE (t)) else if (ELSE_CLAUSE (t))
return expand_unreachable_stmt (ELSE_CLAUSE (t), 0); n = expand_unreachable_stmt (ELSE_CLAUSE (t), 0);
else
n = NULL_TREE;
return false; expand_stmt (n);
return n != NULL_TREE;
} }
/* Expand an unreachable statement list. This function skips all /* Expand an unreachable statement list. This function skips all
statements preceding the first potentially reachable label and statements preceding the first potentially reachable label and
then expands the statements normally with expand_stmt. This then returns the label (or, in same cases, the statement after
function returns true if such a reachable label was found. */ one containing the label). */
static bool static tree
expand_unreachable_stmt (t, warn) expand_unreachable_stmt (t, warn)
tree t; tree t;
int warn; int warn;
@ -1037,36 +1047,31 @@ expand_unreachable_stmt (t, warn)
case RETURN_STMT: case RETURN_STMT:
if (find_reachable_label (RETURN_STMT_EXPR (t)) != NULL_TREE) if (find_reachable_label (RETURN_STMT_EXPR (t)) != NULL_TREE)
{ return t;
expand_stmt (t);
return true;
}
break; break;
case EXPR_STMT: case EXPR_STMT:
if (find_reachable_label (EXPR_STMT_EXPR (t)) != NULL_TREE) if (find_reachable_label (EXPR_STMT_EXPR (t)) != NULL_TREE)
{ return t;
expand_stmt (t);
return true;
}
break; break;
case IF_STMT: case IF_STMT:
if (expand_unreachable_if_stmt (t)) if (expand_unreachable_if_stmt (t))
{ return TREE_CHAIN (t);
expand_stmt (TREE_CHAIN (t));
return true;
}
break; break;
case COMPOUND_STMT: case COMPOUND_STMT:
if (expand_unreachable_stmt (COMPOUND_BODY (t), warn))
{ {
expand_stmt (TREE_CHAIN (t)); tree n;
return true; n = expand_unreachable_stmt (COMPOUND_BODY (t), warn);
if (n != NULL_TREE)
{
expand_stmt (n);
return TREE_CHAIN (t);
} }
warn = false; warn = false;
break; break;
}
case SCOPE_STMT: case SCOPE_STMT:
saved = stmts_are_full_exprs_p (); saved = stmts_are_full_exprs_p ();
@ -1076,11 +1081,10 @@ expand_unreachable_stmt (t, warn)
break; break;
default: default:
expand_stmt (t); return t;
return true;
} }
t = TREE_CHAIN (t); t = TREE_CHAIN (t);
} }
return false; return NULL_TREE;
} }