2018-05-09 Jason Merrill <jason@redhat.com>
+ * lambda.c (lambda_expr_this_capture): Improve logic.
+
* decl.c (make_typename_type): s/parameters/arguments/.
* parser.c (cp_parser_nested_name_specifier_opt): Likewise.
* pt.c (make_pack_expansion): Correct error message.
add_capture_p = false;
/* Try to default capture 'this' if we can. */
- if (!this_capture
- && (!add_capture_p
- || LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda) != CPLD_NONE))
+ if (!this_capture)
{
tree lambda_stack = NULL_TREE;
tree init = NULL_TREE;
3. a non-default capturing lambda function. */
for (tree tlambda = lambda; ;)
{
- lambda_stack = tree_cons (NULL_TREE,
- tlambda,
- lambda_stack);
+ if (add_capture_p
+ && LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (tlambda) == CPLD_NONE)
+ /* tlambda won't let us capture 'this'. */
+ break;
+
+ if (add_capture_p)
+ lambda_stack = tree_cons (NULL_TREE,
+ tlambda,
+ lambda_stack);
tree closure = LAMBDA_EXPR_CLOSURE (tlambda);
tree containing_function
init = LAMBDA_EXPR_THIS_CAPTURE (tlambda);
break;
}
-
- if (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (tlambda) == CPLD_NONE)
- /* An outer lambda won't let us capture 'this'. */
- break;
}
if (init)