]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: memfn lookup consistency and using-decls [PR104432]
authorPatrick Palka <ppalka@redhat.com>
Wed, 9 Feb 2022 16:33:04 +0000 (11:33 -0500)
committerPatrick Palka <ppalka@redhat.com>
Wed, 9 Feb 2022 16:33:04 +0000 (11:33 -0500)
commitee50b4383a0dca88172c3a821418344bd7391956
treec904f8d103b670a8fefdbff46504b72b66c71160
parent1ce5395977f37e8d0c03394f7b932a584ce85cc7
c++: memfn lookup consistency and using-decls [PR104432]

In filter_memfn_lookup, we weren't correctly recognizing and matching up
member functions introduced via a non-dependent using-decl.  This caused
us to crash in the below testcases in which we correctly pruned the
overload set for the non-dependent call ahead of time, but then at
instantiation time filter_memfn_lookup failed to match the selected
function (introduced in each case by a non-dependent using-decl) to the
corresponding function from the new lookup set.  Such member functions
need special handling in filter_memfn_lookup because they look exactly
the same in the old and new lookup sets, whereas ordinary member
functions that're defined in the (dependent) current class become more
specialized in the new lookup set.

This patch reworks the matching logic in filter_memfn_lookup so that it
handles (member functions introduced by) non-dependent using-decls
correctly, and is hopefully simpler overall.

PR c++/104432

gcc/cp/ChangeLog:

* call.cc (build_new_method_call): When a non-dependent call
resolves to a specialization of a member template, always build
the pruned overload set using the member template, not the
specialization.
* pt.cc (filter_memfn_lookup): New parameter newtype.  Simplify
and correct how members from the new lookup set are matched to
those from the old one.
(tsubst_baselink): Pass binfo_type as newtype to
filter_memfn_lookup.

gcc/testsuite/ChangeLog:

* g++.dg/template/non-dependent19.C: New test.
* g++.dg/template/non-dependent19a.C: New test.
* g++.dg/template/non-dependent20.C: New test.
gcc/cp/call.cc
gcc/cp/pt.cc
gcc/testsuite/g++.dg/template/non-dependent19.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/non-dependent19a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/non-dependent20.C [new file with mode: 0644]