c++: "more constrained" vs staticness of memfn [PR103783]
authorPatrick Palka <ppalka@redhat.com>
Mon, 10 Jan 2022 19:57:51 +0000 (14:57 -0500)
committerPatrick Palka <ppalka@redhat.com>
Mon, 10 Jan 2022 19:57:51 +0000 (14:57 -0500)
commit3e95a974c39e922d19bf7ac1246730c516ae01f2
tree75400c8b65eb2929942f7d74ece3bfdefb860314
parent54fa7daefe35cacf4a933947d1802318da193c01
c++: "more constrained" vs staticness of memfn [PR103783]

Here we're rejecting the calls to g1 and g2 as ambiguous even though one
overload is more constrained than the other (and they're otherwise tied),
because the implicit 'this' parameter of the non-static overload causes
cand_parms_match to think the function parameter lists aren't equivalent.

This patch fixes this by making cand_parms_match skip over 'this'
appropriately.  Note that this bug only affects partial ordering of
non-template member functions because for member function templates
more_specialized_fn seems to already skip over 'this' appropriately.

PR c++/103783

gcc/cp/ChangeLog:

* call.c (cand_parms_match): Skip over 'this' when given one
static and one non-static member function.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-memfun2.C: New test.
gcc/cp/call.c
gcc/testsuite/g++.dg/cpp2a/concepts-memfun2.C [new file with mode: 0644]