commit 415022d49d1cee84b6d2085e7585e1d801d15732
Author: Jason Merrill <jason@redhat.com>
Date: Fri Feb 21 00:35:35 2014 -0500
PR c++/60252
* lambda.c (maybe_resolve_dummy): Don't try to capture this
in declaration context.
@@ -749,7 +749,10 @@ maybe_resolve_dummy (tree object)
if (type != current_class_type
&& current_class_type
&& LAMBDA_TYPE_P (current_class_type)
- && DERIVED_FROM_P (type, current_nonlambda_class_type ()))
+ && DERIVED_FROM_P (type, current_nonlambda_class_type ())
+ /* If we get here while parsing the parameter list of a lambda, it
+ will fail, so don't even try (c++/60252). */
+ && current_binding_level->kind != sk_function_parms)
{
/* In a lambda, need to go through 'this' capture. */
tree lam = CLASSTYPE_LAMBDA_EXPR (current_class_type);
new file mode 100644
@@ -0,0 +1,12 @@
+// PR c++/60252
+// { dg-require-effective-target c++11 }
+
+struct A
+{
+ int i; // { dg-message "" }
+
+ void foo()
+ {
+ [&](){ [&](int[i]){}; }; // { dg-error "" }
+ }
+};