mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-08 15:42:07 +08:00
re PR c++/31419 (template user defined conversion operator instantiated for conversion to self)
PR c++/31419 * call.c (reference_binding): Don't look for user-defined conversions to the same type. From-SVN: r128102
This commit is contained in:
parent
4aeb38965b
commit
9380ed8466
@ -1,5 +1,9 @@
|
||||
2007-09-04 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/31419
|
||||
* call.c (reference_binding): Don't look for user-defined conversions
|
||||
to the same type.
|
||||
|
||||
PR c++/31411
|
||||
* except.c (initialize_handler_parm): Put a CLEANUP_POINT_EXPR inside
|
||||
the MUST_NOT_THROW_EXPR.
|
||||
|
@ -1200,7 +1200,12 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
|
||||
|
||||
return conv;
|
||||
}
|
||||
else if (CLASS_TYPE_P (from) && !(flags & LOOKUP_NO_CONVERSION))
|
||||
/* [class.conv.fct] A conversion function is never used to convert a
|
||||
(possibly cv-qualified) object to the (possibly cv-qualified) same
|
||||
object type (or a reference to it), to a (possibly cv-qualified) base
|
||||
class of that type (or a reference to it).... */
|
||||
else if (CLASS_TYPE_P (from) && !related_p
|
||||
&& !(flags & LOOKUP_NO_CONVERSION))
|
||||
{
|
||||
/* [dcl.init.ref]
|
||||
|
||||
|
15
gcc/testsuite/g++.dg/conversion/self1.C
Normal file
15
gcc/testsuite/g++.dg/conversion/self1.C
Normal file
@ -0,0 +1,15 @@
|
||||
// PR c++/31419
|
||||
|
||||
struct B
|
||||
{
|
||||
template<typename T>
|
||||
operator T const& () const
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
};
|
||||
|
||||
B f()
|
||||
{
|
||||
return B();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user