summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2005-04-03 12:33:02 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2005-04-03 12:33:02 +0000
commit1301b5979430d54e4b2ff94440cf9535aa113f74 (patch)
tree84435f4c3075396a4fd35c2ffd666145ccc1525f
parentf7334ae55ea4b0fdf191fb036f344f04c29237a9 (diff)
downloadppe42-gcc-1301b5979430d54e4b2ff94440cf9535aa113f74.tar.gz
ppe42-gcc-1301b5979430d54e4b2ff94440cf9535aa113f74.zip
cp:
PR c++/20723 * pt.c (more_specialized_fn): Member functions are unordered wrt non-members. Conversion operators are unordered wrt other functions. testsuite: PR c++/20723 * g++.dg/template/spec22.C: New. * g++.dg/template/spec23.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@97489 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/pt.c10
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/template/spec22.C22
-rw-r--r--gcc/testsuite/g++.dg/template/spec23.C25
5 files changed, 68 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 4065f174693..90a68926ecf 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2005-04-03 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/20723
+ * pt.c (more_specialized_fn): Member functions are unordered wrt
+ non-members. Conversion operators are unordered wrt other
+ functions.
+
2005-04-01 Nathan Sidwell <nathan@codesourcery.com>
* call.c (add_template_candidates_real): Remove length parameter
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index f92ce90a7f0..e8b219080a5 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -10407,17 +10407,23 @@ more_specialized_fn (tree pat1, tree pat2, int len)
int better1 = 0;
int better2 = 0;
+ /* If only one is a member function, they are unordered. */
+ if (DECL_FUNCTION_MEMBER_P (decl1) != DECL_FUNCTION_MEMBER_P (decl2))
+ return 0;
+
/* Don't consider 'this' parameter. */
if (DECL_NONSTATIC_MEMBER_FUNCTION_P (decl1))
args1 = TREE_CHAIN (args1);
-
if (DECL_NONSTATIC_MEMBER_FUNCTION_P (decl2))
args2 = TREE_CHAIN (args2);
+ /* If only one is a conversion operator, they are unordered. */
+ if (DECL_CONV_FN_P (decl1) != DECL_CONV_FN_P (decl2))
+ return 0;
+
/* Consider the return type for a conversion function */
if (DECL_CONV_FN_P (decl1))
{
- gcc_assert (DECL_CONV_FN_P (decl2));
args1 = tree_cons (NULL_TREE, TREE_TYPE (TREE_TYPE (decl1)), args1);
args2 = tree_cons (NULL_TREE, TREE_TYPE (TREE_TYPE (decl2)), args2);
len++;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 612dcab5895..7191f88e7df 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2005-04-03 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/20723
+ * g++.dg/template/spec22.C: New.
+ * g++.dg/template/spec23.C: New.
+
2005-04-03 Dale Ranta <dir@lanl.gov>
Francois-Xavier Coudert <coudert@clipper.ens.fr>
diff --git a/gcc/testsuite/g++.dg/template/spec22.C b/gcc/testsuite/g++.dg/template/spec22.C
new file mode 100644
index 00000000000..e2d439c9252
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/spec22.C
@@ -0,0 +1,22 @@
+// Copyright (C) 2005 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 2 Apr 2005 <nathan@codesourcery.com>
+
+// PR 20723
+// Origin: Andrew Pinski <pinskia@gcc.gnu.org>
+// Nathan Sidwell <nathan@gcc.gnu.org>
+
+template <typename T>
+int operator+ (T const &, int); // { dg-error "T = Foo" "" }
+
+struct Foo
+{
+ template <typename T>
+ int operator+ (T) const; // { dg-error "T = int" "" }
+};
+
+int main ()
+{
+ Foo f;
+
+ return f + 0; // { dg-error "ambiguous overload" "" }
+}
diff --git a/gcc/testsuite/g++.dg/template/spec23.C b/gcc/testsuite/g++.dg/template/spec23.C
new file mode 100644
index 00000000000..15618b10b51
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/spec23.C
@@ -0,0 +1,25 @@
+// Copyright (C) 2005 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 2 Apr 2005 <nathan@codesourcery.com>
+
+// PR 20723
+// Origin: Andrew Pinski <pinskia@gcc.gnu.org>
+// Nathan Sidwell <nathan@gcc.gnu.org>
+
+struct Foo
+{
+ template <typename T>
+ Foo (const T &); // { dg-error "T = Bar" "" }
+};
+
+struct Bar
+{
+ template <typename T>
+ operator T () const; // { dg-error "T = Foo" "" }
+};
+
+Foo Quux (Bar const &b)
+{
+ return b; // { dg-error "ambiguous overload" "" }
+}
+
+
OpenPOWER on IntegriCloud