]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/cp/cp-tree.def
Implement N4295 fold-expressions.
authorAndrew Sutton <andrew.n.sutton@gmail.com>
Thu, 17 Sep 2015 18:26:06 +0000 (18:26 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 17 Sep 2015 18:26:06 +0000 (14:26 -0400)
commit378b307d0d7e789c69570cba4a9388b781c3f062
tree6946be114431b50821732989faea2214c6fb345a
parent750cdaf713adb0a6c873f729ec7ac48ec4cd25b8
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
12 files changed:
gcc/cp/ChangeLog
gcc/cp/cp-objcp-common.c
gcc/cp/cp-tree.def
gcc/cp/cp-tree.h
gcc/cp/parser.c
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/testsuite/g++.dg/cpp1z/fold1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1z/fold2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1z/fold3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1z/fold4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1z/fold5.C [new file with mode: 0644]