From cbb83bc59f660c614275a3150f200b3b3152140c Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 27 Jan 2015 21:40:45 +0000 Subject: [PATCH] PR c++/58597 * lambda.c (maybe_add_lambda_conv_op): Check cfun rather than current_function_decl. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@220192 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/lambda.c | 2 +- gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg6.C | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg6.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b914f4b1334..2ae15d027d8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2015-01-27 Jason Merrill + PR c++/58597 + * lambda.c (maybe_add_lambda_conv_op): Check cfun rather than + current_function_decl. + PR c++/63889 * pt.c (finish_template_variable): Move from semantics.c. Handle multiple template arg levels. Handle coercion here. diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index 6c9e224c0f4..b160c8cb7ae 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -854,7 +854,7 @@ prepare_op_call (tree fn, int nargs) void maybe_add_lambda_conv_op (tree type) { - bool nested = (current_function_decl != NULL_TREE); + bool nested = (cfun != NULL); bool nested_def = decl_function_context (TYPE_MAIN_DECL (type)); tree callop = lambda_function (type); diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg6.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg6.C new file mode 100644 index 00000000000..fe8767ac605 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg6.C @@ -0,0 +1,9 @@ +// PR c++/58597 +// { dg-do compile { target c++11 } } + +template struct A +{ + template A(T, int = []{ return 0; }()) {} +}; + +A a = 0; -- 2.11.4.GIT