]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/60252 ([c++11] ICE with invalid variable-length array in lambda parameter)
authorJason Merrill <jason@redhat.com>
Fri, 21 Feb 2014 14:56:31 +0000 (09:56 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 21 Feb 2014 14:56:31 +0000 (09:56 -0500)
PR c++/60252
* lambda.c (maybe_resolve_dummy): Don't try to capture this
in declaration context.

From-SVN: r207999

gcc/cp/ChangeLog
gcc/cp/lambda.c
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice11.C [new file with mode: 0644]

index 8a2cb1630f1578173ae3842b5c4f18f8e62bdc3a..28ce7255a4620b7ea0574a8eb2f27eaa30755d10 100644 (file)
@@ -1,5 +1,9 @@
 2014-02-21  Jason Merrill  <jason@redhat.com>
 
+       PR c++/60252
+       * lambda.c (maybe_resolve_dummy): Don't try to capture this
+       in declaration context.
+
        DR 1591
        PR c++/60051
        * pt.c (unify): Only unify if deducible.  Handle 0-length list.
index ad993e9d39236f40e3691f8ffb10fc598229220d..7fe235b570247f4e8782b9de773be36acfa10fed 100644 (file)
@@ -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);
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice11.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice11.C
new file mode 100644 (file)
index 0000000..58f0fa3
--- /dev/null
@@ -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 "" }
+  }
+};