@@ -468,8 +468,7 @@ DEFTREECODE (TRAIT_EXPR, "trait_expr", tcc_exceptional, 0)
LAMBDA_EXPR_THIS_CAPTURE goes straight to the capture of `this', if it exists.
LAMBDA_EXPR_PENDING_PROXIES is a vector of capture proxies which need to
be pushed once scope returns to the lambda.
- LAMBDA_EXPR_MUTABLE_P signals whether this lambda was declared mutable.
- LAMBDA_EXPR_RETURN_TYPE holds the return type, if it was specified. */
+ LAMBDA_EXPR_MUTABLE_P signals whether this lambda was declared mutable. */
DEFTREECODE (LAMBDA_EXPR, "lambda_expr", tcc_exceptional, 0)
/* The declared type of an expression. This is a C++0x extension.
@@ -1253,11 +1253,6 @@ enum cp_lambda_default_capture_mode_type {
#define LAMBDA_EXPR_MUTABLE_P(NODE) \
TREE_LANG_FLAG_1 (LAMBDA_EXPR_CHECK (NODE))
-/* The return type in the expression.
- * NULL_TREE indicates that none was specified. */
-#define LAMBDA_EXPR_RETURN_TYPE(NODE) \
- (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->return_type)
-
/* The source location of the lambda. */
#define LAMBDA_EXPR_LOCATION(NODE) \
(((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->locus)
@@ -1276,20 +1271,17 @@ enum cp_lambda_default_capture_mode_type {
#define LAMBDA_EXPR_PENDING_PROXIES(NODE) \
(((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->pending_proxies)
-/* The closure type of the lambda. Note that the TREE_TYPE of a
- LAMBDA_EXPR is always NULL_TREE, because we need to instantiate the
- LAMBDA_EXPR in order to instantiate the type. */
+/* The closure type of the lambda, which is also the type of the
+ LAMBDA_EXPR. */
#define LAMBDA_EXPR_CLOSURE(NODE) \
- (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->closure)
+ (TREE_TYPE (LAMBDA_EXPR_CHECK (NODE)))
struct GTY (()) tree_lambda_expr
{
struct tree_typed typed;
tree capture_list;
tree this_capture;
- tree return_type;
tree extra_scope;
- tree closure;
vec<tree, va_gc> *pending_proxies;
location_t locus;
enum cp_lambda_default_capture_mode_type default_capture_mode;
@@ -42,7 +42,6 @@ build_lambda_expr (void)
LAMBDA_EXPR_CAPTURE_LIST (lambda) = NULL_TREE;
LAMBDA_EXPR_THIS_CAPTURE (lambda) = NULL_TREE;
LAMBDA_EXPR_PENDING_PROXIES (lambda) = NULL;
- LAMBDA_EXPR_RETURN_TYPE (lambda) = NULL_TREE;
LAMBDA_EXPR_MUTABLE_P (lambda) = false;
return lambda;
}
@@ -10419,6 +10419,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
tree exception_spec = NULL_TREE;
tree template_param_list = NULL_TREE;
tree tx_qual = NULL_TREE;
+ tree return_type = NULL_TREE;
cp_decl_specifier_seq lambda_specs;
clear_decl_specs (&lambda_specs);
@@ -10493,8 +10494,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
if (cp_lexer_next_token_is (parser->lexer, CPP_DEREF))
{
cp_lexer_consume_token (parser->lexer);
- LAMBDA_EXPR_RETURN_TYPE (lambda_expr)
- = cp_parser_trailing_type_id (parser);
+ return_type = cp_parser_trailing_type_id (parser);
}
/* The function parameters must be in scope all the way until after the
@@ -10517,8 +10517,8 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
void *p;
clear_decl_specs (&return_type_specs);
- if (LAMBDA_EXPR_RETURN_TYPE (lambda_expr))
- return_type_specs.type = LAMBDA_EXPR_RETURN_TYPE (lambda_expr);
+ if (return_type)
+ return_type_specs.type = return_type;
else
/* Maybe we will deduce the return type later. */
return_type_specs.type = make_auto ();
@@ -10558,7 +10558,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
DECL_ARTIFICIAL (fco) = 1;
/* Give the object parameter a different name. */
DECL_NAME (DECL_ARGUMENTS (fco)) = get_identifier ("__closure");
- if (LAMBDA_EXPR_RETURN_TYPE (lambda_expr))
+ if (return_type)
TYPE_HAS_LATE_RETURN_TYPE (TREE_TYPE (fco)) = 1;
}
if (template_param_list)
@@ -10648,7 +10648,7 @@ cp_parser_lambda_body (cp_parser* parser, tree lambda_expr)
nor a deducible form, errors should be reported for return statements
in the body. Since we used void as the placeholder return type, parsing
the body as usual will give such desired behavior. */
- if (!LAMBDA_EXPR_RETURN_TYPE (lambda_expr)
+ if (is_auto (TREE_TYPE (TREE_TYPE (fco)))
&& cp_lexer_peek_nth_token (parser->lexer, 1)->keyword == RID_RETURN
&& cp_lexer_peek_nth_token (parser->lexer, 2)->type != CPP_SEMICOLON)
{
@@ -17979,9 +17979,6 @@ tsubst_copy_and_build (tree t,
declaration of the op() for later calls to lambda_function. */
complete_type (type);
- if (tree fn = lambda_function (type))
- LAMBDA_EXPR_RETURN_TYPE (r) = TREE_TYPE (TREE_TYPE (fn));
-
LAMBDA_EXPR_THIS_CAPTURE (r) = NULL_TREE;
insert_pending_capture_proxies ();
@@ -204,8 +204,6 @@ cxx_print_lambda_node (FILE *file, tree node, int indent)
fprintf (file, "] ");
print_node (file, "capture_list", LAMBDA_EXPR_CAPTURE_LIST (node), indent + 4);
print_node (file, "this_capture", LAMBDA_EXPR_THIS_CAPTURE (node), indent + 4);
- print_node (file, "return_type", LAMBDA_EXPR_RETURN_TYPE (node), indent + 4);
- print_node (file, "closure", LAMBDA_EXPR_CLOSURE (node), indent + 4);
}
void
@@ -9304,12 +9304,6 @@ apply_deduced_return_type (tree fco, tree return_type)
if (return_type == error_mark_node)
return;
- if (LAMBDA_FUNCTION_P (fco))
- {
- tree lambda = CLASSTYPE_LAMBDA_EXPR (current_class_type);
- LAMBDA_EXPR_RETURN_TYPE (lambda) = return_type;
- }
-
if (DECL_CONV_FN_P (fco))
DECL_NAME (fco) = make_conv_op_name (return_type);