Commit 9e14e18f by Richard Henderson Committed by Richard Henderson

c-common.def (GOTO_STMT, LABEL_STMT): Remove.

        * c-common.def (GOTO_STMT, LABEL_STMT): Remove.
        * c-common.c (c_add_case_label): Use LABEL_EXPR.
        * c-common.h (GOTO_FAKE_P, LABEL_STMT_LABEL): Remove.
        (c_common_stmt_codes): Remove GOTO_STMT, LABEL_STMT.
        * c-dump.c (c_dump_tree): Likewise.
        * c-gimplify.c (c_gimplify_stmt): Likewise.
        * c-pretty-print.c (pp_c_statement): Likewise.
        * c-parse.in (stmt): Use GOTO_EXPR.
        (label): Use LABEL_EXPR.
        * c-semantics.c (build_stmt): Set TREE_TYPE to void.
        * tree-inline.c (copy_body_r): Don't build empty BLOCKs.
cp/
        * decl.c (finish_destructor_body): Use LABEL_EXPR.
        * parser.c (cp_parser_statement): Update commentary.
        * pt.c (tsubst_expr): Use LABEL_EXPR, GOTO_EXPR.
        * semantics.c (finish_goto_stmt, finish_label_stmt): Likewise.
        * tree.c (mark_local_for_remap_r): Likewise.

From-SVN: r83255
parent 2f52c531
2004-06-16 Richard Henderson <rth@redhat.com>
* c-common.def (GOTO_STMT, LABEL_STMT): Remove.
* c-common.c (c_add_case_label): Use LABEL_EXPR.
* c-common.h (GOTO_FAKE_P, LABEL_STMT_LABEL): Remove.
(c_common_stmt_codes): Remove GOTO_STMT, LABEL_STMT.
* c-dump.c (c_dump_tree): Likewise.
* c-gimplify.c (c_gimplify_stmt): Likewise.
* c-pretty-print.c (pp_c_statement): Likewise.
* c-parse.in (stmt): Use GOTO_EXPR.
(label): Use LABEL_EXPR.
* c-semantics.c (build_stmt): Set TREE_TYPE to void.
* tree-inline.c (copy_body_r): Don't build empty BLOCKs.
2004-06-16 J"orn Rennecke <joern.rennecke@superh.com> 2004-06-16 J"orn Rennecke <joern.rennecke@superh.com>
* cfgcleanup.c (try_simplify_condjump): Update test to make * cfgcleanup.c (try_simplify_condjump): Update test to make
......
...@@ -3900,13 +3900,13 @@ c_add_case_label (splay_tree cases, tree cond, tree low_value, ...@@ -3900,13 +3900,13 @@ c_add_case_label (splay_tree cases, tree cond, tree low_value,
return case_label; return case_label;
error_out: error_out:
/* Add a label so that the back-end doesn't think that the beginning o /* Add a label so that the back-end doesn't think that the beginning of
the switch is unreachable. Note that we do not add a case label, as the switch is unreachable. Note that we do not add a case label, as
that just leads to duplicates and thence to aborts later on. */ that just leads to duplicates and thence to aborts later on. */
if (!cases->root) if (!cases->root)
{ {
tree t = create_artificial_label (); tree t = create_artificial_label ();
add_stmt (build_stmt (LABEL_STMT, t)); add_stmt (build_stmt (LABEL_EXPR, t));
} }
return error_mark_node; return error_mark_node;
} }
......
...@@ -71,13 +71,6 @@ DEFTREECODE (CONTINUE_STMT, "continue_stmt", 'e', 0) ...@@ -71,13 +71,6 @@ DEFTREECODE (CONTINUE_STMT, "continue_stmt", 'e', 0)
SWITCH_COND, SWITCH_BODY and SWITCH_TYPE, respectively. */ SWITCH_COND, SWITCH_BODY and SWITCH_TYPE, respectively. */
DEFTREECODE (SWITCH_STMT, "switch_stmt", 'e', 3) DEFTREECODE (SWITCH_STMT, "switch_stmt", 'e', 3)
/* Used to represent a 'goto' statement. The operand is GOTO_DESTINATION. */
DEFTREECODE (GOTO_STMT, "goto_stmt", 'e', 1)
/* Used to represent a 'label' statement. The operand is a LABEL_DECL
and can be obtained through the macro LABEL_STMT_LABEL. */
DEFTREECODE (LABEL_STMT, "label_stmt", 'e', 1)
/* Used to represent an inline assembly statement. */ /* Used to represent an inline assembly statement. */
DEFTREECODE (ASM_STMT, "asm_stmt", 'e', 4) DEFTREECODE (ASM_STMT, "asm_stmt", 'e', 4)
......
...@@ -961,9 +961,6 @@ extern void finish_file (void); ...@@ -961,9 +961,6 @@ extern void finish_file (void);
#define SWITCH_TYPE(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 2) #define SWITCH_TYPE(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 2)
#define CASE_LABEL_DECL(NODE) TREE_OPERAND (CASE_LABEL_CHECK (NODE), 2) #define CASE_LABEL_DECL(NODE) TREE_OPERAND (CASE_LABEL_CHECK (NODE), 2)
/* True for goto created artificially by the compiler. */
#define GOTO_FAKE_P(NODE) (TREE_LANG_FLAG_0 (GOTO_STMT_CHECK (NODE)))
/* COMPOUND_STMT accessor. This gives access to the TREE_LIST of /* COMPOUND_STMT accessor. This gives access to the TREE_LIST of
statements associated with a compound statement. The result is the statements associated with a compound statement. The result is the
first statement in the list. Succeeding nodes can be accessed by first statement in the list. Succeeding nodes can be accessed by
...@@ -981,10 +978,6 @@ extern void finish_file (void); ...@@ -981,10 +978,6 @@ extern void finish_file (void);
#define STMT_EXPR_NO_SCOPE(NODE) \ #define STMT_EXPR_NO_SCOPE(NODE) \
TREE_LANG_FLAG_0 (STMT_EXPR_CHECK (NODE)) TREE_LANG_FLAG_0 (STMT_EXPR_CHECK (NODE))
/* LABEL_STMT accessor. This gives access to the label associated with
the given label statement. */
#define LABEL_STMT_LABEL(NODE) TREE_OPERAND (LABEL_STMT_CHECK (NODE), 0)
/* COMPOUND_LITERAL_EXPR accessors. */ /* COMPOUND_LITERAL_EXPR accessors. */
#define COMPOUND_LITERAL_EXPR_DECL_STMT(NODE) \ #define COMPOUND_LITERAL_EXPR_DECL_STMT(NODE) \
TREE_OPERAND (COMPOUND_LITERAL_EXPR_CHECK (NODE), 0) TREE_OPERAND (COMPOUND_LITERAL_EXPR_CHECK (NODE), 0)
...@@ -1016,8 +1009,7 @@ enum c_tree_code { ...@@ -1016,8 +1009,7 @@ enum c_tree_code {
DECL_STMT, IF_STMT, FOR_STMT, \ DECL_STMT, IF_STMT, FOR_STMT, \
WHILE_STMT, DO_STMT, RETURN_STMT, \ WHILE_STMT, DO_STMT, RETURN_STMT, \
BREAK_STMT, CONTINUE_STMT, \ BREAK_STMT, CONTINUE_STMT, \
SWITCH_STMT, GOTO_STMT, LABEL_STMT, \ SWITCH_STMT, ASM_STMT, CASE_LABEL
ASM_STMT, CASE_LABEL
/* TRUE if a code represents a statement. The front end init /* TRUE if a code represents a statement. The front end init
langhook should take care of initialization of this array. */ langhook should take care of initialization of this array. */
......
...@@ -129,12 +129,6 @@ c_dump_tree (void *dump_info, tree t) ...@@ -129,12 +129,6 @@ c_dump_tree (void *dump_info, tree t)
dump_next_stmt (di, t); dump_next_stmt (di, t);
break; break;
case GOTO_STMT:
dump_stmt (di, t);
dump_child ("dest", GOTO_DESTINATION (t));
dump_next_stmt (di, t);
break;
case IF_STMT: case IF_STMT:
dump_stmt (di, t); dump_stmt (di, t);
dump_child ("cond", IF_COND (t)); dump_child ("cond", IF_COND (t));
...@@ -143,12 +137,6 @@ c_dump_tree (void *dump_info, tree t) ...@@ -143,12 +137,6 @@ c_dump_tree (void *dump_info, tree t)
dump_next_stmt (di, t); dump_next_stmt (di, t);
break; break;
case LABEL_STMT:
dump_stmt (di, t);
dump_child ("labl", LABEL_STMT_LABEL (t));
dump_next_stmt (di, t);
break;
case RETURN_STMT: case RETURN_STMT:
dump_stmt (di, t); dump_stmt (di, t);
dump_child ("expr", RETURN_STMT_EXPR (t)); dump_child ("expr", RETURN_STMT_EXPR (t));
......
...@@ -264,16 +264,6 @@ c_gimplify_stmt (tree *stmt_p) ...@@ -264,16 +264,6 @@ c_gimplify_stmt (tree *stmt_p)
ret = gimplify_decl_stmt (&stmt); ret = gimplify_decl_stmt (&stmt);
break; break;
case LABEL_STMT:
stmt = build1 (LABEL_EXPR, void_type_node, LABEL_STMT_LABEL (stmt));
ret = GS_OK;
break;
case GOTO_STMT:
stmt = build1 (GOTO_EXPR, void_type_node, GOTO_DESTINATION (stmt));
ret = GS_OK;
break;
case CASE_LABEL: case CASE_LABEL:
{ {
tree label = create_artificial_label (); tree label = create_artificial_label ();
......
...@@ -2292,7 +2292,7 @@ stmt: ...@@ -2292,7 +2292,7 @@ stmt:
if (decl != 0) if (decl != 0)
{ {
TREE_USED (decl) = 1; TREE_USED (decl) = 1;
$$ = add_stmt (build_stmt (GOTO_STMT, decl)); $$ = add_stmt (build_stmt (GOTO_EXPR, decl));
} }
else else
$$ = NULL_TREE; $$ = NULL_TREE;
...@@ -2302,7 +2302,7 @@ stmt: ...@@ -2302,7 +2302,7 @@ stmt:
pedwarn ("ISO C forbids `goto *expr;'"); pedwarn ("ISO C forbids `goto *expr;'");
stmt_count++; stmt_count++;
$3 = convert (ptr_type_node, $3); $3 = convert (ptr_type_node, $3);
$$ = add_stmt (build_stmt (GOTO_STMT, $3)); } $$ = add_stmt (build_stmt (GOTO_EXPR, $3)); }
| ';' | ';'
{ $$ = NULL_TREE; } { $$ = NULL_TREE; }
@@ifobjc @@ifobjc
...@@ -2379,7 +2379,7 @@ label: CASE expr_no_commas ':' ...@@ -2379,7 +2379,7 @@ label: CASE expr_no_commas ':'
if (label) if (label)
{ {
decl_attributes (&label, $4, 0); decl_attributes (&label, $4, 0);
$$ = add_stmt (build_stmt (LABEL_STMT, label)); $$ = add_stmt (build_stmt (LABEL_EXPR, label));
} }
else else
$$ = NULL_TREE; $$ = NULL_TREE;
......
...@@ -1913,28 +1913,22 @@ pp_c_statement (c_pretty_printer *pp, tree stmt) ...@@ -1913,28 +1913,22 @@ pp_c_statement (c_pretty_printer *pp, tree stmt)
identifier : statement identifier : statement
case constant-expression : statement case constant-expression : statement
default : statement */ default : statement */
case LABEL_STMT:
case CASE_LABEL: case CASE_LABEL:
if (pp_needs_newline (pp)) if (pp_needs_newline (pp))
pp_newline_and_indent (pp, -3); pp_newline_and_indent (pp, -3);
else else
pp_indentation (pp) -= 3; pp_indentation (pp) -= 3;
if (code == LABEL_STMT) if (CASE_LOW (stmt) == NULL_TREE)
pp_c_tree_decl_identifier (pp, LABEL_STMT_LABEL (stmt)); pp_identifier (pp, "default");
else if (code == CASE_LABEL) else
{ {
if (CASE_LOW (stmt) == NULL_TREE) pp_c_identifier (pp, "case");
pp_identifier (pp, "default"); pp_c_whitespace (pp);
else pp_conditional_expression (pp, CASE_LOW (stmt));
if (CASE_HIGH (stmt))
{ {
pp_c_identifier (pp, "case"); pp_identifier (pp, "...");
pp_c_whitespace (pp); pp_conditional_expression (pp, CASE_HIGH (stmt));
pp_conditional_expression (pp, CASE_LOW (stmt));
if (CASE_HIGH (stmt))
{
pp_identifier (pp, "...");
pp_conditional_expression (pp, CASE_HIGH (stmt));
}
} }
} }
pp_colon (pp); pp_colon (pp);
...@@ -2098,14 +2092,11 @@ pp_c_statement (c_pretty_printer *pp, tree stmt) ...@@ -2098,14 +2092,11 @@ pp_c_statement (c_pretty_printer *pp, tree stmt)
break; break;
case RETURN_STMT: case RETURN_STMT:
case GOTO_STMT:
{ {
tree e = code == RETURN_STMT tree e = RETURN_STMT_EXPR (stmt);
? RETURN_STMT_EXPR (stmt)
: GOTO_DESTINATION (stmt);
if (pp_needs_newline (pp)) if (pp_needs_newline (pp))
pp_newline_and_indent (pp, 0); pp_newline_and_indent (pp, 0);
pp_c_identifier (pp, code == RETURN_STMT ? "return" : "goto"); pp_c_identifier (pp, "return");
pp_c_whitespace (pp); pp_c_whitespace (pp);
if (e) if (e)
{ {
......
...@@ -188,6 +188,7 @@ build_stmt (enum tree_code code, ...) ...@@ -188,6 +188,7 @@ build_stmt (enum tree_code code, ...)
va_start (p, code); va_start (p, code);
ret = make_node (code); ret = make_node (code);
TREE_TYPE (ret) = void_type_node;
length = TREE_CODE_LENGTH (code); length = TREE_CODE_LENGTH (code);
annotate_with_locus (ret, input_location); annotate_with_locus (ret, input_location);
......
2004-06-16 Richard Henderson <rth@redhat.com> 2004-06-16 Richard Henderson <rth@redhat.com>
* decl.c (finish_destructor_body): Use LABEL_EXPR.
* parser.c (cp_parser_statement): Update commentary.
* pt.c (tsubst_expr): Use LABEL_EXPR, GOTO_EXPR.
* semantics.c (finish_goto_stmt, finish_label_stmt): Likewise.
* tree.c (mark_local_for_remap_r): Likewise.
2004-06-16 Richard Henderson <rth@redhat.com>
PR c++/16012 PR c++/16012
* semantics.c (begin_for_stmt, begin_for_stmt): Do put the init * semantics.c (begin_for_stmt, begin_for_stmt): Do put the init
statement in FOR_INIT_STMT for templates. statement in FOR_INIT_STMT for templates.
......
...@@ -10569,7 +10569,7 @@ finish_destructor_body (void) ...@@ -10569,7 +10569,7 @@ finish_destructor_body (void)
/* Any return from a destructor will end up here; that way all base /* Any return from a destructor will end up here; that way all base
and member cleanups will be run when the function returns. */ and member cleanups will be run when the function returns. */
add_stmt (build_stmt (LABEL_STMT, dtor_label)); add_stmt (build_stmt (LABEL_EXPR, dtor_label));
/* In a virtual destructor, we must call delete. */ /* In a virtual destructor, we must call delete. */
if (DECL_VIRTUAL_P (current_function_decl)) if (DECL_VIRTUAL_P (current_function_decl))
......
...@@ -5721,7 +5721,7 @@ cp_parser_statement (cp_parser* parser, tree in_statement_expr) ...@@ -5721,7 +5721,7 @@ cp_parser_statement (cp_parser* parser, tree in_statement_expr)
case constant-expression ... constant-expression : statement case constant-expression ... constant-expression : statement
Returns the new CASE_LABEL, for a `case' or `default' label. For Returns the new CASE_LABEL, for a `case' or `default' label. For
an ordinary label, returns a LABEL_STMT. */ an ordinary label, returns a LABEL_EXPR. */
static tree static tree
cp_parser_labeled_statement (cp_parser* parser, tree in_statement_expr) cp_parser_labeled_statement (cp_parser* parser, tree in_statement_expr)
...@@ -6241,8 +6241,7 @@ cp_parser_for_init_statement (cp_parser* parser) ...@@ -6241,8 +6241,7 @@ cp_parser_for_init_statement (cp_parser* parser)
jump-statement: jump-statement:
goto * expression ; goto * expression ;
Returns the new BREAK_STMT, CONTINUE_STMT, RETURN_STMT, or Returns the new BREAK_STMT, CONTINUE_STMT, RETURN_STMT, or GOTO_EXPR. */
GOTO_STMT. */
static tree static tree
cp_parser_jump_statement (cp_parser* parser) cp_parser_jump_statement (cp_parser* parser)
......
...@@ -7979,12 +7979,12 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -7979,12 +7979,12 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
in_decl)); in_decl));
break; break;
case LABEL_STMT: case LABEL_EXPR:
prep_stmt (t); prep_stmt (t);
finish_label_stmt (DECL_NAME (LABEL_STMT_LABEL (t))); finish_label_stmt (DECL_NAME (LABEL_EXPR_LABEL (t)));
break; break;
case GOTO_STMT: case GOTO_EXPR:
prep_stmt (t); prep_stmt (t);
tmp = GOTO_DESTINATION (t); tmp = GOTO_DESTINATION (t);
if (TREE_CODE (tmp) != LABEL_DECL) if (TREE_CODE (tmp) != LABEL_DECL)
......
...@@ -435,7 +435,7 @@ finish_goto_stmt (tree destination) ...@@ -435,7 +435,7 @@ finish_goto_stmt (tree destination)
check_goto (destination); check_goto (destination);
return add_stmt (build_stmt (GOTO_STMT, destination)); return add_stmt (build_stmt (GOTO_EXPR, destination));
} }
/* COND is the condition-expression for an if, while, etc., /* COND is the condition-expression for an if, while, etc.,
...@@ -1086,7 +1086,7 @@ tree ...@@ -1086,7 +1086,7 @@ tree
finish_label_stmt (tree name) finish_label_stmt (tree name)
{ {
tree decl = define_label (input_location, name); tree decl = define_label (input_location, name);
return add_stmt (build_stmt (LABEL_STMT, decl)); return add_stmt (build_stmt (LABEL_EXPR, decl));
} }
/* Finish a series of declarations for local labels. G++ allows users /* Finish a series of declarations for local labels. G++ allows users
......
...@@ -2216,8 +2216,8 @@ mark_local_for_remap_r (tree* tp, ...@@ -2216,8 +2216,8 @@ mark_local_for_remap_r (tree* tp,
if (TREE_CODE (t) == DECL_STMT if (TREE_CODE (t) == DECL_STMT
&& nonstatic_local_decl_p (DECL_STMT_DECL (t))) && nonstatic_local_decl_p (DECL_STMT_DECL (t)))
decl = DECL_STMT_DECL (t); decl = DECL_STMT_DECL (t);
else if (TREE_CODE (t) == LABEL_STMT) else if (TREE_CODE (t) == LABEL_EXPR)
decl = LABEL_STMT_LABEL (t); decl = LABEL_EXPR_LABEL (t);
else if (TREE_CODE (t) == TARGET_EXPR else if (TREE_CODE (t) == TARGET_EXPR
&& nonstatic_local_decl_p (TREE_OPERAND (t, 0))) && nonstatic_local_decl_p (TREE_OPERAND (t, 0)))
decl = TREE_OPERAND (t, 0); decl = TREE_OPERAND (t, 0);
......
...@@ -467,8 +467,8 @@ copy_body_r (tree *tp, int *walk_subtrees, void *data) ...@@ -467,8 +467,8 @@ copy_body_r (tree *tp, int *walk_subtrees, void *data)
abort (); abort ();
#endif #endif
/* If this is a RETURN_STMT, change it into an EXPR_STMT and a /* If this is a RETURN_EXPR, change it into a MODIFY_EXPR and a
GOTO_STMT with the RET_LABEL as its target. */ GOTO_EXPR with the RET_LABEL as its target. */
if (TREE_CODE (*tp) == RETURN_EXPR && id->ret_label) if (TREE_CODE (*tp) == RETURN_EXPR && id->ret_label)
{ {
tree return_stmt = *tp; tree return_stmt = *tp;
...@@ -489,8 +489,7 @@ copy_body_r (tree *tp, int *walk_subtrees, void *data) ...@@ -489,8 +489,7 @@ copy_body_r (tree *tp, int *walk_subtrees, void *data)
if (TREE_CODE (assignment) == RESULT_DECL) if (TREE_CODE (assignment) == RESULT_DECL)
gimplify_stmt (&assignment); gimplify_stmt (&assignment);
*tp = build (BIND_EXPR, void_type_node, NULL_TREE, NULL_TREE, *tp = build (BIND_EXPR, void_type_node, NULL, NULL, NULL);
make_node (BLOCK));
append_to_statement_list (assignment, &BIND_EXPR_BODY (*tp)); append_to_statement_list (assignment, &BIND_EXPR_BODY (*tp));
append_to_statement_list (goto_stmt, &BIND_EXPR_BODY (*tp)); append_to_statement_list (goto_stmt, &BIND_EXPR_BODY (*tp));
} }
......
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