Now that structured bindings are another use of DECL_VALUE_EXPR,
is_capture_proxy needs to recognize them.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 275feb77e153ff34289b1fc381d4da52bb68dd8e
Author: Jason Merrill <ja...@redhat.com>
Date:   Fri Feb 16 15:09:56 2018 -0500

            PR c++/84420 - ICE with structured binding in lambda.
    
            * lambda.c (is_capture_proxy): Check DECL_DECOMPOSITION_P.

diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index 6b5bd800741..38500b13262 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -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
index 00000000000..fbab0259643
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/decomp-lambda1.C
@@ -0,0 +1,10 @@
+// PR c++/84420
+// { dg-additional-options -std=c++17 }
+
+int main(){
+    int a[1]{};
+    [&a]{
+        auto [v] = a;
+        (void)v;
+    }();
+}

Reply via email to