* decl2.c (determine_visibility): Look for outer containing template
instantiation.
From-SVN: r257202
2018-01-30 Jason Merrill <jason@redhat.com>
+ 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.
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)
--- /dev/null
+// PR c++/84091
+// { dg-do compile { target c++11 } }
+
+template < typename > void f ()
+{
+ [] { struct A {} a; } ();
+}
+
+int main ()
+{
+ f < int > ();
+ return 0;
+}