summaryrefslogtreecommitdiff
path: root/gcc/c-semantics.c
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2000-09-10 21:34:41 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2000-09-10 21:34:41 +0000
commit225ec6aae7502e0b287baca4fd3d4f6d89ad7400 (patch)
treee6b472ea3504de9f1d42acce2241fe0cbaf55dcf /gcc/c-semantics.c
parent508f18c8cfcf812f41173c35b744d20f6a4fd1e6 (diff)
downloadgcc-225ec6aae7502e0b287baca4fd3d4f6d89ad7400.tar.gz
* c-common.h (add_stmt): Change prototype.
(RECHAIN_STMTS): New macro. (CASE_LABEL_DECL): Likewise. (genrtl_case_label): Change prototype. (c_expand_start_case): Remove prototype. (build_case_label): Change prototype. (decl_constant_value): Declare. * c-common.c (check_case_value): Handle C++'s extensions to C semantics. * c-commnon.def (CASE_LABEL): Add room for the CASE_LABEL_DECL field. * c-parse.in (stmt): Adjust handling of return statements and case laels. * c-semantics.c (add_stmt): Return the new statement. (genrtl_return_stmt): Take the RETURN_STMT as input, not the returned expression. Directly generate RTL, rather than calling c_expand_return. (genrtl_switch_stmt): Don't call c_expand_start_case. (build_case_label): Take the LABEL_DECL as input, too. (genrtl_case_label): Just call add_case_node. (expand_stmt): Adjust calls to genrtl_return_stmt and genrtl_case_label. * c-tree.h (c_expand_start_case): Declare. * c-typeck.c (decl_constant_value): Give it external linkage. (c_expand_return): Don't call expand_return or expand_null_return; use genrtl_return_stmt instead. * stmt.c (struct nesting): Remove num_ranges field. (add_case_node): Give it external linkage. (expand_start_case): Don't set num_ranges. (expand_start_case_dummy): Don't clear it. (pushcase): Rely on add_case_node to handle `default' labels. (add_case_node): Handle `default' labels. * tree.c (tree_int_cst_compare): New function. * tree.h (tree_int_cst_compare): Declare. (add_case_node): Likewise. * cp-tree.h (push_switch): Change prototype. (check_cp_case_value): Remove declaration. (decl_constant_value): Likewise. * decl.c (struct cp_switch): Add switch_stmt and cases. (case_compare): New function. (push_switch): Set switch_stmt. Initialize cases. (pop_switch): Clean up cases. (define_case_label): Rename to ... (finish_case_label): ... this. Do semantic analysis for case labels here. (start_function): Correct comment. * decl2.c (check_cp_case_value): Remove. * expr.c (do_case): Remove. * pt.c (tsubst_expr): Adjust call to finish_case_label. * semantics.c (genrtl_do_poplevel): Remove declaration. (RECHAIN_STMTS): Remove. (finish_break_stmt): Use build_break_stmt. (finish_continue_stmt): Use build_continue_stmt. (finish_switch_cond): Adjust condition here, rater than in c_expand_start_case. (finish_case_label): Remove. * typeck.c (c_expand_return): Remove. (c_expand_start_case): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@36305 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-semantics.c')
-rw-r--r--gcc/c-semantics.c50
1 files changed, 29 insertions, 21 deletions
diff --git a/gcc/c-semantics.c b/gcc/c-semantics.c
index 8a4cf91c6c4..991311ef117 100644
--- a/gcc/c-semantics.c
+++ b/gcc/c-semantics.c
@@ -58,7 +58,7 @@ begin_stmt_tree (t)
/* T is a statement. Add it to the statement-tree. */
-void
+tree
add_stmt (t)
tree t;
{
@@ -68,6 +68,7 @@ add_stmt (t)
/* When we expand a statement-tree, we must know whether or not the
statements are full-expresions. We record that fact here. */
STMT_IS_FULL_EXPR_P (last_tree) = stmts_are_full_exprs_p ();
+ return t;
}
/* Remove declarations of internal variables that are not used from a
@@ -434,14 +435,23 @@ build_return_stmt (expr)
return (build_stmt (RETURN_STMT, expr));
}
-/* Generate the RTL for EXPR, which is a RETURN_STMT. */
+/* Generate the RTL for STMT, which is a RETURN_STMT. */
void
-genrtl_return_stmt (expr)
- tree expr;
+genrtl_return_stmt (stmt)
+ tree stmt;
{
+ tree expr = RETURN_EXPR (stmt);
+
emit_line_note (input_filename, lineno);
- c_expand_return (expr);
+ if (!expr)
+ expand_null_return ();
+ else
+ {
+ expand_start_target_temps ();
+ expand_return (expr);
+ expand_end_target_temps ();
+ }
}
/* Generate the RTL for T, which is a FOR_STMT. */
@@ -547,40 +557,38 @@ genrtl_switch_stmt (t)
genrtl_do_pushlevel ();
cond = expand_cond (SWITCH_COND (t));
- if (cond != error_mark_node)
- {
- emit_line_note (input_filename, lineno);
- c_expand_start_case (cond);
- }
- else
+ if (cond == error_mark_node)
/* The code is in error, but we don't want expand_end_case to
crash. */
- c_expand_start_case (boolean_false_node);
+ cond = boolean_false_node;
+ emit_line_note (input_filename, lineno);
+ expand_start_case (1, cond, TREE_TYPE (cond), "switch statement");
expand_stmt (SWITCH_BODY (t));
-
expand_end_case (cond);
}
/* Create a CASE_LABEL tree node and return it. */
tree
-build_case_label (low_value, high_value)
+build_case_label (low_value, high_value, label_decl)
tree low_value;
tree high_value;
+ tree label_decl;
{
- return build_stmt (CASE_LABEL, low_value, high_value);
+ return build_stmt (CASE_LABEL, low_value, high_value, label_decl);
}
/* Generate the RTL for a CASE_LABEL. */
void
-genrtl_case_label (low_value, high_value)
- tree low_value;
- tree high_value;
+genrtl_case_label (case_label)
+ tree case_label;
{
- do_case (low_value, high_value);
+ tree duplicate;
+ add_case_node (CASE_LOW (case_label), CASE_HIGH (case_label),
+ CASE_LABEL_DECL (case_label), &duplicate);
}
/* Generate the RTL for T, which is a COMPOUND_STMT. */
@@ -677,7 +685,7 @@ expand_stmt (t)
switch (TREE_CODE (t))
{
case RETURN_STMT:
- genrtl_return_stmt (RETURN_EXPR (t));
+ genrtl_return_stmt (t);
break;
case EXPR_STMT:
@@ -721,7 +729,7 @@ expand_stmt (t)
break;
case CASE_LABEL:
- genrtl_case_label (CASE_LOW (t), CASE_HIGH (t));
+ genrtl_case_label (t);
break;
case LABEL_STMT: