This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Remove CASE_LABEL
- From: Richard Henderson <rth at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 16 Jun 2004 13:52:40 -0700
- Subject: Remove CASE_LABEL
Replaced by the generic CASE_LABEL_EXPR.
r~
* c-common.def (CASE_LABEL): Remove.
* c-common.c (c_add_case_label): Use CASE_LABEL, not CASE_LABEL_DECL.
(match_case_to_enum_1): Likewise.
* c-common.h (c_common_stmt_codes): Remove CASE_LABEL.
* c-dump.c (c_dump_tree): Likewise.
* c-gimplify.c (c_gimplify_stmt): Likewise.
* c-pretty-print.c (pp_c_statement): Likewise.
* c-semantics.c (build_case_label): Use CASE_LABEL_EXPR.
* tree.h (CASE_LOW): Update commentary.
cp/
* parser.c (cp_parser_labeled_statement): Update commentary.
* pt.c (tsubst_expr): Use CASE_LABEL_EXPR.
* tree.c (mark_local_for_remap_r): Likewise.
Index: gcc/c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.513
diff -u -p -r1.513 c-common.c
--- gcc/c-common.c 16 Jun 2004 18:21:12 -0000 1.513
+++ gcc/c-common.c 16 Jun 2004 20:46:26 -0000
@@ -3770,8 +3770,8 @@ case_compare (splay_tree_key k1, splay_t
case label was declared using the usual C/C++ syntax, rather than
the GNU case range extension. CASES is a tree containing all the
case ranges processed so far; COND is the condition for the
- switch-statement itself. Returns the CASE_LABEL created, or
- ERROR_MARK_NODE if no CASE_LABEL is created. */
+ switch-statement itself. Returns the CASE_LABEL_EXPR created, or
+ ERROR_MARK_NODE if no CASE_LABEL_EXPR is created. */
tree
c_add_case_label (splay_tree cases, tree cond, tree low_value,
@@ -3870,7 +3870,7 @@ c_add_case_label (splay_tree cases, tree
/* If there was an overlap, issue an error. */
if (node)
{
- tree duplicate = CASE_LABEL_DECL ((tree) node->value);
+ tree duplicate = CASE_LABEL ((tree) node->value);
if (high_value)
{
@@ -3935,10 +3935,10 @@ match_case_to_enum_1 (tree key, tree typ
if (TYPE_NAME (type) == 0)
warning ("%Jcase value `%s' not in enumerated type",
- CASE_LABEL_DECL (label), buf);
+ CASE_LABEL (label), buf);
else
warning ("%Jcase value `%s' not in enumerated type `%T'",
- CASE_LABEL_DECL (label), buf, type);
+ CASE_LABEL (label), buf, type);
}
static int
Index: gcc/c-common.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.def,v
retrieving revision 1.18
diff -u -p -r1.18 c-common.def
--- gcc/c-common.def 16 Jun 2004 20:23:01 -0000 1.18
+++ gcc/c-common.def 16 Jun 2004 20:46:26 -0000
@@ -71,12 +71,6 @@ DEFTREECODE (CONTINUE_STMT, "continue_st
SWITCH_COND, SWITCH_BODY and SWITCH_TYPE, respectively. */
DEFTREECODE (SWITCH_STMT, "switch_stmt", 'e', 3)
-/* Used to represent a CASE_LABEL. The operands are CASE_LOW and
- CASE_HIGH, respectively. If CASE_LOW is NULL_TREE, the label is a
- 'default' label. If CASE_HIGH is NULL_TREE, the label is a normal case
- label. The CASE_LABEL_DECL is a LABEL_DECL for this node. */
-DEFTREECODE (CASE_LABEL, "case_label", 'e', 3)
-
/* A STMT_EXPR represents a statement-expression. The
STMT_EXPR_STMT is the statement given by the expression. */
DEFTREECODE (STMT_EXPR, "stmt_expr", 'e', 1)
Index: gcc/c-common.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.h,v
retrieving revision 1.233
diff -u -p -r1.233 c-common.h
--- gcc/c-common.h 16 Jun 2004 20:23:01 -0000 1.233
+++ gcc/c-common.h 16 Jun 2004 20:46:27 -0000
@@ -958,7 +958,6 @@ extern void finish_file (void);
#define FOR_BODY(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 3)
#define SWITCH_TYPE(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 2)
-#define CASE_LABEL_DECL(NODE) TREE_OPERAND (CASE_LABEL_CHECK (NODE), 2)
/* COMPOUND_STMT accessor. This gives access to the TREE_LIST of
statements associated with a compound statement. The result is the
@@ -1007,8 +1006,7 @@ enum c_tree_code {
CLEANUP_STMT, EXPR_STMT, COMPOUND_STMT, \
DECL_STMT, IF_STMT, FOR_STMT, \
WHILE_STMT, DO_STMT, RETURN_STMT, \
- BREAK_STMT, CONTINUE_STMT, \
- SWITCH_STMT, CASE_LABEL
+ BREAK_STMT, CONTINUE_STMT, SWITCH_STMT
/* TRUE if a code represents a statement. The front end init
langhook should take care of initialization of this array. */
Index: gcc/c-dump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-dump.c,v
retrieving revision 1.21
diff -u -p -r1.21 c-dump.c
--- gcc/c-dump.c 16 Jun 2004 20:23:01 -0000 1.21
+++ gcc/c-dump.c 16 Jun 2004 20:46:27 -0000
@@ -69,14 +69,6 @@ c_dump_tree (void *dump_info, tree t)
dump_next_stmt (di, t);
break;
- case CASE_LABEL:
- /* Note that a case label is not like other statements; there is
- no way to get the line-number of a case label. */
- dump_child ("low", CASE_LOW (t));
- dump_child ("high", CASE_HIGH (t));
- dump_next_stmt (di, t);
- break;
-
case CLEANUP_STMT:
dump_stmt (di, t);
dump_child ("decl", CLEANUP_DECL (t));
Index: gcc/c-gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-gimplify.c,v
retrieving revision 2.7
diff -u -p -r2.7 c-gimplify.c
--- gcc/c-gimplify.c 16 Jun 2004 20:23:01 -0000 2.7
+++ gcc/c-gimplify.c 16 Jun 2004 20:46:27 -0000
@@ -264,15 +264,6 @@ c_gimplify_stmt (tree *stmt_p)
ret = gimplify_decl_stmt (&stmt);
break;
- case CASE_LABEL:
- {
- tree label = create_artificial_label ();
- stmt = build (CASE_LABEL_EXPR, void_type_node,
- CASE_LOW (stmt), CASE_HIGH (stmt), label);
- ret = GS_OK;
- }
- break;
-
case CONTINUE_STMT:
stmt = build_bc_goto (bc_continue);
ret = GS_OK;
Index: gcc/c-pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-pretty-print.c,v
retrieving revision 1.45
diff -u -p -r1.45 c-pretty-print.c
--- gcc/c-pretty-print.c 16 Jun 2004 20:23:01 -0000 1.45
+++ gcc/c-pretty-print.c 16 Jun 2004 20:46:27 -0000
@@ -1909,33 +1909,6 @@ pp_c_statement (c_pretty_printer *pp, tr
}
break;
- /* labeled-statement:
- identifier : statement
- case constant-expression : statement
- default : statement */
- case CASE_LABEL:
- if (pp_needs_newline (pp))
- pp_newline_and_indent (pp, -3);
- else
- pp_indentation (pp) -= 3;
- if (CASE_LOW (stmt) == NULL_TREE)
- pp_identifier (pp, "default");
- else
- {
- pp_c_identifier (pp, "case");
- pp_c_whitespace (pp);
- 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_indentation (pp) += 3;
- pp_needs_newline (pp) = true;
- break;
-
/* compound-statement:
{ block-item-list(opt) }
Index: gcc/c-semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-semantics.c,v
retrieving revision 1.83
diff -u -p -r1.83 c-semantics.c
--- gcc/c-semantics.c 16 Jun 2004 18:21:12 -0000 1.83
+++ gcc/c-semantics.c 16 Jun 2004 20:46:27 -0000
@@ -297,12 +297,12 @@ build_continue_stmt (void)
return (build_stmt (CONTINUE_STMT));
}
-/* Create a CASE_LABEL tree node and return it. */
+/* Create a CASE_LABEL_EXPR tree node and return it. */
tree
build_case_label (tree low_value, tree high_value, tree label_decl)
{
- return build_stmt (CASE_LABEL, low_value, high_value, label_decl);
+ return build_stmt (CASE_LABEL_EXPR, low_value, high_value, label_decl);
}
/* We're about to expand T, a statement. Set up appropriate context
Index: gcc/tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.516
diff -u -p -r1.516 tree.h
--- gcc/tree.h 16 Jun 2004 20:23:01 -0000 1.516
+++ gcc/tree.h 16 Jun 2004 20:46:27 -0000
@@ -1066,7 +1066,7 @@ struct tree_vec GTY(())
#define SWITCH_BODY(NODE) TREE_OPERAND ((NODE), 1)
#define SWITCH_LABELS(NODE) TREE_OPERAND ((NODE), 2)
-/* CASE_LABEL accessors. These give access to the high and low values
+/* CASE_LABEL_EXPR accessors. These give access to the high and low values
of a case label, respectively. */
#define CASE_LOW(NODE) TREE_OPERAND ((NODE), 0)
#define CASE_HIGH(NODE) TREE_OPERAND ((NODE), 1)
Index: gcc/cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.209
diff -u -p -r1.209 parser.c
--- gcc/cp/parser.c 16 Jun 2004 20:23:02 -0000 1.209
+++ gcc/cp/parser.c 16 Jun 2004 20:46:29 -0000
@@ -5720,8 +5720,8 @@ cp_parser_statement (cp_parser* parser,
labeled-statement:
case constant-expression ... constant-expression : statement
- Returns the new CASE_LABEL, for a `case' or `default' label. For
- an ordinary label, returns a LABEL_EXPR. */
+ Returns the new CASE_LABEL_EXPR, for a `case' or `default' label.
+ For an ordinary label, returns a LABEL_EXPR. */
static tree
cp_parser_labeled_statement (cp_parser* parser, tree in_statement_expr)
Index: gcc/cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.865
diff -u -p -r1.865 pt.c
--- gcc/cp/pt.c 16 Jun 2004 20:23:02 -0000 1.865
+++ gcc/cp/pt.c 16 Jun 2004 20:46:30 -0000
@@ -7972,7 +7972,7 @@ tsubst_expr (tree t, tree args, tsubst_f
}
break;
- case CASE_LABEL:
+ case CASE_LABEL_EXPR:
prep_stmt (t);
finish_case_label (tsubst_expr (CASE_LOW (t), args, complain, in_decl),
tsubst_expr (CASE_HIGH (t), args, complain,
Index: gcc/cp/tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/tree.c,v
retrieving revision 1.377
diff -u -p -r1.377 tree.c
--- gcc/cp/tree.c 16 Jun 2004 18:21:20 -0000 1.377
+++ gcc/cp/tree.c 16 Jun 2004 20:46:31 -0000
@@ -2221,8 +2221,8 @@ mark_local_for_remap_r (tree* tp,
else if (TREE_CODE (t) == TARGET_EXPR
&& nonstatic_local_decl_p (TREE_OPERAND (t, 0)))
decl = TREE_OPERAND (t, 0);
- else if (TREE_CODE (t) == CASE_LABEL)
- decl = CASE_LABEL_DECL (t);
+ else if (TREE_CODE (t) == CASE_LABEL_EXPR)
+ decl = CASE_LABEL (t);
else
decl = NULL_TREE;