aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/lambda.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-02-22 01:47:37 -0500
committerJason Merrill <jason@gcc.gnu.org>2019-02-22 01:47:37 -0500
commit9adf74a36e569e555cfe41ba0304b0379e72f9c5 (patch)
tree1f4db50e7e402dae2891a15270c126465e2414d9 /gcc/cp/lambda.c
parentd36b4bf75260d7228025af59fd811e3fd48993c6 (diff)
downloadgcc-9adf74a36e569e555cfe41ba0304b0379e72f9c5.zip
gcc-9adf74a36e569e555cfe41ba0304b0379e72f9c5.tar.gz
gcc-9adf74a36e569e555cfe41ba0304b0379e72f9c5.tar.bz2
PR c++/87685 - generic lambda 'this' capture error.
The standard says that in a generic lambda we should speculatively capture 'this' if we see a call to an overload set that contains a non-static member function, but it seems wrong to reject the program if we can't capture, since it might not actually be needed. * lambda.c (lambda_expr_this_capture): Change add_capture_p to int. (maybe_generic_this_capture): Pass -1. From-SVN: r269095
Diffstat (limited to 'gcc/cp/lambda.c')
-rw-r--r--gcc/cp/lambda.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index 7032168..d178f15 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -730,10 +730,11 @@ add_default_capture (tree lambda_stack, tree id, tree initializer)
/* Return the capture pertaining to a use of 'this' in LAMBDA, in the
form of an INDIRECT_REF, possibly adding it through default
- capturing, if ADD_CAPTURE_P is true. */
+ capturing, if ADD_CAPTURE_P is nonzero. If ADD_CAPTURE_P is negative,
+ try to capture but don't complain if we can't. */
tree
-lambda_expr_this_capture (tree lambda, bool add_capture_p)
+lambda_expr_this_capture (tree lambda, int add_capture_p)
{
tree result;
@@ -829,7 +830,7 @@ lambda_expr_this_capture (tree lambda, bool add_capture_p)
result = this_capture;
else if (!this_capture)
{
- if (add_capture_p)
+ if (add_capture_p == 1)
{
error ("%<this%> was not captured for this lambda function");
result = error_mark_node;
@@ -934,7 +935,7 @@ maybe_generic_this_capture (tree object, tree fns)
&& DECL_NONSTATIC_MEMBER_FUNCTION_P (*iter))
{
/* Found a non-static member. Capture this. */
- lambda_expr_this_capture (lam, true);
+ lambda_expr_this_capture (lam, /*maybe*/-1);
break;
}
}