re PR c++/32756 (wrong ambiguous overload error?)

cp/
	PR c++/32756
	* call.c (maybe_handle_implicit_object): Set this_p, clear
	rvaluedness_matches_p.
	(compare_ics): Do not compare rvaluedness matching when one of the
	operands is an implicit object.

	testsuite/
	PR c++/32756
	* g++.dg/overload/operator3.C: New.

From-SVN: r128528
This commit is contained in:
Nathan Sidwell 2007-09-16 17:26:42 +00:00 committed by Nathan Sidwell
parent ce616dd5ac
commit 0ee3f0a892
4 changed files with 64 additions and 11 deletions

View File

@ -1,3 +1,16 @@
2007-09-16 Nathan Sidwell <nathan@codesourcery.com>
cp/
PR c++/32756
* call.c (maybe_handle_implicit_object): Set this_p, clear
rvaluedness_matches_p.
(compare_ics): Do not compare rvaluedness matching when one of the
operands is an implicit object.
testsuite/
PR c++/32756
* g++.dg/overload/operator3.C: New.
2007-09-14 Jason Merrill <jason@redhat.com>
PR c++/17743, c++/19163

View File

@ -5767,7 +5767,8 @@ maybe_handle_implicit_object (conversion **ics)
t = t->u.next;
t = build_identity_conv (TREE_TYPE (t->type), NULL_TREE);
t = direct_reference_binding (reference_type, t);
t->rvaluedness_matches_p = 1;
t->this_p = 1;
t->rvaluedness_matches_p = 0;
*ics = t;
}
}
@ -6126,18 +6127,21 @@ compare_ics (conversion *ics1, conversion *ics2)
initialized by S2 refers is more cv-qualified than the type to
which the reference initialized by S1 refers */
if (ref_conv1 && ref_conv2
&& same_type_ignoring_top_level_qualifiers_p (to_type1, to_type2))
if (ref_conv1 && ref_conv2)
{
if (ref_conv1->rvaluedness_matches_p
&& !ref_conv2->rvaluedness_matches_p)
return 1;
else if (!ref_conv1->rvaluedness_matches_p
&& ref_conv2->rvaluedness_matches_p)
return -1;
if (!ref_conv1->this_p && !ref_conv2->this_p
&& (TYPE_REF_IS_RVALUE (ref_conv1->type)
!= TYPE_REF_IS_RVALUE (ref_conv2->type)))
{
if (ref_conv1->rvaluedness_matches_p)
return 1;
if (ref_conv2->rvaluedness_matches_p)
return -1;
}
return comp_cv_qualification (TREE_TYPE (ref_conv2->type),
TREE_TYPE (ref_conv1->type));
if (same_type_ignoring_top_level_qualifiers_p (to_type1, to_type2))
return comp_cv_qualification (TREE_TYPE (ref_conv2->type),
TREE_TYPE (ref_conv1->type));
}
/* Neither conversion sequence is better than the other. */

View File

@ -1,3 +1,8 @@
2007-09-16 Nathan Sidwell <nathan@codesourcery.com>
PR c++/32756
* g++.dg/overload/operator3.C: New.
2007-09-16 Richard Sandiford <rsandifo@nildram.co.uk>
* gcc.target/mips/truncate-1.c: New test.

View File

@ -0,0 +1,31 @@
// PR c++/32756
// { dg-do compile }
// bogus overload warning
class QString;
struct QByteArray
{
QByteArray ();
bool operator!= (const QString & s2) const;
};
bool operator!= (const QByteArray & a1, const QByteArray & a2);
struct QString
{
QString ();
QString (const QByteArray & a);
};
QByteArray abbreviation ();
void
fromString ()
{
QByteArray zoneAbbrev;
if (abbreviation () != zoneAbbrev)
{
}
}