From: Jason Merrill Date: Tue, 27 Jan 2015 21:40:45 +0000 (-0500) Subject: re PR c++/58597 (ICE with lambda in default argument of template function) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2cc7f90b6e4906efd9cd909d7182630dbf9e819b;p=gcc.git re PR c++/58597 (ICE with lambda in default argument of template function) PR c++/58597 * lambda.c (maybe_add_lambda_conv_op): Check cfun rather than current_function_decl. From-SVN: r220192 --- 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;