From 1f18dbc6a6de7752b6569228c3076715e60c9fc7 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Thu, 14 Apr 2011 18:42:44 +0000 Subject: [PATCH] cp-tree.def (SWITCH_STMT): Add an extra operand. * cp-tree.def (SWITCH_STMT): Add an extra operand. * cp-objcp-common.c (cp_common_init_ts): Mark it as TS_TYPED. * cp-tree.h (SWITCH_STMT_SCOPE): Define. * semantics.c (begin_switch__stmt): Pass scope to build_stmt. (finish_switch_stmt): Use SWITCH_STMT_SCOPE instead of TREE_CHAIN. From-SVN: r172440 --- gcc/cp/ChangeLog | 8 ++++++++ gcc/cp/cp-objcp-common.c | 2 +- gcc/cp/cp-tree.def | 5 +++-- gcc/cp/cp-tree.h | 1 + gcc/cp/semantics.c | 9 ++++----- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6226030f513..86ee781d126 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2011-04-14 Nathan Froyd + + * cp-tree.def (SWITCH_STMT): Add an extra operand. + * cp-objcp-common.c (cp_common_init_ts): Mark it as TS_TYPED. + * cp-tree.h (SWITCH_STMT_SCOPE): Define. + * semantics.c (begin_switch__stmt): Pass scope to build_stmt. + (finish_switch_stmt): Use SWITCH_STMT_SCOPE instead of TREE_CHAIN. + 2011-04-14 Nathan Froyd * cp-tree.def (IF_STMT): Add an extra operand. diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c index 6aa24053f26..6421f6f2656 100644 --- a/gcc/cp/cp-objcp-common.c +++ b/gcc/cp/cp-objcp-common.c @@ -239,13 +239,13 @@ cp_common_init_ts (void) MARK_TS_COMMON (TYPENAME_TYPE); MARK_TS_COMMON (TYPEOF_TYPE); MARK_TS_COMMON (BASELINK); - MARK_TS_COMMON (SWITCH_STMT); MARK_TS_COMMON (TYPE_PACK_EXPANSION); MARK_TS_COMMON (EXPR_PACK_EXPANSION); MARK_TS_COMMON (DECLTYPE_TYPE); MARK_TS_COMMON (BOUND_TEMPLATE_TEMPLATE_PARM); MARK_TS_COMMON (UNBOUND_CLASS_TEMPLATE); + MARK_TS_TYPED (SWITCH_STMT); MARK_TS_TYPED (IF_STMT); MARK_TS_TYPED (FOR_STMT); MARK_TS_TYPED (RANGE_FOR_STMT); diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def index 59f89b8630a..42840a81c10 100644 --- a/gcc/cp/cp-tree.def +++ b/gcc/cp/cp-tree.def @@ -313,8 +313,9 @@ DEFTREECODE (BREAK_STMT, "break_stmt", tcc_statement, 0) DEFTREECODE (CONTINUE_STMT, "continue_stmt", tcc_statement, 0) /* Used to represent a 'switch' statement. The operands are - SWITCH_STMT_COND, SWITCH_STMT_BODY and SWITCH_STMT_TYPE, respectively. */ -DEFTREECODE (SWITCH_STMT, "switch_stmt", tcc_statement, 3) + SWITCH_STMT_COND, SWITCH_STMT_BODY, SWITCH_STMT_TYPE, and + SWITCH_STMT_SCOPE, respectively. */ +DEFTREECODE (SWITCH_STMT, "switch_stmt", tcc_statement, 4) /* Used to represent an expression statement. Use `EXPR_STMT_EXPR' to obtain the expression. */ diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 076754c2a8e..e5388259ae6 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3823,6 +3823,7 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter) #define SWITCH_STMT_COND(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 0) #define SWITCH_STMT_BODY(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 1) #define SWITCH_STMT_TYPE(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 2) +#define SWITCH_STMT_SCOPE(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 3) /* STMT_EXPR accessor. */ #define STMT_EXPR_STMT(NODE) TREE_OPERAND (STMT_EXPR_CHECK (NODE), 0) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 6e717331ad7..b7171ed324b 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1018,10 +1018,9 @@ begin_switch_stmt (void) { tree r, scope; - r = build_stmt (input_location, SWITCH_STMT, NULL_TREE, NULL_TREE, NULL_TREE); - scope = do_pushlevel (sk_block); - TREE_CHAIN (r) = scope; + r = build_stmt (input_location, SWITCH_STMT, NULL_TREE, NULL_TREE, NULL_TREE, scope); + begin_cond (&SWITCH_STMT_COND (r)); return r; @@ -1077,8 +1076,8 @@ finish_switch_stmt (tree switch_stmt) pop_switch (); finish_stmt (); - scope = TREE_CHAIN (switch_stmt); - TREE_CHAIN (switch_stmt) = NULL; + scope = SWITCH_STMT_SCOPE (switch_stmt); + SWITCH_STMT_SCOPE (switch_stmt) = NULL; add_stmt (do_poplevel (scope)); } -- 2.30.2