Commit 506e2710 by Richard Henderson Committed by Richard Henderson

c-decl.c (c_in_iteration_stmt, [...]): Remove.

	* c-decl.c (c_in_iteration_stmt, c_in_case_stmt): Remove.
	(c_break_label, c_cont_label): New.
	(start_function): Update initializations.
	(c_push_function_context): Update saves.
	(c_pop_function_context): Update restores.
	* c-parse.in: Update expected conflicts.
	(stmt_count, compstmt_count): Remove.  Remove all updates.
	(if_prefix, simple_if, do_stmt_start): Remove.
	(lineno_labeled_stmt): Remove.
	(lineno_labels): New.
	(c99_block_lineno_labeled_stmt): Use it.
	(lineno_stmt, lineno_label): Don't clear EXPR_LOCUS before calling
	annotate_with_locus.
	(select_or_iter_stmt): Replace by ...
	(condition, if_statement_1, if_statement_2, if_statement,
	start_break, start_continue, while_statement, do_statement,
	for_cond_expr, for_incr_expr, for_statement, switch_statement): New.
	(stmt): Split out ...
	(stmt_nocomp): ... this.  Use c_finish_bc_stmt, c_finish_goto_label,
	c_finish_goto_ptr.
	* c-semantics.c (add_stmt): Don't add line numbers to labels.
	* c-tree.h: Update prototypes.
	(struct language_function): Remove x_in_iteration_stmt, x_in_case_stmt;
	add x_break_label, x_cont_label, x_switch_stack.
	(c_switch_stack): Declare.
	* c-typeck.c (c_finish_goto_label, c_finish_goto_ptr): New.
	(c_finish_return): Return the statement.
	(c_switch_stack): Rename from switch_stack; export.
	(if_elt, if_stack, if_stack_space, if_stack_pointer): Remove.
	(c_begin_if_stmt, c_finish_if_cond, c_finish_then, c_begin_else,
	c_finish_else): Remove.
	(c_finish_if_stmt): Rewrite to perform the entire operation.
	(c_begin_while_stmt, c_finish_while_stmt_cond, c_finish_while_stmt,
	c_begin_for_stmt, c_finish_for_stmt_init, c_finish_for_stmt_cond,
	c_finish_for_stmt_incr, c_finish_for_stmt): Remove.
	(c_finish_loop): New.
	(c_finish_bc_stmt): New.
	(c_finish_expr_stmt): Return the statement.  Split out...
	(c_process_expr_stmt): ... this.  Don't add locus to error marks.
	* gimplify.c (gimplify_cond_expr): Accept NULL type statements.
	* tree-gimple.c (is_gimple_stmt): Likewise.
	* tree-pretty-print.c (dump_generic_node <COND_EXPR>): Likewise.
	(print_struct_decl): Delete empty compound statement.
	* objc/objc-act.c (objc_build_throw_stmt): Return the statement.
	* objc/objc-act.h: Update decl.

