Patchwork C++ PATCH for c++/36435 (partial ordering ignoring return type)

login
register
mail settings
Submitter Jason Merrill
Date June 23, 2011, 4:10 p.m.
Message ID <4E036590.6070100@redhat.com>
Download mbox | patch
Permalink /patch/101649/
State New
Headers show

Comments

Jason Merrill - June 23, 2011, 4:10 p.m.
Partial ordering to match a particular function signature should 
consider the return type.

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

Patch

commit 344d1ea28e060dc539b7f8cbcbeb33a32420f638
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jun 22 14:39:13 2011 -0400

    	PR c++/36435
    	* pt.c (most_specialized_instantiation): Do check return types.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 2716f78..08ce5af 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -16610,12 +16610,12 @@  most_specialized_instantiation (tree templates)
 
       if (get_bindings (TREE_VALUE (champ),
 			DECL_TEMPLATE_RESULT (TREE_VALUE (fn)),
-			NULL_TREE, /*check_ret=*/false))
+			NULL_TREE, /*check_ret=*/true))
 	fate--;
 
       if (get_bindings (TREE_VALUE (fn),
 			DECL_TEMPLATE_RESULT (TREE_VALUE (champ)),
-			NULL_TREE, /*check_ret=*/false))
+			NULL_TREE, /*check_ret=*/true))
 	fate++;
 
       if (fate == -1)
@@ -16637,10 +16637,10 @@  most_specialized_instantiation (tree templates)
     for (fn = templates; fn != champ; fn = TREE_CHAIN (fn))
       if (get_bindings (TREE_VALUE (champ),
 			DECL_TEMPLATE_RESULT (TREE_VALUE (fn)),
-			NULL_TREE, /*check_ret=*/false)
+			NULL_TREE, /*check_ret=*/true)
 	  || !get_bindings (TREE_VALUE (fn),
 			    DECL_TEMPLATE_RESULT (TREE_VALUE (champ)),
-			    NULL_TREE, /*check_ret=*/false))
+			    NULL_TREE, /*check_ret=*/true))
 	{
 	  champ = NULL_TREE;
 	  break;
diff --git a/gcc/testsuite/g++.dg/template/partial9.C b/gcc/testsuite/g++.dg/template/partial9.C
new file mode 100644
index 0000000..4c340fc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/partial9.C
@@ -0,0 +1,6 @@ 
+// PR c++/36435
+
+template <class T> T f();
+template <class T> T* f() { }
+
+template int* f();