Commit ee307009 by Nathan Sidwell Committed by Nathan Sidwell

re PR c++/20723 (ICE in more_specialized_fn, more than one user-defined…

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
parent 00b28cb0
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
......
......@@ -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++;
......
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>
......
// 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" "" }
}
// 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" "" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment