diff options
author | Jason Merrill <jason@redhat.com> | 2018-05-10 14:40:43 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2018-05-10 14:40:43 -0400 |
commit | 86cf10840b6cfbfe03399d10ca6deabb05eb4e40 (patch) | |
tree | 9cc87b92d390f3ac63dde3a298be136438cdd953 /gcc | |
parent | fa141e9b3c41bab7728cda7cd5a3f672e0193797 (diff) | |
download | gcc-86cf10840b6cfbfe03399d10ca6deabb05eb4e40.zip gcc-86cf10840b6cfbfe03399d10ca6deabb05eb4e40.tar.gz gcc-86cf10840b6cfbfe03399d10ca6deabb05eb4e40.tar.bz2 |
* lambda.c (lambda_expr_this_capture): Improve logic.
From-SVN: r260122
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 2 | ||||
-rw-r--r-- | gcc/cp/lambda.c | 20 |
2 files changed, 12 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e70d394..544806d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,7 @@ 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. diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index e9b962a..e3f22fc 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -743,9 +743,7 @@ lambda_expr_this_capture (tree lambda, bool add_capture_p) 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; @@ -756,9 +754,15 @@ lambda_expr_this_capture (tree lambda, bool add_capture_p) 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 @@ -807,10 +811,6 @@ lambda_expr_this_capture (tree lambda, bool add_capture_p) 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) |