Commit 86cf1084 by Jason Merrill Committed by Jason Merrill

* lambda.c (lambda_expr_this_capture): Improve logic.

From-SVN: r260122
parent fa141e9b
2018-05-09 Jason Merrill <jason@redhat.com> 2018-05-09 Jason Merrill <jason@redhat.com>
* lambda.c (lambda_expr_this_capture): Improve logic.
* decl.c (make_typename_type): s/parameters/arguments/. * decl.c (make_typename_type): s/parameters/arguments/.
* parser.c (cp_parser_nested_name_specifier_opt): Likewise. * parser.c (cp_parser_nested_name_specifier_opt): Likewise.
* pt.c (make_pack_expansion): Correct error message. * pt.c (make_pack_expansion): Correct error message.
......
...@@ -743,9 +743,7 @@ lambda_expr_this_capture (tree lambda, bool add_capture_p) ...@@ -743,9 +743,7 @@ lambda_expr_this_capture (tree lambda, bool add_capture_p)
add_capture_p = false; add_capture_p = false;
/* Try to default capture 'this' if we can. */ /* Try to default capture 'this' if we can. */
if (!this_capture if (!this_capture)
&& (!add_capture_p
|| LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda) != CPLD_NONE))
{ {
tree lambda_stack = NULL_TREE; tree lambda_stack = NULL_TREE;
tree init = NULL_TREE; tree init = NULL_TREE;
...@@ -756,6 +754,12 @@ lambda_expr_this_capture (tree lambda, bool add_capture_p) ...@@ -756,6 +754,12 @@ lambda_expr_this_capture (tree lambda, bool add_capture_p)
3. a non-default capturing lambda function. */ 3. a non-default capturing lambda function. */
for (tree tlambda = lambda; ;) for (tree tlambda = lambda; ;)
{ {
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, lambda_stack = tree_cons (NULL_TREE,
tlambda, tlambda,
lambda_stack); lambda_stack);
...@@ -807,10 +811,6 @@ lambda_expr_this_capture (tree lambda, bool add_capture_p) ...@@ -807,10 +811,6 @@ lambda_expr_this_capture (tree lambda, bool add_capture_p)
init = LAMBDA_EXPR_THIS_CAPTURE (tlambda); init = LAMBDA_EXPR_THIS_CAPTURE (tlambda);
break; break;
} }
if (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (tlambda) == CPLD_NONE)
/* An outer lambda won't let us capture 'this'. */
break;
} }
if (init) if (init)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment