re PR c++/20723 (ICE in more_specialized_fn, more than one user-defined conversion "srp<int>" to "ptr<int>")

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.

From-SVN: r97489
This commit is contained in:
Nathan Sidwell 2005-04-03 12:33:02 +00:00 committed by Nathan Sidwell
parent 00b28cb030
commit ee307009db
5 changed files with 68 additions and 2 deletions

View File

@ -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

View File

@ -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++;

View File

@ -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>

View File

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

View File

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