* cp-tree.h (LAMBDA_EXPR_CLOSURE): Use TREE_TYPE.
(LAMBDA_EXPR_RETURN_TYPE): Remove.
(struct tree_lambda_expr): Remove closure and return_type fields.
* lambda.c (build_lambda_expr): Don't set LAMBDA_EXPR_RETURN_TYPE.
* pt.c (tsubst_copy_and_build): Likewise.
* parser.c (cp_parser_lambda_declarator_opt): Track return type.
(cp_parser_lambda_body): Adjust unspecified return type check.
* ptree.c (cxx_print_lambda_node): Don't print closure or
return type.
From-SVN: r251430
-2017-08-28 Jason Merrill <jason@redhat.com>
+2017-08-29 Jason Merrill <jason@redhat.com>
+
+ * cp-tree.h (LAMBDA_EXPR_CLOSURE): Use TREE_TYPE.
+ (LAMBDA_EXPR_RETURN_TYPE): Remove.
+ (struct tree_lambda_expr): Remove closure and return_type fields.
+ * lambda.c (build_lambda_expr): Don't set LAMBDA_EXPR_RETURN_TYPE.
+ * pt.c (tsubst_copy_and_build): Likewise.
+ * parser.c (cp_parser_lambda_declarator_opt): Track return type.
+ (cp_parser_lambda_body): Adjust unspecified return type check.
+ * ptree.c (cxx_print_lambda_node): Don't print closure or
+ return type.
PR c++/80935 - wrong C++17 error with lambda
* decl.c (check_for_uninitialized_const_var): Check
is_instantiation_of_constexpr.
(potential_constant_expression_1): Check var_in_maybe_constexpr_fn.
-2017-08-23 Jason Merrill <jason@redhat.com>
-
* lambda.c (build_lambda_object): Check for error_mark_node.
* pt.c (make_pack_expansion): Set PACK_EXPANSION_LOCAL_P on the type
pack as well.
(tsubst_decl) [FUNCTION_DECL]: Set DECL_CONTEXT on the parameters.
(tsubst) [TEMPLATE_PARM_INDEX]: Check for error_mark_node.
-2017-08-29 Jason Merrill <jason@redhat.com>
-
PR c++/80767 - unnecessary instantiation of generic lambda
* call.c (convert_like_real): Call build_user_type_conversion_1 if
cand is null.
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.
#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)
#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;
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;
}
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);
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
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 ();
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)
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)
{
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 ();
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
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);