From d3155b0847744996ae5438065aebf257151e18f0 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 12 Dec 2014 16:43:16 +0000 Subject: [PATCH] PR c++/61402 * lambda.c (add_capture): Don't pass a dependent type to variably_modified_type_p. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@218680 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/lambda.c | 3 ++- gcc/testsuite/g++.dg/cpp1y/lambda-init11.C | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp1y/lambda-init11.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 53bf2f5981c2..1809b26a0109 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-12-12 Jason Merrill + + PR c++/61402 + * lambda.c (add_capture): Don't pass a dependent type to + variably_modified_type_p. + 2014-12-11 Jason Merrill Remove N3639 "array of runtime length" from -std=c++14. diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index 9eb920063232..3da28e568831 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -483,7 +483,8 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p, NULL_TREE, array_type_nelts (type)); type = vla_capture_type (type); } - else if (variably_modified_type_p (type, NULL_TREE)) + else if (!dependent_type_p (type) + && variably_modified_type_p (type, NULL_TREE)) { error ("capture of variable-size type %qT that is not an N3639 array " "of runtime bound", type); diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init11.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init11.C new file mode 100644 index 000000000000..f7525d8664a9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init11.C @@ -0,0 +1,20 @@ +// PR c++/61402 +// { dg-do run { target c++14 } } + +extern "C" void abort(); + +template +void foo(T t) { + auto test = [ i = ++t ](T v) { + if (i != v) + abort(); + }; + test(t); +} + +int main(){ + foo(3.14f); + foo(0); + foo('a'); + foo(false); +} -- 2.47.3