From-SVN: r83620
parent 6e6e49b1
2004-06-24 Richard Henderson <rth@redhat.com>
* c-decl.c (c_in_iteration_stmt, c_in_case_stmt): Remove.
(c_break_label, c_cont_label): New.
(start_function): Update initializations.
(c_push_function_context): Update saves.
(c_pop_function_context): Update restores.
* c-parse.in: Update expected conflicts.
(stmt_count, compstmt_count): Remove. Remove all updates.
(if_prefix, simple_if, do_stmt_start): Remove.
(lineno_labeled_stmt): Remove.
(lineno_labels): New.
(c99_block_lineno_labeled_stmt): Use it.
(lineno_stmt, lineno_label): Don't clear EXPR_LOCUS before calling
annotate_with_locus.
(select_or_iter_stmt): Replace by ...
(condition, if_statement_1, if_statement_2, if_statement,
start_break, start_continue, while_statement, do_statement,
for_cond_expr, for_incr_expr, for_statement, switch_statement): New.
(stmt): Split out ...
(stmt_nocomp): ... this. Use c_finish_bc_stmt, c_finish_goto_label,
c_finish_goto_ptr.
* c-semantics.c (add_stmt): Don't add line numbers to labels.
* c-tree.h: Update prototypes.
(struct language_function): Remove x_in_iteration_stmt, x_in_case_stmt;
add x_break_label, x_cont_label, x_switch_stack.
(c_switch_stack): Declare.
* c-typeck.c (c_finish_goto_label, c_finish_goto_ptr): New.
(c_finish_return): Return the statement.
(c_switch_stack): Rename from switch_stack; export.
(if_elt, if_stack, if_stack_space, if_stack_pointer): Remove.
(c_begin_if_stmt, c_finish_if_cond, c_finish_then, c_begin_else,
c_finish_else): Remove.
(c_finish_if_stmt): Rewrite to perform the entire operation.
(c_begin_while_stmt, c_finish_while_stmt_cond, c_finish_while_stmt,
c_begin_for_stmt, c_finish_for_stmt_init, c_finish_for_stmt_cond,
c_finish_for_stmt_incr, c_finish_for_stmt): Remove.
(c_finish_loop): New.
(c_finish_bc_stmt): New.
(c_finish_expr_stmt): Return the statement. Split out...
(c_process_expr_stmt): ... this. Don't add locus to error marks.
* gimplify.c (gimplify_cond_expr): Accept NULL type statements.
* tree-gimple.c (is_gimple_stmt): Likewise.
* tree-pretty-print.c (dump_generic_node <COND_EXPR>): Likewise.
(print_struct_decl): Delete empty compound statement.
* objc/objc-act.c (objc_build_throw_stmt): Return the statement.
* objc/objc-act.h: Update decl.
2004-06-24 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* tree-pretty-print.c (dump_generic_node, case TYPE_DECL):
......
......@@ -109,8 +109,8 @@ static location_t current_function_prototype_locus;
static GTY(()) struct stmt_tree_s c_stmt_tree;
/* State saving variables. */
int c_in_iteration_stmt;
int c_in_case_stmt;
tree c_break_label;
tree c_cont_label;
/* Linked list of TRANSLATION_UNIT_DECLS for the translation units
included in this invocation. Note that the current translation
......@@ -5592,8 +5592,12 @@ start_function (tree declspecs, tree declarator, tree attributes)
current_function_returns_abnormally = 0;
warn_about_return_type = 0;
current_extern_inline = 0;
c_in_iteration_stmt = 0;
c_in_case_stmt = 0;
c_switch_stack = NULL;
/* Indicate no valid break/continue context by setting these variables
to some non-null, non-label value. We'll notice and emit the proper
error message in c_finish_bc_stmt. */
c_break_label = c_cont_label = size_zero_node;
/* Don't expand any sizes in the return type of the function. */
immediate_size_expand = 0;
......@@ -6410,8 +6414,9 @@ c_push_function_context (struct function *f)
f->language = p;
p->base.x_stmt_tree = c_stmt_tree;
p->x_in_iteration_stmt = c_in_iteration_stmt;
p->x_in_case_stmt = c_in_case_stmt;
p->x_break_label = c_break_label;
p->x_cont_label = c_cont_label;
p->x_switch_stack = c_switch_stack;
p->returns_value = current_function_returns_value;
p->returns_null = current_function_returns_null;
p->returns_abnormally = current_function_returns_abnormally;
......@@ -6437,8 +6442,9 @@ c_pop_function_context (struct function *f)
}
c_stmt_tree = p->base.x_stmt_tree;
c_in_iteration_stmt = p->x_in_iteration_stmt;
c_in_case_stmt = p->x_in_case_stmt;
c_break_label = p->x_break_label;
c_cont_label = p->x_cont_label;
c_switch_stack = p->x_switch_stack;
current_function_returns_value = p->returns_value;
current_function_returns_null = p->returns_null;
current_function_returns_abnormally = p->returns_abnormally;
......
......@@ -128,7 +128,9 @@ pop_stmt_list (tree t)
tree
add_stmt (tree t)
{
if (EXPR_P (t) || STATEMENT_CODE_P (TREE_CODE (t)))
enum tree_code code = TREE_CODE (t);
if ((EXPR_P (t) || STATEMENT_CODE_P (code)) && code != LABEL_EXPR)
{
if (!EXPR_LOCUS (t))
annotate_with_locus (t, input_location);
......
......@@ -126,13 +126,14 @@ struct lang_type GTY(())
struct language_function GTY(())
{
struct c_language_function base;
tree x_break_label;
tree x_cont_label;
struct c_switch * GTY((skip)) x_switch_stack;
int returns_value;
int returns_null;
int returns_abnormally;
int warn_about_return_type;
int extern_inline;
int x_in_iteration_stmt;
int x_in_case_stmt;
};
......@@ -143,8 +144,8 @@ extern void c_parse_init (void);
extern void gen_aux_info_record (tree, int, int, int);
/* in c-decl.c */
extern int c_in_iteration_stmt;
extern int c_in_case_stmt;
extern tree c_break_label;
extern tree c_cont_label;
extern int global_bindings_p (void);
extern void push_scope (void);
......@@ -212,6 +213,7 @@ extern bool c_warn_unused_global_decl (tree);
#define c_sizeof_nowarn(T) c_sizeof_or_alignof_type (T, SIZEOF_EXPR, 0)
/* in c-typeck.c */
extern struct c_switch *c_switch_stack;
extern tree require_complete_type (tree);
extern int same_translation_unit_p (tree, tree);
......@@ -254,24 +256,16 @@ extern tree c_convert_parm_for_inlining (tree, tree, tree, int);
extern int c_types_compatible_p (tree, tree);
extern tree c_begin_compound_stmt (bool);
extern tree c_end_compound_stmt (tree, bool);
extern void c_begin_if_stmt (void);
extern void c_finish_if_cond (tree, int, int);
extern void c_finish_then (tree);
extern void c_begin_else (int);
extern void c_finish_else (tree);
extern void c_finish_if_stmt (int);
extern tree c_begin_while_stmt (void);
extern void c_finish_while_stmt_cond (tree, tree);
extern void c_finish_while_stmt (tree, tree);
extern tree c_begin_for_stmt (void);
extern void c_finish_for_stmt_init (tree);
extern void c_finish_for_stmt_cond (tree, tree);
extern void c_finish_for_stmt_incr (tree, tree);
extern void c_finish_for_stmt (tree, tree);
extern void c_finish_if_stmt (location_t, tree, tree, tree, bool);
extern void c_finish_loop (location_t, tree, tree, tree, tree, tree, bool);
extern tree c_begin_stmt_expr (void);
extern tree c_finish_stmt_expr (tree);
extern void c_finish_expr_stmt (tree);
extern void c_finish_return (tree);
extern tree c_process_expr_stmt (tree);
extern tree c_finish_expr_stmt (tree);
extern tree c_finish_return (tree);
extern tree c_finish_bc_stmt (tree *, bool);
extern tree c_finish_goto_label (tree);
extern tree c_finish_goto_ptr (tree);
extern tree build_offsetof (tree, tree);
/* Set to 0 at beginning of a function definition, set to 1 if
......
......@@ -2511,12 +2511,16 @@ static enum gimplify_status
gimplify_cond_expr (tree *expr_p, tree *pre_p, tree target)
{
tree expr = *expr_p;
tree tmp;
tree tmp, type;
enum gimplify_status ret;
type = TREE_TYPE (expr);
if (!type)
TREE_TYPE (expr) = void_type_node;
/* If this COND_EXPR has a value, copy the values into a temporary within
the arms. */
if (! VOID_TYPE_P (TREE_TYPE (expr)))
else if (! VOID_TYPE_P (type))
{
if (target)
{
......
......@@ -3188,10 +3188,12 @@ objc_finish_try_stmt (void)
free (c);
}
void
tree
objc_build_throw_stmt (tree throw_expr)
{
tree func_params;
tree args;
objc_init_exceptions ();
if (throw_expr == NULL)
{
......@@ -3201,7 +3203,7 @@ objc_build_throw_stmt (tree throw_expr)
|| cur_try_context->current_catch == NULL)
{
error ("%<@throw%> (rethrow) used outside of a @catch block");
return;
return NULL_TREE;
}
/* Otherwise the object is still sitting in the EXC_PTR_EXPR
......@@ -3211,10 +3213,8 @@ objc_build_throw_stmt (tree throw_expr)
/* A throw is just a call to the runtime throw function with the
object as a parameter. */
func_params = tree_cons (NULL, throw_expr, NULL);
add_stmt (build_function_call (objc_exception_throw_decl, func_params));
objc_init_exceptions ();
args = tree_cons (NULL, throw_expr, NULL);
return add_stmt (build_function_call (objc_exception_throw_decl, args));
}
void
......
......@@ -39,7 +39,7 @@ void finish_method_def (void);
tree start_protocol (enum tree_code, tree, tree);
void finish_protocol (tree);
void objc_build_throw_stmt (tree);
tree objc_build_throw_stmt (tree);
void objc_begin_try_stmt (location_t, tree);
void objc_begin_catch_clause (tree);
void objc_finish_catch_clause (void);
......
......@@ -348,7 +348,7 @@ is_gimple_stmt (tree t)
case BIND_EXPR:
case COND_EXPR:
/* These are only valid if they're void. */
return VOID_TYPE_P (TREE_TYPE (t));
return TREE_TYPE (t) == NULL || VOID_TYPE_P (TREE_TYPE (t));
case SWITCH_EXPR:
case GOTO_EXPR:
......
......@@ -767,7 +767,7 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
break;
case COND_EXPR:
if (TREE_TYPE (node) == void_type_node)
if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
{
pp_string (buffer, "if (");
dump_generic_node (buffer, COND_EXPR_COND (node), spc, flags, false);
......@@ -1543,10 +1543,6 @@ print_struct_decl (pretty_printer *buffer, tree node, int spc, int flags)
print_declaration (buffer, tmp, spc+2, flags);
pp_newline (buffer);
}
else
{
}
tmp = TREE_CHAIN (tmp);
}
}
......
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