re PR c++/60251 ([c++11] ICE capturing variable-length array)
authorJason Merrill <jason@redhat.com>
Fri, 21 Feb 2014 14:01:20 +0000 (09:01 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 21 Feb 2014 14:01:20 +0000 (09:01 -0500)
PR c++/60251
* lambda.c (is_normal_capture_proxy): Handle VLA capture.

From-SVN: r207995

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

index be248e1f400a368812a2eaa2b7ef2c1c1ab6beff..e17576895ed38b6fde7fba6af55ebb7ad8fc6084 100644 (file)
@@ -1,5 +1,8 @@
 2014-02-21  Jason Merrill  <jason@redhat.com>
 
+       PR c++/60251
+       * lambda.c (is_normal_capture_proxy): Handle VLA capture.
+
        PR c++/60167
        PR c++/60222
        PR c++/58606
index 8bb820d0c3b0367dca12b2751d911ba39f3810ff..ad993e9d39236f40e3691f8ffb10fc598229220d 100644 (file)
@@ -250,6 +250,10 @@ is_normal_capture_proxy (tree decl)
     /* It's not a capture proxy.  */
     return false;
 
+  if (variably_modified_type_p (TREE_TYPE (decl), NULL_TREE))
+    /* VLA capture.  */
+    return true;
+
   /* It is a capture proxy, is it a normal capture?  */
   tree val = DECL_VALUE_EXPR (decl);
   if (val == error_mark_node)
diff --git a/gcc/testsuite/g++.dg/cpp1y/vla11.C b/gcc/testsuite/g++.dg/cpp1y/vla11.C
new file mode 100644 (file)
index 0000000..c9cdade
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/60251
+// { dg-options "-std=c++1y -pedantic-errors" }
+
+void foo(int n)
+{
+  int x[n];
+  [&x]() { decltype(x) y; }; // { dg-error "decltype of array of runtime bound" }
+}