From: Jason Merrill Date: Wed, 10 May 2017 20:07:22 +0000 (-0400) Subject: CWG 1847 - Clarifying compatibility during partial ordering X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=00e08b0f4802855cf1516e67faea5ab385acafd5;p=gcc.git CWG 1847 - Clarifying compatibility during partial ordering * pt.c (more_specialized_fn): No order between two non-deducible parameters. From-SVN: r247856 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 09caa02ba70..cc94e0a291c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2017-05-10 Jason Merrill + CWG 1847 - Clarifying compatibility during partial ordering + * pt.c (more_specialized_fn): No order between two non-deducible + parameters. + * pt.c (dependent_type_p): Make sure we aren't called with global_type_node. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index b9e7af7066b..17398c9dcdd 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -21182,6 +21182,13 @@ 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 (TREE_CODE (arg1) == REFERENCE_TYPE) { ref1 = TYPE_REF_IS_RVALUE (arg1) + 1; @@ -21303,6 +21310,8 @@ 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 new file mode 100644 index 00000000000..0832ea535ca --- /dev/null +++ b/gcc/testsuite/g++.dg/template/partial-order1.C @@ -0,0 +1,18 @@ +// { dg-do compile { target c++11 } } + +using size_t = decltype(sizeof(0)); +template struct A +{ + using size_type = size_t; +}; + +template +void f(size_t, T); + +template +void f(typename A::size_type, T); + +int main() +{ + f(1,2); // { dg-error "ambiguous" } +}