On Thu Dec 18, 2025 at 3:34 AM WET, Patrick Palka wrote: > On Wed, 17 Dec 2025, Patrick Palka wrote: > >> Hey Egas, >> >> Thanks for looking into this recent regression! >> >> On Wed, 17 Dec 2025, Egas Ribeiro wrote: >> >> > Regtested on x86_64-pc-linux-gnu. >> > >> > This fix works, but I believe the real issue is that >> > member_like_constrained_friend_p is incorrectly returning false because >> > DECL_TEMPLATE_INFO isn't set up for the friend before duplicate_decls is >> > called. I tried a few fixes to defer pushdecl_namespace_level after we >> > call build_template_info in push_template_decl, but they caused some >> > regressions. Suggestions on how i might fix this correctly? >> > (also, using && probably goes against [temp.friend]/9 requirements) >> >> Yeah, one would expect DECL_TEMPLATE_INFO to point back to the template >> friend's TEMPLATE_DECL here (whose DECL_TEMPLATE_RESULT points to the >> FUNCTION_DECL as expected). We probably should fix that.. >> >> Luckily I think we can work around this missing DECL_TEMPLATE_INFO for >> this PR. The predicate needs to return true for non-template >> constrained friends and template friends whose constraints depend on >> outer template parameters. In the former case the function must be >> templated (since only templated functions can have constraints) and >> therefore the class scope must be templated. In the latter case the >> class scope must also be templated since we assume there are outer >> template parameters on which the constraint can depend. So in either >> case the class scope must be templated! >> >> So I think it should work to add >> >> CLASSTYPE_TEMPLATE_INFO (DECL_FRIEND_CONTEXT (decl)) >> >> to the predicate, which will rule out non class template scope friends >> such as in the PR?
Thanks for the feedback! I was looking exactly for this kind of extra check but couldn't find the right method. > Actually we probably need to check > > CLASSTYPE_IMPLICIT_INSTANTIATION > > instead, so that we return false also when the friend in an explicit > specialization scope. Alright. I'll try these and see if it has no regressions.
