]> git.ipfire.org Git - people/ms/gcc.git/commit
c++: explicit specialization and trailing requirements [PR107864]
authorPatrick Palka <ppalka@redhat.com>
Tue, 29 Nov 2022 14:55:21 +0000 (09:55 -0500)
committerPatrick Palka <ppalka@redhat.com>
Tue, 7 Mar 2023 02:13:21 +0000 (21:13 -0500)
commit18bd59990196462cde8011458e2518118b1b6681
treefe1bd73cd56755f25945d4cf8492f043c09ea6ac
parent668098c2e55c33f97e331c3160174bf12c3d88f7
c++: explicit specialization and trailing requirements [PR107864]

Here we're crashing when using the explicit specialization of the
function template g with trailing requirements ultimately because
earlier decls_match (called indirectly from register_specialization) for
for the explicit specialization returned false since the template has
trailing requirements whereas the specialization doesn't.

In r12-2230-gddd25bd1a7c8f4, we fixed a similar issue concerning template
requirements instead of trailing requirements.  We could extend that fix
to ignore trailing requirement mismatches for explicit specializations
as well, but it seems cleaner to just propagate constraints from the
specialized template to the specialization when declaring an explicit
specialization so that decls_match will naturally return true in this
case.  And it looks like determine_specialization already does this,
albeit inconsistently (only when specializing a non-template member
function of a class template as in cpp2a/concepts-explicit-spec4.C).

So this patch makes determine_specialization consistently propagate
constraints from the specialized template to the specialization, which
in turn lets us get rid of the function_requirements_equivalent_p special
case added by r12-2230.

PR c++/107864

gcc/cp/ChangeLog:

* decl.cc (function_requirements_equivalent_p): Don't check
DECL_TEMPLATE_SPECIALIZATION.
* pt.cc (determine_specialization): Propagate constraints when
specializing a function template too.  Simplify by using
add_outermost_template_args.

gcc/testsuite/ChangeLog:

* g++.dg/concepts/explicit-spec1a.C: New test.

(cherry picked from commit 36cabc257dfb7dd4f7625896891f6c5b195a0241)
gcc/cp/decl.cc
gcc/cp/pt.cc
gcc/testsuite/g++.dg/concepts/explicit-spec1a.C [new file with mode: 0644]