@@ -241,11 +241,11 @@ cp_common_init_ts (void)
MARK_TS_COMMON (UNDERLYING_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);
@@ -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
@@ -2734,7 +2734,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) \
@@ -5430,6 +5433,7 @@ extern tree nonlambda_method_basetype (void);
extern void maybe_add_lambda_conv_op (tree);
/* in tree.c */
+extern int cp_tree_operand_length (const_tree);
void cp_free_lang_data (tree t);
extern tree force_target_expr (tree, tree, tsubst_flags_t);
extern tree build_target_expr_with_type (tree, tree, tsubst_flags_t);
@@ -2701,23 +2701,7 @@ write_expression (tree expr)
default:
/* In the middle-end, some expressions have more operands than
they do in templates (and mangling). */
- switch (code)
- {
- case PREINCREMENT_EXPR:
- case PREDECREMENT_EXPR:
- case POSTINCREMENT_EXPR:
- case POSTDECREMENT_EXPR:
- len = 1;
- break;
-
- case ARRAY_REF:
- len = 2;
- break;
-
- default:
- len = TREE_OPERAND_LENGTH (expr);
- break;
- }
+ len = cp_tree_operand_length (expr);
for (i = 0; i < len; ++i)
{
@@ -18279,35 +18279,31 @@ value_dependent_expression_p (tree expression)
{
case tcc_reference:
case tcc_unary:
- return (value_dependent_expression_p
- (TREE_OPERAND (expression, 0)));
-
case tcc_comparison:
case tcc_binary:
- return ((value_dependent_expression_p
- (TREE_OPERAND (expression, 0)))
- || (value_dependent_expression_p
- (TREE_OPERAND (expression, 1))));
-
case tcc_expression:
case tcc_vl_exp:
{
- int i;
- for (i = 0; i < TREE_OPERAND_LENGTH (expression); ++i)
- /* In some cases, some of the operands may be missing.
- (For example, in the case of PREDECREMENT_EXPR, the
- amount to increment by may be missing.) That doesn't
- make the expression dependent. */
- if (TREE_OPERAND (expression, i)
- && (value_dependent_expression_p
- (TREE_OPERAND (expression, i))))
- return true;
- return false;
- }
+ int i, len = cp_tree_operand_length (expression);
+ for (i = 0; i < len; i++)
+ {
+ tree t = TREE_OPERAND (expression, i);
+
+ /* In some cases, some of the operands may be missing.l
+ (For example, in the case of PREDECREMENT_EXPR, the
+ amount to increment by may be missing.) That doesn't
+ make the expression dependent. */
+ if (t && value_dependent_expression_p (t))
+ return true;
+ }
+ }
+ break;
default:
break;
}
+ break;
}
/* The expression is not value-dependent. */
@@ -2342,7 +2342,7 @@ cp_tree_equal (tree t1, tree t2)
{
int i, n;
- n = TREE_OPERAND_LENGTH (t1);
+ n = cp_tree_operand_length (t1);
if (TREE_CODE_CLASS (code1) == tcc_vl_exp
&& n != TREE_OPERAND_LENGTH (t2))
return false;
@@ -3408,6 +3408,33 @@ c_register_addr_space (const char *word ATTRIBUTE_UNUSED,
{
}
+/* Return the number of operands in T that we care about for things like
+ mangling. */
+
+int
+cp_tree_operand_length (const_tree t)
+{
+ enum tree_code code = TREE_CODE (t);
+
+ switch (code)
+ {
+ case PREINCREMENT_EXPR:
+ case PREDECREMENT_EXPR:
+ case POSTINCREMENT_EXPR:
+ case POSTDECREMENT_EXPR:
+ return 1;
+
+ case ARRAY_REF:
+ return 2;
+
+ case EXPR_PACK_EXPANSION:
+ return 1;
+
+ default:
+ return TREE_OPERAND_LENGTH (t);
+ }
+}
+
#if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
/* Complain that some language-specific thing hanging off a tree