c++: dependence of constrained memfn from current inst [PR105842]
authorPatrick Palka <ppalka@redhat.com>
Wed, 13 Jul 2022 18:01:28 +0000 (14:01 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 21 Jul 2022 16:38:46 +0000 (12:38 -0400)
commit5d6286903f325a7a85e5ab1d04ba942d33d755bc
treeb6b1b2080ba3cfa466a39b90f6917b8ef88b4491
parent670ef5b108d0acfbde96f44b064079f2fa0c92d4
c++: dependence of constrained memfn from current inst [PR105842]

Here we incorrectly deem the calls to func1, func2 and tmpl2 as
ambiguous ahead of time ultimately because we mishandle dependence
of a constrained member function from the current instantiation.

In type_dependent_expression_p, we already consider dependence of a
TEMPLATE_DECL's constraints (via uses_outer_template_parms), but
neglect to do the same for a FUNCTION_DECL (such as that for func1).

And in satisfy_declaration_constraints, we give up if _any_ template
argument is dependent, but for non-dependent member functions from
the current instantiation (such as func2 and tmpl2), we can and must
check constraints as long as the innermost arguments aren't dependent.

PR c++/105842

gcc/cp/ChangeLog:

* constraint.cc (satisfy_declaration_constraints): Refine early
exit test for argument dependence.
* cp-tree.h (uses_outer_template_parms_in_constraints): Declare.
* pt.cc (template_class_depth): Handle TI_TEMPLATE being a
FIELD_DECL.
(usse_outer_template_parms): Factor out constraint dependence
test into ...
(uses_outer_template_parms_in_constraints): ... here.
(type_dependent_expression_p): Use it for FUNCTION_DECL.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-memtmpl6.C: New test.

(cherry picked from commit f07778f6f92111aa0abfd0f669b148a0bda537a9)
gcc/cp/constraint.cc
gcc/cp/cp-tree.h
gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp2a/concepts-memtmpl6.C [new file with mode: 0644]