From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id ED753399081E; Fri, 9 Jul 2021 20:13:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED753399081E MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jason Merrill To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-2230] c++: concepts TS and explicit specialization [PR101098] X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/heads/master X-Git-Oldrev: d5b1bb0d197f9141a0f0e510f8d1b598c3df9552 X-Git-Newrev: ddd25bd1a7c8f456bc914e34b77d43f39a1062d4 Message-Id: <20210709201352.ED753399081E@sourceware.org> Date: Fri, 9 Jul 2021 20:13:52 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jul 2021 20:13:53 -0000 https://gcc.gnu.org/g:ddd25bd1a7c8f456bc914e34b77d43f39a1062d4 commit r12-2230-gddd25bd1a7c8f456bc914e34b77d43f39a1062d4 Author: Jason Merrill Date: Fri Jul 9 13:50:01 2021 -0400 c++: concepts TS and explicit specialization [PR101098] duplicate_decls was not recognizing the explicit specialization as matching the implicit specialization of g because function_requirements_equivalent_p was seeing the C constraint on the implicit one and not on the explicit. PR c++/101098 gcc/cp/ChangeLog: * decl.c (function_requirements_equivalent_p): Only compare trailing requirements on a specialization. gcc/testsuite/ChangeLog: * g++.dg/concepts/explicit-spec1.C: New test. Diff: --- gcc/cp/decl.c | 4 +++- gcc/testsuite/g++.dg/concepts/explicit-spec1.C | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index ebe1318d38d..0df689b01f8 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -955,7 +955,9 @@ static bool function_requirements_equivalent_p (tree newfn, tree oldfn) { /* In the concepts TS, the combined constraints are compared. */ - if (cxx_dialect < cxx20) + if (cxx_dialect < cxx20 + && (DECL_TEMPLATE_SPECIALIZATION (newfn) + <= DECL_TEMPLATE_SPECIALIZATION (oldfn))) { tree ci1 = get_constraints (oldfn); tree ci2 = get_constraints (newfn); diff --git a/gcc/testsuite/g++.dg/concepts/explicit-spec1.C b/gcc/testsuite/g++.dg/concepts/explicit-spec1.C new file mode 100644 index 00000000000..d9b6b3d1741 --- /dev/null +++ b/gcc/testsuite/g++.dg/concepts/explicit-spec1.C @@ -0,0 +1,9 @@ +// PR c++/101098 +// { dg-do compile { target concepts } } + +template concept C = __is_class(T); +struct Y { int n; } y; +template void g(T) { } +int called; +template<> void g(Y) { called = 3; } +int main() { g(y); }