From: jason Date: Mon, 11 Feb 2019 23:05:16 +0000 (+0000) Subject: PR c++/89241 - ICE with __func__ in lambda in template. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=33fe677ecbc4c282fc7dd4f60c29b8abc4b97e5c;p=thirdparty%2Fgcc.git PR c++/89241 - ICE with __func__ in lambda in template. When we're instantiating a generic lambda, its enclosing context will have already been instantiated, so we need to look for that as well. * pt.c (enclosing_instantiation_of): Also check instantiated_lambda_fn_p for the template context. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@268784 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3d3bb2ace9ab..5fe18ccdab63 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-02-11 Jason Merrill + + PR c++/89241 - ICE with __func__ in lambda in template. + * pt.c (enclosing_instantiation_of): Also check + instantiated_lambda_fn_p for the template context. + 2019-02-11 Marek Polacek PR c++/89212 - ICE converting nullptr to pointer-to-member-function. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 184cb851145a..b96e3aa9cd56 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13355,7 +13355,8 @@ enclosing_instantiation_of (tree otctx) tree fn = current_function_decl; int lambda_count = 0; - for (; tctx && lambda_fn_in_template_p (tctx); + for (; tctx && (lambda_fn_in_template_p (tctx) + || instantiated_lambda_fn_p (tctx)); tctx = decl_function_context (tctx)) ++lambda_count; for (; fn; fn = decl_function_context (fn)) diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-func1.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-func1.C new file mode 100644 index 000000000000..4a6385529f81 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-func1.C @@ -0,0 +1,12 @@ +// PR c++/89241 +// { dg-do compile { target c++14 } } + +template void m(al p) { + p(1); +} + +template void f() { + m([](auto) { __func__; }); +} + +template void f();