From 329a89d34cedb0aec759f9c4531d2dbba7f0937b Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 19 Feb 2018 22:39:37 -0500 Subject: [PATCH] PR c++/84429 - ICE capturing VLA. * lambda.c (build_capture_proxy): Handle reference refs. From-SVN: r257836 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/lambda.c | 7 ++++--- gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla1.C | 9 +++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 870dde6388d..000e72f2286 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-02-19 Jason Merrill + + PR c++/84429 - ICE capturing VLA. + * lambda.c (build_capture_proxy): Handle reference refs. + 2018-02-19 Jakub Jelinek PR c++/84448 diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index 38500b13262..a0a80dfde5c 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -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 index 00000000000..91498c4589a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-vla1.C @@ -0,0 +1,9 @@ +// PR c++/84429 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +void foo(int i) +{ + char x[i]; + [&]{ [&]{ return x; }; }; +} -- 2.30.2