CWG 1847 - Clarifying compatibility during partial ordering
authorJason Merrill <jason@redhat.com>
Wed, 10 May 2017 20:07:22 +0000 (16:07 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 10 May 2017 20:07:22 +0000 (16:07 -0400)
* pt.c (more_specialized_fn): No order between two non-deducible
parameters.

From-SVN: r247856

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/template/partial-order1.C [new file with mode: 0644]

index 09caa02ba70b19cdbd9dc091889975019c8c2281..cc94e0a291c338609e7649521dff2653967fce70 100644 (file)
@@ -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.
 
index b9e7af7066b40c0ff29c2401d8b355481c6c6a3f..17398c9dcdd206a0689540bbe2c43fb5b4c9de0e 100644 (file)
@@ -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 (file)
index 0000000..0832ea5
--- /dev/null
@@ -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" }
+}