is_normal_capture_proxy got confused by the contortions we go through to
build up a capture proxy for a VLA capture, so it's easier to just check
for variably modified type.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 1fa864d218992c8a1b9b1fd4fae2205d5572205b
Author: Jason Merrill <ja...@redhat.com>
Date: Thu Feb 20 23:35:28 2014 -0500
PR c++/60251
* lambda.c (is_normal_capture_proxy): Handle VLA capture.
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index 8bb820d..ad993e9d 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -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
index 0000000..c9cdade
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/vla11.C
@@ -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" }
+}