From 5d011fcfcdcd04a94f74eca8643cb61f824774e3 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Wed, 21 Mar 2018 15:58:00 +0000 Subject: [PATCH] [PR c++/84804] ICE with default arg, template friend & lambda 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 | 6 ++++++ gcc/cp/name-lookup.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/lookup/pr84804.C | 12 ++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/lookup/pr84804.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 36e07d9bd9a..8fc9314ac0f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-03-21 Nathan Sidwell + + PR c++/84804 + * name-lookup.c (do_pushtag): Permit lambdas to be pushed into + complete classes. + 2018-03-21 Martin Sebor PR c++/84850 diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index eda565551fb..e193b3bc1de 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -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 ()) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1b8c63b469f..4422bdf5308 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-21 Nathan Sidwell + + PR c++/84804 + * g++.dg/lookup/pr84804.C: New. + 2018-03-21 Martin Sebor 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 index 00000000000..af7b615a45c --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/pr84804.C @@ -0,0 +1,12 @@ +// { dg-do compile { target c++11 } } +// PR c++/84804 ICE instantiating friend with default arg containing a lambda +template 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; +} -- 2.30.2