From: Jason Merrill Date: Tue, 30 Jan 2018 20:01:36 +0000 (-0500) Subject: PR c++/84091 - ICE with local class in lambda in template. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b1c7b29a3cae7dcf652cc3e3f971ec010153d814;p=gcc.git PR c++/84091 - ICE with local class in lambda in template. * decl2.c (determine_visibility): Look for outer containing template instantiation. From-SVN: r257202 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 536a3e36107..ceb1e856324 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2018-01-30 Jason Merrill + PR c++/84091 - ICE with local class in lambda in template. + * decl2.c (determine_visibility): Look for outer containing template + instantiation. + PR c++/84098 - ICE with lambda in template NSDMI. * pt.c (instantiate_class_template_1): Ignore more lambdas. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index ef7e6de41c3..2da6f9023c5 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2418,6 +2418,16 @@ determine_visibility (tree decl) by that. */ if (DECL_LANG_SPECIFIC (fn) && DECL_USE_TEMPLATE (fn)) template_decl = fn; + else if (template_decl) + { + /* FN must be a regenerated lambda function, since they don't + have template arguments. Find a containing non-lambda + template instantiation. */ + tree ctx = fn; + while (ctx && !get_template_info (ctx)) + ctx = get_containing_scope (ctx); + template_decl = ctx; + } } else if (VAR_P (decl) && DECL_TINFO_P (decl) && flag_visibility_ms_compat) diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-local1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-local1.C new file mode 100644 index 00000000000..a2dd350369a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-local1.C @@ -0,0 +1,13 @@ +// PR c++/84091 +// { dg-do compile { target c++11 } } + +template < typename > void f () +{ + [] { struct A {} a; } (); +} + +int main () +{ + f < int > (); + return 0; +}