This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 11/18] mark EXPR_PACK_EXPANSION as typed only
- From: Nathan Froyd <froydnj at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Nathan Froyd <froydnj at codesourcery dot com>
- Date: Thu, 10 Mar 2011 23:23:19 -0500
- Subject: [PATCH 11/18] mark EXPR_PACK_EXPANSION as typed only
- References: <1299817406-16745-1-git-send-email-froydnj@codesourcery.com>
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;