Message ID | 20190218230223.GS2135@tucnak |
---|---|
State | New |
Headers | show |
Series | [C++] Fix maybe_generic_this_capture ICE on USING_DECL (PR c++/89387) | expand |
On 2/18/19 1:02 PM, Jakub Jelinek wrote: > 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)? It only applies if DECL_DECLARES_FUNCTION_P. But the only other thing we should encounter is USING_DECL. So let's use != USING_DECL like the other places Alex changed. Jason
--- 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 (); +};