From e42f342652981aa9181cc3ceb04e0eb715506764 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 5 May 2020 17:39:19 -0400 Subject: [PATCH] c++: CWG2235 partial ordering and non-dependent types Issue 2235 removed the rule previously added for issues 1391/1847 that had partial ordering completely ignore function parameters with no deducible template parameters. gcc/cp/ChangeLog 2020-05-05 Jason Merrill CWG 2235 * pt.c (more_specialized_fn): Do consider parms with no deducible template parameters. --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 9 --------- .../g++.dg/template/partial-order1.C | 2 +- .../g++.dg/template/partial-order2.C | 20 +++++++++++++++++++ 4 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/partial-order2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 71ca21f24e4..c49e90e34a7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-05-05 Jason Merrill + + CWG 2235 + * pt.c (more_specialized_fn): Do consider parms with no deducible + template parameters. + 2020-05-05 Jason Merrill PR c++/90212 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index ff8391c2093..2ed6d0e7457 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -23960,13 +23960,6 @@ more_specialized_fn (tree pat1, tree pat2, int len) len = 0; } - /* DR 1847: If a particular P contains no template-parameters that - participate in template argument deduction, that P is not used to - determine the ordering. */ - if (!uses_deducible_template_parms (arg1) - && !uses_deducible_template_parms (arg2)) - goto next; - if (TYPE_REF_P (arg1)) { ref1 = TYPE_REF_IS_RVALUE (arg1) + 1; @@ -24088,8 +24081,6 @@ more_specialized_fn (tree pat1, tree pat2, int len) These must be unordered. */ break; - next: - if (TREE_CODE (arg1) == TYPE_PACK_EXPANSION || TREE_CODE (arg2) == TYPE_PACK_EXPANSION) /* We have already processed all of the arguments in our diff --git a/gcc/testsuite/g++.dg/template/partial-order1.C b/gcc/testsuite/g++.dg/template/partial-order1.C index 0832ea535ca..624bb4bc0f0 100644 --- a/gcc/testsuite/g++.dg/template/partial-order1.C +++ b/gcc/testsuite/g++.dg/template/partial-order1.C @@ -14,5 +14,5 @@ void f(typename A::size_type, T); int main() { - f(1,2); // { dg-error "ambiguous" } + f(1,2); } diff --git a/gcc/testsuite/g++.dg/template/partial-order2.C b/gcc/testsuite/g++.dg/template/partial-order2.C new file mode 100644 index 00000000000..2aed6008d05 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/partial-order2.C @@ -0,0 +1,20 @@ +// CWG 2235 + +namespace X +{ + template struct Const { typedef void type; }; + template void f(T, typename Const::type*); // T1 + template void f(T, void *); // T2 + void g(void *p) { f(0, p); } +} + +namespace Y +{ + struct A { A(int); }; + struct B { B(int); }; + + template void f(T, A); + template void f(T*, B); + + void g(int *p) { f(p, 0); } // { dg-error "ambiguous" } +}