Commit b0385db8 by Mark Mitchell Committed by Mark Mitchell

call.c (reference_binding): Tweak.

	* call.c (reference_binding): Tweak.
	(mayble_handle_implicit_object): Use direct_reference_binding to
	create the right implicit conversion sequence.

From-SVN: r28228
parent ed0e6530
1999-07-23 Mark Mitchell <mark@codesourcery.com>
* call.c (reference_binding): Tweak.
(mayble_handle_implicit_object): Use direct_reference_binding to
create the right implicit conversion sequence.
1999-07-22 Mark Mitchell <mark@codesourcery.com> 1999-07-22 Mark Mitchell <mark@codesourcery.com>
* pt.c (convert_nontype_argument): Don't call decl_constant_value * pt.c (convert_nontype_argument): Don't call decl_constant_value
......
...@@ -1005,9 +1005,6 @@ reference_binding (rto, rfrom, expr, flags) ...@@ -1005,9 +1005,6 @@ reference_binding (rto, rfrom, expr, flags)
from = TREE_TYPE (expr); from = TREE_TYPE (expr);
} }
related_p = reference_related_p (to, from);
compatible_p = reference_compatible_p (to, from);
if (TREE_CODE (from) == REFERENCE_TYPE) if (TREE_CODE (from) == REFERENCE_TYPE)
{ {
/* Anything with reference type is an lvalue. */ /* Anything with reference type is an lvalue. */
...@@ -1017,6 +1014,12 @@ reference_binding (rto, rfrom, expr, flags) ...@@ -1017,6 +1014,12 @@ reference_binding (rto, rfrom, expr, flags)
else if (expr) else if (expr)
lvalue_p = real_lvalue_p (expr); lvalue_p = real_lvalue_p (expr);
/* Figure out whether or not the types are reference-related and
reference compatible. We have do do this after stripping
references from FROM. */
related_p = reference_related_p (to, from);
compatible_p = reference_compatible_p (to, from);
if (lvalue_p && compatible_p) if (lvalue_p && compatible_p)
{ {
/* [dcl.init.ref] /* [dcl.init.ref]
...@@ -3975,15 +3978,20 @@ maybe_handle_implicit_object (ics) ...@@ -3975,15 +3978,20 @@ maybe_handle_implicit_object (ics)
member and cv is the cv-qualification on the member member and cv is the cv-qualification on the member
function declaration. */ function declaration. */
tree t = *ics; tree t = *ics;
tree reference_type;
/* The `this' parameter is a pointer to a class type. Make the
implict conversion talk about a reference to that same class
type. */
reference_type = TREE_TYPE (TREE_TYPE (*ics));
reference_type = build_reference_type (reference_type);
if (TREE_CODE (t) == QUAL_CONV) if (TREE_CODE (t) == QUAL_CONV)
t = TREE_OPERAND (t, 0); t = TREE_OPERAND (t, 0);
if (TREE_CODE (t) == PTR_CONV) if (TREE_CODE (t) == PTR_CONV)
t = TREE_OPERAND (t, 0); t = TREE_OPERAND (t, 0);
t = build1 (IDENTITY_CONV, TREE_TYPE (TREE_TYPE (t)), NULL_TREE); t = build1 (IDENTITY_CONV, TREE_TYPE (TREE_TYPE (t)), NULL_TREE);
t = build_conv (REF_BIND, t = direct_reference_binding (reference_type, t);
build_reference_type (TREE_TYPE (TREE_TYPE (*ics))),
t);
ICS_STD_RANK (t) = ICS_STD_RANK (*ics);
*ics = t; *ics = t;
} }
} }
......
// Build don't link:
// Origin: Jason Merrill <jason@cygnus.com>
struct A {
virtual A& f();
};
struct B: public A {
B& f();
};
// Build don't link:
// Origin: Jason Merrill <jason@cygnus.com>
struct A {
int operator * ();
};
struct B : public A { };
int operator * (B &);
int main ()
{
B b;
B& br = b;
*br;
}
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