diff options
author | Andrew Sutton <andrew.n.sutton@gmail.com> | 2015-09-17 18:26:06 +0000 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2015-09-17 14:26:06 -0400 |
commit | 378b307d0d7e789c69570cba4a9388b781c3f062 (patch) | |
tree | 6946be114431b50821732989faea2214c6fb345a /gcc/cp/cp-tree.def | |
parent | 750cdaf713adb0a6c873f729ec7ac48ec4cd25b8 (diff) | |
download | gcc-378b307d0d7e789c69570cba4a9388b781c3f062.zip gcc-378b307d0d7e789c69570cba4a9388b781c3f062.tar.gz gcc-378b307d0d7e789c69570cba4a9388b781c3f062.tar.bz2 |
Implement N4295 fold-expressions.
* cp-tree.def: Add UNARY_LEFT_FOLD_EXPR, UNARY_RIGHT_FOLD_EXPR,
BINARY_LEFT_FOLD_EXPR, BINARY_RIGHT_FOLD_EXPR.
* cp-objcp-common.c (cp_common_init_ts): Handle them.
* cp-tree.h (FOLD_EXPR_CHECK, BINARY_FOLD_EXPR_CHECK, FOLD_EXPR_P)
(FOLD_EXPR_MODIFY_P, FOLD_EXPR_OP, FOLD_EXPR_PACK, FOLD_EXPR_INIT): New.
* parser.c (cp_parser_skip_to_closing_parenthesis): Split out...
(cp_parser_skip_to_closing_parenthesis_1): This function. Change
or_comma parameter to or_ttype.
(cp_parser_fold_operator, cp_parser_fold_expr_p)
(cp_parser_fold_expression): New.
(cp_parser_primary_expression): Use them.
* pt.c (expand_empty_fold, fold_expression, tsubst_fold_expr_pack)
(tsubst_fold_expr_init, expand_left_fold, tsubst_unary_left_fold)
(tsubst_binary_left_fold, expand_right_fold)
(tsubst_unary_right_fold, tsubst_binary_right_fold): New.
(tsubst_copy): Use them.
(type_dependent_expression_p): Handle fold-expressions.
* semantics.c (finish_unary_fold_expr)
(finish_left_unary_fold_expr, finish_right_unary_fold_expr)
(finish_binary_fold_expr): New.
Co-Authored-By: Jason Merrill <jason@redhat.com>
From-SVN: r227883
Diffstat (limited to 'gcc/cp/cp-tree.def')
-rw-r--r-- | gcc/cp/cp-tree.def | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def index 61acf27..7df72c5 100644 --- a/gcc/cp/cp-tree.def +++ b/gcc/cp/cp-tree.def @@ -432,6 +432,26 @@ DEFTREECODE (EXPR_PACK_EXPANSION, "expr_pack_expansion", tcc_expression, 3) index is a machine integer. */ DEFTREECODE (ARGUMENT_PACK_SELECT, "argument_pack_select", tcc_exceptional, 0) +/* Fold expressions allow the expansion of a template argument pack + over a binary operator. + + FOLD_EXPR_MOD_P is true when the fold operation is a compound assignment + operator. + + FOLD_EXPR_OP is an INTEGER_CST storing the tree code for the folded + expression. Note that when FOLDEXPR_MOD_P is true, the operator is + a compound assignment operator for that kind of expression. + + FOLD_EXPR_PACK is an expression containing an unexpanded parameter pack; + when expanded, each term becomes an argument of the folded expression. + + In a BINARY_FOLD_EXPRESSION, FOLD_EXPR_INIT is the non-pack argument. */ +DEFTREECODE (UNARY_LEFT_FOLD_EXPR, "unary_left_fold_expr", tcc_expression, 2) +DEFTREECODE (UNARY_RIGHT_FOLD_EXPR, "unary_right_fold_expr", tcc_expression, 2) +DEFTREECODE (BINARY_LEFT_FOLD_EXPR, "binary_left_fold_expr", tcc_expression, 3) +DEFTREECODE (BINARY_RIGHT_FOLD_EXPR, "binary_right_fold_expr", tcc_expression, 3) + + /** C++ extensions. */ /* Represents a trait expression during template expansion. */ |