PR c++/84420 - ICE with structured binding in lambda.
authorJason Merrill <jason@redhat.com>
Fri, 16 Feb 2018 21:02:50 +0000 (16:02 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 16 Feb 2018 21:02:50 +0000 (16:02 -0500)
* lambda.c (is_capture_proxy): Check DECL_DECOMPOSITION_P.

From-SVN: r257761

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

index 076b8f93c4793f4f4101e16275b9b3f9571a41f3..b7d45707d5e91d4a01fa321d86d7212e0327a7b0 100644 (file)
@@ -1,5 +1,8 @@
 2018-02-16  Jason Merrill  <jason@redhat.com>
 
+       PR c++/84420 - ICE with structured binding in lambda.
+       * lambda.c (is_capture_proxy): Check DECL_DECOMPOSITION_P.
+
        PR c++/83835 - C++17 error with constructor ctors.
        * call.c (build_special_member_call): Set TARGET_EXPR_DIRECT_INIT_P.
 
index 6b5bd8007418968f65b1de772172e2ccbe8b136c..38500b13262882039f6be4fd4460b0cd7d9db494 100644 (file)
@@ -261,6 +261,7 @@ is_capture_proxy (tree decl)
   return (VAR_P (decl)
          && DECL_HAS_VALUE_EXPR_P (decl)
          && !DECL_ANON_UNION_VAR_P (decl)
+         && !DECL_DECOMPOSITION_P (decl)
          && LAMBDA_FUNCTION_P (DECL_CONTEXT (decl)));
 }
 
diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp-lambda1.C b/gcc/testsuite/g++.dg/cpp1z/decomp-lambda1.C
new file mode 100644 (file)
index 0000000..fbab025
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/84420
+// { dg-additional-options -std=c++17 }
+
+int main(){
+    int a[1]{};
+    [&a]{
+        auto [v] = a;
+        (void)v;
+    }();
+}