aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/call.cc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2022-02-09 11:33:04 -0500
committerPatrick Palka <ppalka@redhat.com>2022-02-09 11:33:04 -0500
commitee50b4383a0dca88172c3a821418344bd7391956 (patch)
treec904f8d103b670a8fefdbff46504b72b66c71160 /gcc/cp/call.cc
parent1ce5395977f37e8d0c03394f7b932a584ce85cc7 (diff)
downloadgcc-ee50b4383a0dca88172c3a821418344bd7391956.zip
gcc-ee50b4383a0dca88172c3a821418344bd7391956.tar.gz
gcc-ee50b4383a0dca88172c3a821418344bd7391956.tar.bz2
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.
Diffstat (limited to 'gcc/cp/call.cc')
-rw-r--r--gcc/cp/call.cc9
1 files changed, 4 insertions, 5 deletions
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index b2e89c5..d6eed5e 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -11189,12 +11189,11 @@ build_new_method_call (tree instance, tree fns, vec<tree, va_gc> **args,
if (really_overloaded_fn (fns))
{
if (DECL_TEMPLATE_INFO (fn)
- && DECL_MEMBER_TEMPLATE_P (DECL_TI_TEMPLATE (fn))
- && dependent_type_p (DECL_CONTEXT (fn)))
+ && DECL_MEMBER_TEMPLATE_P (DECL_TI_TEMPLATE (fn)))
{
- /* FIXME: We're not prepared to fully instantiate "inside-out"
- partial instantiations such as A<T>::f<int>(). So instead
- use the selected template, not the specialization. */
+ /* Use the selected template, not the specialization, so that
+ this looks like an actual lookup result for sake of
+ filter_memfn_lookup. */
if (OVL_SINGLE_P (fns))
/* If the original overload set consists of a single function