]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: unique friend shenanigans [PR69836]
authorJason Merrill <jason@redhat.com>
Wed, 1 Feb 2023 22:00:48 +0000 (17:00 -0500)
committerJason Merrill <jason@redhat.com>
Wed, 26 Apr 2023 21:16:21 +0000 (17:16 -0400)
commit1e27e7e0985e055b3d4ec92e93976b709fdbe425
tree3bb453a340838375b0cf5ceb5a58f9d38c6f9252
parent50d866038a910ceb9075b97295a12d77a8d09a3a
c++: unique friend shenanigans [PR69836]

Normally we re-instantiate a function declaration when we start to
instantiate the body in case of multiple declarations.  In this wacky
testcase, this causes a problem because the type of the w_counter parameter
depends on its declaration not being in scope yet, so the name lookup only
finds the previous declaration.  This isn't a problem for member functions,
since they aren't subject to argument-dependent lookup.  So let's just skip
the regeneration for hidden friends.

PR c++/69836

gcc/cp/ChangeLog:

* pt.cc (regenerate_decl_from_template): Skip unique friends.

gcc/testsuite/ChangeLog:

* g++.dg/template/friend76.C: New test.
gcc/cp/pt.cc
gcc/testsuite/g++.dg/template/friend76.C [new file with mode: 0644]