aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/parser.cc')
-rw-r--r--gcc/cp/parser.cc35
1 files changed, 24 insertions, 11 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 53e6237..812a7c5 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -11736,21 +11736,34 @@ cp_parser_lambda_expression (cp_parser* parser)
if (cp_parser_error_occurred (parser))
return error_mark_node;
- type = begin_lambda_type (lambda_expr);
- if (type == error_mark_node)
- return error_mark_node;
+ {
+ /* OK, this is a bit tricksy. cp_parser_requires_expression sets
+ processing_template_decl to make checking more normal, but that confuses
+ lambda parsing terribly. In non-template context, we want to parse the
+ lambda once and not tsubst_lambda_expr. So in that case, clear
+ processing_template_decl now, and restore it before the call to
+ build_lambda_object; that way we end up with what looks like a templatey
+ functional cast to the closure type, which is suitable for the
+ requires-expression tsubst_expr. This is PR99546 and friends. */
+ processing_template_decl_sentinel ptds (/*reset*/false);
+ if (processing_template_decl && !in_template_context
+ && current_binding_level->requires_expression)
+ processing_template_decl = 0;
+
+ type = begin_lambda_type (lambda_expr);
+ if (type == error_mark_node)
+ return error_mark_node;
- record_lambda_scope (lambda_expr);
- record_lambda_scope_discriminator (lambda_expr);
+ record_lambda_scope (lambda_expr);
+ record_lambda_scope_discriminator (lambda_expr);
- /* Do this again now that LAMBDA_EXPR_EXTRA_SCOPE is set. */
- determine_visibility (TYPE_NAME (type));
+ /* Do this again now that LAMBDA_EXPR_EXTRA_SCOPE is set. */
+ determine_visibility (TYPE_NAME (type));
- /* Now that we've started the type, add the capture fields for any
- explicit captures. */
- register_capture_members (LAMBDA_EXPR_CAPTURE_LIST (lambda_expr));
+ /* Now that we've started the type, add the capture fields for any
+ explicit captures. */
+ register_capture_members (LAMBDA_EXPR_CAPTURE_LIST (lambda_expr));
- {
/* Inside the class, surrounding template-parameter-lists do not apply. */
unsigned int saved_num_template_parameter_lists
= parser->num_template_parameter_lists;