c++: only declare satisfied friends
authorJason Merrill <jason@redhat.com>
Fri, 11 Nov 2022 10:45:02 +0000 (00:45 -1000)
committerJason Merrill <jason@redhat.com>
Mon, 14 Nov 2022 22:51:38 +0000 (17:51 -0500)
commitc41bbfcaf9d6ef5b57a7e89bba70b861c08a686b
tree23c3fbf034db9747bc4e05a833d1b096e9e29ee4
parente7c12a921525b2aa27ca4814c42c63d61a6d954e
c++: only declare satisfied friends

A friend declaration can only have constraints if it is defined.  If
multiple instantiations of a class template define the same friend function
signature, it's an error, but that shouldn't happen if it's constrained to
only be declared in one instantiation.

Currently we don't mangle requirements, so the foos all mangle the same and
actually instantiating #1 will break, but for now we can test that they're
considered distinct.

gcc/cp/ChangeLog:

* pt.cc (tsubst_friend_function): Check satisfaction.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-friend11.C: New test.
gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp2a/concepts-friend11.C [new file with mode: 0644]