+2011-05-10 Nathan Froyd <froydnj@codesourcery.com>
+
+ * 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.
+ (cp_tree_operand_length): Declare.
+ * tree.c (cp_tree_operand_length): Define.
+ (cp_tree_equal): Call it.
+ * pt.c (value_dependent_expr_P): Likewise.
+ * mangle.c (write_expression): Likewise.
+
2011-05-09 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/48737
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);
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
/* 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) \
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);
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)
{
{
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. */
{
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;
{
}
+/* 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);
+ }
+}
\f
#if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
/* Complain that some language-specific thing hanging off a tree