aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/lambda.c4
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/lambda-generic-vla1.C24
3 files changed, 29 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c921f203..242342b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2013-12-23 Jason Merrill <jason@redhat.com>
+ PR c++/59271
+ * lambda.c (build_capture_proxy): Use build_cplus_array_type.
+
PR c++/59349
* parser.c (cp_parser_lambda_introducer): Handle empty init.
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index 24aa2c5..bd8df1d 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -377,8 +377,8 @@ build_capture_proxy (tree member)
tree ptr = build_simple_component_ref (object, field);
field = next_initializable_field (DECL_CHAIN (field));
tree max = build_simple_component_ref (object, field);
- type = build_array_type (TREE_TYPE (TREE_TYPE (ptr)),
- build_index_type (max));
+ type = build_cplus_array_type (TREE_TYPE (TREE_TYPE (ptr)),
+ build_index_type (max));
type = build_reference_type (type);
REFERENCE_VLA_OK (type) = true;
object = convert (type, ptr);
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-vla1.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-vla1.C
new file mode 100644
index 0000000..556722c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-vla1.C
@@ -0,0 +1,24 @@
+// PR c++/59271
+// { dg-options -std=c++1y }
+
+extern "C" int printf (const char *, ...);
+
+void f(int n)
+{
+ int a[n];
+
+ for (auto& i : a)
+ {
+ i = &i - a;
+ }
+
+ [&a] (auto m)
+ {
+ for (auto i : a)
+ {
+ printf ("%d", i);
+ }
+
+ return m;
+ };
+}