Commit a546927c by Jason Merrill Committed by Jason Merrill

re PR c++/63320 (bogus ‘this’ was not captured for this lambda function error)

	PR c++/63320
	PR c++/60463
	PR c++/60755
	* lambda.c (maybe_resolve_dummy, lambda_expr_this_capture): Handle
	not finding 'this'.

From-SVN: r215478
parent 05424ee6
2014-09-22 Jason Merrill <jason@redhat.com>
PR c++/63320
PR c++/60463
PR c++/60755
* lambda.c (maybe_resolve_dummy, lambda_expr_this_capture): Handle
not finding 'this'.
2014-09-22 Paolo Carlini <paolo.carlini@oracle.com> 2014-09-22 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/62219 PR c++/62219
......
...@@ -724,7 +724,8 @@ lambda_expr_this_capture (tree lambda, bool add_capture_p) ...@@ -724,7 +724,8 @@ lambda_expr_this_capture (tree lambda, bool add_capture_p)
if (!this_capture) if (!this_capture)
{ {
error ("%<this%> was not captured for this lambda function"); if (add_capture_p)
error ("%<this%> was not captured for this lambda function");
result = error_mark_node; result = error_mark_node;
} }
else else
...@@ -768,8 +769,9 @@ maybe_resolve_dummy (tree object, bool add_capture_p) ...@@ -768,8 +769,9 @@ maybe_resolve_dummy (tree object, bool add_capture_p)
/* In a lambda, need to go through 'this' capture. */ /* In a lambda, need to go through 'this' capture. */
tree lam = CLASSTYPE_LAMBDA_EXPR (current_class_type); tree lam = CLASSTYPE_LAMBDA_EXPR (current_class_type);
tree cap = lambda_expr_this_capture (lam, add_capture_p); tree cap = lambda_expr_this_capture (lam, add_capture_p);
object = build_x_indirect_ref (EXPR_LOCATION (object), cap, if (cap != error_mark_node)
RO_NULL, tf_warning_or_error); object = build_x_indirect_ref (EXPR_LOCATION (object), cap,
RO_NULL, tf_warning_or_error);
} }
return object; return object;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
class Klass class Klass
{ {
unsigned int local; unsigned int local; // { dg-error "non-static" }
public: public:
bool dostuff(); bool dostuff();
}; };
...@@ -11,7 +11,7 @@ public: ...@@ -11,7 +11,7 @@ public:
bool Klass::dostuff() bool Klass::dostuff()
{ {
auto f = []() -> bool { auto f = []() -> bool {
if (local & 1) { return true; } // { dg-error "not captured" } if (local & 1) { return true; } // { dg-error "not captured|this location" }
return false; return false;
}; };
} }
......
// PR c++/63320
// { dg-do compile { target c++11 } }
class A {
static void addWindow();
static void activateWindow(void *);
};
void A::addWindow() {
int* action {};
[action] { activateWindow(action); };
}
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