aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2017-05-10 16:07:22 -0400
committerJason Merrill <jason@gcc.gnu.org>2017-05-10 16:07:22 -0400
commit00e08b0f4802855cf1516e67faea5ab385acafd5 (patch)
treefac302907200fdf074e6c0c3d28d74ad61e0d500 /gcc
parente5795ce4937af06206161ea94b27a9df87fba1f1 (diff)
downloadgcc-00e08b0f4802855cf1516e67faea5ab385acafd5.zip
gcc-00e08b0f4802855cf1516e67faea5ab385acafd5.tar.gz
gcc-00e08b0f4802855cf1516e67faea5ab385acafd5.tar.bz2
CWG 1847 - Clarifying compatibility during partial ordering
* pt.c (more_specialized_fn): No order between two non-deducible parameters. From-SVN: r247856
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/pt.c9
-rw-r--r--gcc/testsuite/g++.dg/template/partial-order1.C18
3 files changed, 31 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 09caa02..cc94e0a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2017-05-10 Jason Merrill <jason@redhat.com>
+ 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 b9e7af7..17398c9 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 0000000..0832ea5
--- /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 <class T> struct A
+{
+ using size_type = size_t;
+};
+
+template <class T>
+void f(size_t, T);
+
+template <class T>
+void f(typename A<T>::size_type, T);
+
+int main()
+{
+ f(1,2); // { dg-error "ambiguous" }
+}