re PR c++/59271 (a.C:16:21: internal compiler error: in strip_typedefs, at cp/tree...
authorJason Merrill <jason@redhat.com>
Tue, 24 Dec 2013 04:22:23 +0000 (23:22 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 24 Dec 2013 04:22:23 +0000 (23:22 -0500)
PR c++/59271
* lambda.c (build_capture_proxy): Use build_cplus_array_type.

From-SVN: r206193

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

index c921f203ac993b34692be4988a2a5b864a9d9304..242342b54537db2b5d0e2f811b27f79a0fc8bdb2 100644 (file)
@@ -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.
 
index 24aa2c55cc0f3a8224932be8e282e44bda28b242..bd8df1d94a9fba9231feb890c51a7dc07725cf38 100644 (file)
@@ -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 (file)
index 0000000..556722c
--- /dev/null
@@ -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;
+    };
+}