2018-03-21 Nathan Sidwell <nathan@acm.org>
PR c++/84804
* name-lookup.c (do_pushtag): Permit lambdas to be pushed into
complete classes.
PR c++/84804
* g++.dg/lookup/pr84804.C: New.
===================================================================
@@ -6436,7 +6436,8 @@ do_pushtag (tree name, tree type, tag_sc
if (b->kind == sk_class)
{
- if (!TYPE_BEING_DEFINED (current_class_type))
+ if (!TYPE_BEING_DEFINED (current_class_type)
+ && !LAMBDA_TYPE_P (type))
return error_mark_node;
if (!PROCESSING_REAL_TEMPLATE_DECL_P ())
===================================================================
@@ -0,0 +1,12 @@
+// { dg-do compile { target c++11 } }
+// PR c++/84804 ICE instantiating friend with default arg containing a lambda
+template<int> struct A
+{
+ // Note, instantiation injects this into ::, so there can only be one!
+ friend void foo(int i = []{ return 0;}()) {}
+};
+
+void bar()
+{
+ A<0> x;
+}