Hi! On the following testcase, id_expr is false and TREE_CODE (*iter) is USING_DECL (and the following one is FUNCTION_DECL). Since the USING_DECL changes, this ICEs because DECL_NONSTATIC_MEMBER_FUNCTION_P uses TREE_TYPE which can't be used here. Previously, I believe DECL_NONSTATIC_MEMBER_FUNCTION_P would be never true for USING_DECLs.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Or should it use != USING_DECL instead (what should be DECL_NONSTATIC_MEMBER_FUNCTION_P checked on other than FUNCTION_DECL/TEMPLATE_DECL)? 2019-02-18 Jakub Jelinek <ja...@redhat.com> PR c++/89387 * lambda.c (maybe_generic_this_capture): Don't check DECL_NONSTATIC_MEMBER_FUNCTION_P on USING_DECLs. * g++.dg/cpp0x/lambda/lambda-89387.C: New test. --- gcc/cp/lambda.c.jj 2019-02-18 20:48:32.112741017 +0100 +++ gcc/cp/lambda.c 2019-02-18 21:49:23.319629179 +0100 @@ -941,7 +941,8 @@ maybe_generic_this_capture (tree object, fns = TREE_OPERAND (fns, 0); for (lkp_iterator iter (fns); iter; ++iter) - if ((!id_expr || TREE_CODE (*iter) == TEMPLATE_DECL) + if (((!id_expr && TREE_CODE (*iter) == FUNCTION_DECL) + || TREE_CODE (*iter) == TEMPLATE_DECL) && DECL_NONSTATIC_MEMBER_FUNCTION_P (*iter)) { /* Found a non-static member. Capture this. */ --- gcc/testsuite/g++.dg/cpp0x/lambda/lambda-89387.C.jj 2019-02-18 21:56:46.410339001 +0100 +++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-89387.C 2019-02-18 21:55:58.869119054 +0100 @@ -0,0 +1,11 @@ +// PR c++/89387 +// { dg-do compile { target c++11 } } + +template <template <typename, typename> class T> +struct S { + using A = int; + using B = T<unsigned, A>; + using B::foo; + void bar () { [&] { foo (); }; } + void foo (); +}; Jakub