From 6f58bc5825c0d0ff0606b747b01bb2dcff882a1d Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 16 Feb 2018 16:02:50 -0500 Subject: [PATCH] PR c++/84420 - ICE with structured binding in lambda. * lambda.c (is_capture_proxy): Check DECL_DECOMPOSITION_P. From-SVN: r257761 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/lambda.c | 1 + gcc/testsuite/g++.dg/cpp1z/decomp-lambda1.C | 10 ++++++++++ 3 files changed, 14 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1z/decomp-lambda1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 076b8f93c47..b7d45707d5e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2018-02-16 Jason Merrill + 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. 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; + }(); +} -- 2.30.2