From patchwork Fri Mar 11 04:23:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 86373 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id BFBBFB6FA4 for ; Fri, 11 Mar 2011 15:31:13 +1100 (EST) Received: (qmail 27924 invoked by alias); 11 Mar 2011 04:30:50 -0000 Received: (qmail 27789 invoked by uid 22791); 11 Mar 2011 04:30:48 -0000 X-SWARE-Spam-Status: No, hits=-0.3 required=5.0 tests=AWL, BAYES_50, TW_BJ, TW_JC, 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:42 +0000 Received: (qmail 1726 invoked from network); 11 Mar 2011 04:23:58 -0000 Received: from unknown (HELO codesourcery.com) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 11 Mar 2011 04:23:58 -0000 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Cc: Nathan Froyd Subject: [PATCH 11/18] mark EXPR_PACK_EXPANSION as typed only Date: Thu, 10 Mar 2011 23:23:19 -0500 Message-Id: <1299817406-16745-12-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-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org EXPR_PACK_EXPANSION nodes store things in TREE_CHAIN, for symmetry with TYPE_PACK_EXPANSIONs. In the interest of expendiency towards slimming tree_exp, this patch moves EXPR_PACK_EXPANSION's use of TREE_CHAIN into a local TREE_OPERAND. I suppose the conditional would be needed in any event later on... The odd case in mangle.c is needed to avoid mangling PACK_EXPANSION_PARAMETER_PACKS; doing so would lead to an ICE. -Nathan gcc/cp/ * cp-tree.def (EXPR_PACK_EXPANSION): Add an operand. * cp-objcp-common.c (cp_common_init_ts): Mark it as TS_TYPED. * cp-tree.h (PACK_EXPANSION_PARAMETER_PACKS): Use the new operand of EXPR_PACK_EXPANSION. * mangle.c (write_expression): Don't mangle all of EXPR_PACK_EXPANSION. diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c index 57358b1..90a4a9b 100644 --- a/gcc/cp/cp-objcp-common.c +++ b/gcc/cp/cp-objcp-common.c @@ -238,11 +238,11 @@ cp_common_init_ts (void) MARK_TS_COMMON (TYPEOF_TYPE); MARK_TS_COMMON (BASELINK); 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 (EXPR_PACK_EXPANSION); MARK_TS_TYPED (SWITCH_STMT); MARK_TS_TYPED (IF_STMT); MARK_TS_TYPED (FOR_STMT); diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def index 42840a8..366013a 100644 --- a/gcc/cp/cp-tree.def +++ b/gcc/cp/cp-tree.def @@ -413,7 +413,7 @@ DEFTREECODE (TYPE_PACK_EXPANSION, "type_pack_expansion", tcc_type, 0) EXPR_PACK_EXPANSION plays precisely the same role as TYPE_PACK_EXPANSION, but will be used for expressions. */ -DEFTREECODE (EXPR_PACK_EXPANSION, "expr_pack_expansion", tcc_expression, 1) +DEFTREECODE (EXPR_PACK_EXPANSION, "expr_pack_expansion", tcc_expression, 2) /* Selects the Ith parameter out of an argument pack. This node will be used when instantiating pack expansions; see diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 3249ef0..7bdf9e0 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2713,7 +2713,10 @@ extern void decl_shadowed_for_var_insert (tree, tree); /* The list of parameter packs used in the PACK_EXPANSION_* node. The TREE_VALUE of each TREE_LIST contains the parameter packs. */ -#define PACK_EXPANSION_PARAMETER_PACKS(NODE) TREE_CHAIN (NODE) +#define PACK_EXPANSION_PARAMETER_PACKS(NODE) \ + *(TREE_CODE (NODE) == EXPR_PACK_EXPANSION \ + ? &TREE_OPERAND (NODE, 1) \ + : &TREE_CHAIN (TYPE_PACK_EXPANSION_CHECK (NODE))) /* Determine if this is an argument pack. */ #define ARGUMENT_PACK_P(NODE) \ diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 4d2ace6..e4d53c5 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -2653,6 +2653,10 @@ write_expression (tree expr) len = 2; break; + case EXPR_PACK_EXPANSION: + len = 1; + break; + default: len = TREE_OPERAND_LENGTH (expr); break;