PR c++/84429 - ICE capturing VLA.
authorJason Merrill <jason@redhat.com>
Tue, 20 Feb 2018 03:39:37 +0000 (22:39 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 20 Feb 2018 03:39:37 +0000 (22:39 -0500)
* lambda.c (build_capture_proxy): Handle reference refs.

From-SVN: r257836

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

index 870dde6388d2d57b242b41c28ffc575dc3f22955..000e72f2286e88ce89fe0e9870ff8c32bc1de598 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-19  Jason Merrill  <jason@redhat.com>
+
+       PR c++/84429 - ICE capturing VLA.
+       * lambda.c (build_capture_proxy): Handle reference refs.
+
 2018-02-19  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/84448
index 38500b13262882039f6be4fd4460b0cd7d9db494..a0a80dfde5c9bef0b45f3d70c6939d6761807ec3 100644 (file)
@@ -451,11 +451,12 @@ build_capture_proxy (tree member, tree init)
        {
          if (PACK_EXPANSION_P (init))
            init = PACK_EXPANSION_PATTERN (init);
-         if (INDIRECT_REF_P (init))
-           init = TREE_OPERAND (init, 0);
-         STRIP_NOPS (init);
        }
 
+      if (INDIRECT_REF_P (init))
+       init = TREE_OPERAND (init, 0);
+      STRIP_NOPS (init);
+
       gcc_assert (VAR_P (init) || TREE_CODE (init) == PARM_DECL);
       while (is_normal_capture_proxy (init))
        init = DECL_CAPTURED_VARIABLE (init);
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla1.C
new file mode 100644 (file)
index 0000000..91498c4
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/84429
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+void foo(int i)
+{
+  char x[i];
+  [&]{ [&]{ return x; }; };
+}