public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for CWG DR 1847, partial ordering and non-deduced context
@ 2017-05-10 20:21 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2017-05-10 20:21 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 438 bytes --]

The resolution of Core DRs 1391 and 1847 clarified that function
parameters that don't involve deducible template parameters are not
considered for partial ordering.  I also experimented with handling
this at a finer-grained level, in unify, so that we would handle a
typename vs. a concrete type even if there were other deducible
template parameters, but that broke template/partial15.C.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: dr1847.diff --]
[-- Type: text/plain, Size: 1748 bytes --]

commit 8e4f455347781e161b73a121038efd76dc376aaa
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Mar 1 16:56:20 2017 -1000

            CWG 1847 - Clarifying compatibility during partial ordering
    
            * pt.c (more_specialized_fn): No order between two non-deducible
            parameters.

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" }
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-05-10 20:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-10 20:21 C++ PATCH for CWG DR 1847, partial ordering and non-deduced context Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).