diff mbox

[10/18] convert cp SWITCH_STMTs to use private scope fields

Message ID 1299817406-16745-11-git-send-email-froydnj@codesourcery.com
State New
Headers show

Commit Message

Nathan Froyd March 11, 2011, 4:23 a.m. UTC
Just like the previous patches, except with SWITCH_STMT.

-Nathan

gcc/cp/
	* 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.
diff mbox

Patch

diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index d602dfe..57358b1 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -237,13 +237,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 59f89b8..42840a8 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 2340812..3249ef0 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3812,6 +3812,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 4071494..689ad00 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));
 }