From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27531 invoked by alias); 11 Mar 2011 04:30:44 -0000 Received: (qmail 27522 invoked by uid 22791); 11 Mar 2011 04:30:42 -0000 X-SWARE-Spam-Status: No, hits=-0.2 required=5.0 tests=AWL,BAYES_50,TW_BJ,TW_JC,TW_TM,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 11 Mar 2011 04:30:37 +0000 Received: (qmail 1685 invoked from network); 11 Mar 2011 04:23:54 -0000 Received: from unknown (HELO codesourcery.com) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 11 Mar 2011 04:23:54 -0000 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Cc: Nathan Froyd Subject: [PATCH 09/18] convert cp IF_STMTs to use private scope fields Date: Fri, 11 Mar 2011 04:30:00 -0000 Message-Id: <1299817406-16745-10-git-send-email-froydnj@codesourcery.com> In-Reply-To: <1299817406-16745-1-git-send-email-froydnj@codesourcery.com> References: <1299817406-16745-1-git-send-email-froydnj@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-03/txt/msg00562.txt.bz2 Just like the previous *FOR_STMT conversions, except with IF_STMTs. -Nathan gcc/cp/ * cp-tree.def (IF_STMT): Add an extra operand. * cp-objcp-common.c (cp_common_init_ts): Mark it as TS_TYPED. * cp-tree.h (IF_SCOPE): Define. * semantics.c (begin_if_stmt): Pass scope to build_stmt. (finish_if_stmt): Use IF_SCOPE instead of TREE_CHAIN. diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c index 21fa57f..d602dfe 100644 --- a/gcc/cp/cp-objcp-common.c +++ b/gcc/cp/cp-objcp-common.c @@ -236,7 +236,6 @@ cp_common_init_ts (void) MARK_TS_COMMON (TEMPLATE_INFO); MARK_TS_COMMON (TYPENAME_TYPE); MARK_TS_COMMON (TYPEOF_TYPE); - MARK_TS_COMMON (IF_STMT); MARK_TS_COMMON (BASELINK); MARK_TS_COMMON (SWITCH_STMT); MARK_TS_COMMON (TYPE_PACK_EXPANSION); @@ -245,6 +244,7 @@ cp_common_init_ts (void) MARK_TS_COMMON (BOUND_TEMPLATE_TEMPLATE_PARM); MARK_TS_COMMON (UNBOUND_CLASS_TEMPLATE); + MARK_TS_TYPED (IF_STMT); MARK_TS_TYPED (FOR_STMT); MARK_TS_TYPED (RANGE_FOR_STMT); MARK_TS_TYPED (AGGR_INIT_EXPR); diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def index fdfe9b5..59f89b8 100644 --- a/gcc/cp/cp-tree.def +++ b/gcc/cp/cp-tree.def @@ -284,10 +284,10 @@ DEFTREECODE (MUST_NOT_THROW_EXPR, "must_not_throw_expr", tcc_expression, 1) DEFTREECODE (CLEANUP_STMT, "cleanup_stmt", tcc_statement, 3) /* Represents an 'if' statement. The operands are IF_COND, - THEN_CLAUSE, and ELSE_CLAUSE, respectively. */ + THEN_CLAUSE, and ELSE_CLAUSE, and the current scope, respectively. */ /* ??? It is currently still necessary to distinguish between IF_STMT and COND_EXPR for the benefit of templates. */ -DEFTREECODE (IF_STMT, "if_stmt", tcc_statement, 3) +DEFTREECODE (IF_STMT, "if_stmt", tcc_statement, 4) /* Used to represent a `for' statement. The operands are FOR_INIT_STMT, FOR_COND, FOR_EXPR, and FOR_BODY, respectively. */ diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index e542388..2340812 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3781,6 +3781,7 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter) #define IF_COND(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 0) #define THEN_CLAUSE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 1) #define ELSE_CLAUSE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 2) +#define IF_SCOPE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 3) /* WHILE_STMT accessors. These give access to the condition of the while statement and the body of the while statement, respectively. */ diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index c8e5619..4071494 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -662,8 +662,8 @@ begin_if_stmt (void) { tree r, scope; scope = do_pushlevel (sk_block); - r = build_stmt (input_location, IF_STMT, NULL_TREE, NULL_TREE, NULL_TREE); - TREE_CHAIN (r) = scope; + r = build_stmt (input_location, IF_STMT, NULL_TREE, + NULL_TREE, NULL_TREE, scope); begin_cond (&IF_COND (r)); return r; } @@ -711,8 +711,8 @@ finish_else_clause (tree if_stmt) void finish_if_stmt (tree if_stmt) { - tree scope = TREE_CHAIN (if_stmt); - TREE_CHAIN (if_stmt) = NULL; + tree scope = IF_SCOPE (if_stmt); + IF_SCOPE (if_stmt) = NULL; add_stmt (do_poplevel (scope)); finish_stmt (); } -- 1.7.0.4