diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-09-17 18:26:06 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-09-17 18:26:06 +0000 |
commit | a4c3da45a877599791191334536d1a1f155f50e1 (patch) | |
tree | 6946be114431b50821732989faea2214c6fb345a /gcc/cp/cp-tree.h | |
parent | d93fbda6e21e83a9a010c47a1f0959cfe3a8c1aa (diff) | |
download | gcc-a4c3da45a877599791191334536d1a1f155f50e1.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227883 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/cp-tree.h')
-rw-r--r-- | gcc/cp/cp-tree.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 8643e089d03..80d6c4e4a2f 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -80,6 +80,7 @@ c-common.h, not after. COMPOUND_REQ_NOEXCEPT_P (in COMPOUND_REQ) WILDCARD_PACK_P (in WILDCARD_DECL) BLOCK_OUTER_CURLY_BRACE_P (in BLOCK) + FOLD_EXPR_MODOP_P (*_FOLD_EXPR) 1: IDENTIFIER_VIRTUAL_P (in IDENTIFIER_NODE) TI_PENDING_TEMPLATE_FLAG. TEMPLATE_PARMS_FOR_INLINE. @@ -3249,6 +3250,37 @@ extern void decl_shadowed_for_var_insert (tree, tree); TREE_VEC_ELT (ARGUMENT_PACK_ARGS (ARGUMENT_PACK_SELECT_FROM_PACK (NODE)), \ ARGUMENT_PACK_SELECT_INDEX (NODE)) +#define FOLD_EXPR_CHECK(NODE) \ + TREE_CHECK4 (NODE, UNARY_LEFT_FOLD_EXPR, UNARY_RIGHT_FOLD_EXPR, \ + BINARY_LEFT_FOLD_EXPR, BINARY_RIGHT_FOLD_EXPR) + +#define BINARY_FOLD_EXPR_CHECK(NODE) \ + TREE_CHECK2 (NODE, BINARY_LEFT_FOLD_EXPR, BINARY_RIGHT_FOLD_EXPR) + +/* True if NODE is UNARY_FOLD_EXPR or a BINARY_FOLD_EXPR */ +#define FOLD_EXPR_P(NODE) \ + TREE_CODE (NODE) == UNARY_LEFT_FOLD_EXPR \ + || TREE_CODE (NODE) == UNARY_RIGHT_FOLD_EXPR \ + || TREE_CODE (NODE) == BINARY_LEFT_FOLD_EXPR \ + || TREE_CODE (NODE) == BINARY_RIGHT_FOLD_EXPR + +/* True when NODE is a fold over a compound assignment operator. */ +#define FOLD_EXPR_MODIFY_P(NODE) \ + TREE_LANG_FLAG_0 (FOLD_EXPR_CHECK (NODE)) + +/* An INTEGER_CST containing the tree code of the folded operator. */ +#define FOLD_EXPR_OP(NODE) \ + TREE_OPERAND (FOLD_EXPR_CHECK (NODE), 0) + +/* The expression containing an unexpanded parameter pack. */ +#define FOLD_EXPR_PACK(NODE) \ + TREE_OPERAND (FOLD_EXPR_CHECK (NODE), 1) + +/* In a binary fold expression, the argument with no unexpanded + parameter packs. */ +#define FOLD_EXPR_INIT(NODE) \ + TREE_OPERAND (BINARY_FOLD_EXPR_CHECK (NODE), 2) + /* In a FUNCTION_DECL, the saved language-specific per-function data. */ #define DECL_SAVED_FUNCTION_DATA(NODE) \ (LANG_DECL_FN_CHECK (FUNCTION_DECL_CHECK (NODE)) \ @@ -6567,6 +6599,10 @@ extern bool check_literal_operator_args (const_tree, bool *, bool *); extern void maybe_warn_about_useless_cast (tree, tree, tsubst_flags_t); extern tree cp_perform_integral_promotions (tree, tsubst_flags_t); +extern tree finish_left_unary_fold_expr (tree, int); +extern tree finish_right_unary_fold_expr (tree, int); +extern tree finish_binary_fold_expr (tree, tree, int); + /* in typeck2.c */ extern void require_complete_eh_spec_types (tree, tree); extern void cxx_incomplete_type_diagnostic (const_tree, const_tree, diagnostic_t); |