[PR c++/84804] ICE with default arg, template friend & lambda
authorNathan Sidwell <nathan@acm.org>
Wed, 21 Mar 2018 15:58:00 +0000 (15:58 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Wed, 21 Mar 2018 15:58:00 +0000 (15:58 +0000)
https://gcc.gnu.org/ml/gcc-patches/2018-03/msg01108.html
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.

From-SVN: r258722

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/pr84804.C [new file with mode: 0644]

index 36e07d9bd9a0282612bc413ff4bfd33cb7aca3c2..8fc9314ac0f684187df9705081cae2722a29a822 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-21  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/84804
+       * name-lookup.c (do_pushtag): Permit lambdas to be pushed into
+       complete classes.
+
 2018-03-21  Martin Sebor  <msebor@redhat.com>
 
        PR c++/84850
index eda565551fb42fcaaf9025c0c017e577283e7a69..e193b3bc1de2237a092eab83db587ea7e9c3092f 100644 (file)
@@ -6436,7 +6436,8 @@ do_pushtag (tree name, tree type, tag_scope scope)
 
       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 ())
index 1b8c63b469fc113d1b876deadbf600dfb8a950bd..4422bdf5308d2e0fe4633d32de882ed8fdce59c1 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-21  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/84804
+       * g++.dg/lookup/pr84804.C: New.
+
 2018-03-21  Martin Sebor  <msebor@redhat.com>
 
        PR c++/84850
diff --git a/gcc/testsuite/g++.dg/lookup/pr84804.C b/gcc/testsuite/g++.dg/lookup/pr84804.C
new file mode 100644 (file)
index 0000000..af7b615
--- /dev/null
@@ -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;
+}