init.c (build_offset_ref): Wrap baselinks in OFFSET_REF, too.

* init.c (build_offset_ref): Wrap baselinks in OFFSET_REF, too.
	Don't bother wrapping an OFFSET_TYPE around unknown_type_node.
	(resolve_offset_ref): Don't handle a raw baselink.
	* cvt.c (build_expr_type_conversion): Likewise.
	* typeck.c (decay_conversion, build_c_cast, convert_for_assignment,
	convert_for_initialization): Likewise.
	* class.c (instantiate_type): Handle seeing a baselink under an
	OFFSET_REF.
	* error.c (dump_expr): Likewise.
	* pt.c (for_each_template_parm): Likewise.
	(resolve_overloaded_unification): Likewise.
	* tree.c (is_overloaded_fn, really_overloaded_fn): Likewise.
	* typeck.c (expr_sizeof): Also complain about other permutations
	of overloaded functions.

From-SVN: r26861
This commit is contained in:
Jason Merrill 1999-05-10 12:12:58 +00:00 committed by Jason Merrill
parent 0ca40216d7
commit 05e0b2f47c
9 changed files with 63 additions and 25 deletions

View File

@ -1,3 +1,20 @@
1999-05-10 Jason Merrill <jason@yorick.cygnus.com>
* init.c (build_offset_ref): Wrap baselinks in OFFSET_REF, too.
Don't bother wrapping an OFFSET_TYPE around unknown_type_node.
(resolve_offset_ref): Don't handle a raw baselink.
* cvt.c (build_expr_type_conversion): Likewise.
* typeck.c (decay_conversion, build_c_cast, convert_for_assignment,
convert_for_initialization): Likewise.
* class.c (instantiate_type): Handle seeing a baselink under an
OFFSET_REF.
* error.c (dump_expr): Likewise.
* pt.c (for_each_template_parm): Likewise.
(resolve_overloaded_unification): Likewise.
* tree.c (is_overloaded_fn, really_overloaded_fn): Likewise.
* typeck.c (expr_sizeof): Also complain about other permutations
of overloaded functions.
1999-05-07 Jason Merrill <jason@yorick.cygnus.com>
* init.c (resolve_offset_ref): Don't return a raw method.

View File

@ -5004,11 +5004,14 @@ instantiate_type (lhstype, rhs, flags)
}
case OFFSET_REF:
rhs = TREE_OPERAND (rhs, 1);
if (BASELINK_P (rhs))
return instantiate_type (lhstype, TREE_VALUE (rhs), flags);
/* This can happen if we are forming a pointer-to-member for a
member template. */
rhs = TREE_OPERAND (rhs, 1);
my_friendly_assert (TREE_CODE (rhs) == TEMPLATE_ID_EXPR, 0);
/* Fall through. */
case TEMPLATE_ID_EXPR:

View File

@ -976,7 +976,7 @@ build_expr_type_conversion (desires, expr, complain)
&& !(desires & WANT_NULL))
cp_warning ("converting NULL to non-pointer type");
if (TREE_CODE (expr) == OFFSET_REF || BASELINK_P (expr))
if (TREE_CODE (expr) == OFFSET_REF)
expr = resolve_offset_ref (expr);
expr = convert_from_reference (expr);
basetype = TREE_TYPE (expr);

View File

@ -4772,6 +4772,8 @@ arg_assoc (k, n)
n = TREE_OPERAND (n, 0);
if (TREE_CODE (n) == COMPONENT_REF)
n = TREE_OPERAND (n, 1);
if (TREE_CODE (n) == OFFSET_REF)
n = TREE_OPERAND (n, 1);
while (TREE_CODE (n) == TREE_LIST)
n = TREE_VALUE (n);

View File

@ -1680,11 +1680,14 @@ dump_expr (t, nop)
tree ob = TREE_OPERAND (t, 0);
if (is_dummy_object (ob))
{
if (TREE_CODE (TREE_OPERAND (t, 1)) == FUNCTION_DECL)
t = TREE_OPERAND (t, 1);
if (TREE_CODE (t) == FUNCTION_DECL)
/* A::f */
dump_expr (TREE_OPERAND (t, 1), 0);
dump_expr (t, 0);
else if (BASELINK_P (t))
dump_expr (OVL_CURRENT (TREE_VALUE (t)), 0);
else
dump_decl (TREE_OPERAND (t, 1), 0);
dump_decl (t, 0);
}
else
{

View File

@ -1604,7 +1604,7 @@ build_offset_ref (type, name)
t = ovl_cons (t, NULL_TREE);
return build (OFFSET_REF,
build_offset_type (type, unknown_type_node),
unknown_type_node,
decl,
build (TEMPLATE_ID_EXPR,
TREE_TYPE (t),
@ -1638,8 +1638,8 @@ build_offset_ref (type, name)
&& ! allocation_temporary_p ())
fnfields = copy_list (fnfields);
TREE_TYPE (fnfields) = build_offset_type (type, unknown_type_node);
return fnfields;
TREE_TYPE (fnfields) = unknown_type_node;
return build (OFFSET_REF, unknown_type_node, decl, fnfields);
}
t = member;
@ -1692,12 +1692,6 @@ resolve_offset_ref (exp)
tree member;
tree basetype, addr;
if (BASELINK_P (exp))
{
cp_pedwarn ("assuming & on overloaded member function");
return build_unary_op (ADDR_EXPR, exp, 0);
}
if (TREE_CODE (exp) == OFFSET_REF)
{
member = TREE_OPERAND (exp, 1);
@ -1716,6 +1710,18 @@ resolve_offset_ref (exp)
base = current_class_ref;
}
if (BASELINK_P (member))
{
cp_pedwarn ("assuming & on overloaded member function");
return build_unary_op (ADDR_EXPR, exp, 0);
}
if (TREE_CODE (TREE_TYPE (member)) == METHOD_TYPE)
{
cp_pedwarn ("assuming & on `%E'", member);
return build_unary_op (ADDR_EXPR, exp, 0);
}
if ((TREE_CODE (member) == VAR_DECL
&& ! TYPE_PTRMEMFUNC_P (TREE_TYPE (member))
&& ! TYPE_PTRMEM_P (TREE_TYPE (member)))
@ -1727,12 +1733,6 @@ resolve_offset_ref (exp)
return member;
}
if (TREE_CODE (TREE_TYPE (member)) == METHOD_TYPE)
{
cp_pedwarn ("assuming & on `%E'", member);
return build_unary_op (ADDR_EXPR, exp, 0);
}
if (TREE_CODE (TREE_TYPE (member)) == POINTER_TYPE
&& TREE_CODE (TREE_TYPE (TREE_TYPE (member))) == METHOD_TYPE)
return member;

View File

@ -4030,6 +4030,7 @@ for_each_template_parm (t, fn, data)
return for_each_template_parm (TREE_TYPE (t), fn, data);
case ARRAY_REF:
case OFFSET_REF:
return (for_each_template_parm (TREE_OPERAND (t, 0), fn, data)
|| for_each_template_parm (TREE_OPERAND (t, 1), fn, data));
@ -7662,6 +7663,9 @@ resolve_overloaded_unification (tparms, targs, parm, arg, strict,
function name. */
arg = TREE_OPERAND (arg, 1);
if (TREE_CODE (arg) == OFFSET_REF)
arg = TREE_OPERAND (arg, 1);
/* Strip baselink information. */
while (TREE_CODE (arg) == TREE_LIST)
arg = TREE_VALUE (arg);

View File

@ -1224,6 +1224,8 @@ is_overloaded_fn (x)
tree x;
{
/* A baselink is also considered an overloaded function. */
if (TREE_CODE (x) == OFFSET_REF)
x = TREE_OPERAND (x, 1);
if (BASELINK_P (x))
x = TREE_VALUE (x);
return (TREE_CODE (x) == FUNCTION_DECL
@ -1237,6 +1239,8 @@ really_overloaded_fn (x)
tree x;
{
/* A baselink is also considered an overloaded function. */
if (TREE_CODE (x) == OFFSET_REF)
x = TREE_OPERAND (x, 1);
if (BASELINK_P (x))
x = TREE_VALUE (x);
return (TREE_CODE (x) == OVERLOAD

View File

@ -1638,6 +1638,11 @@ expr_sizeof (e)
pedwarn ("ANSI C++ forbids taking the sizeof a function type");
return size_int (1);
}
else if (type_unknown_p (e))
{
incomplete_type_error (e, TREE_TYPE (e));
return size_int (1);
}
return c_sizeof (TREE_TYPE (e));
}
@ -1717,7 +1722,7 @@ decay_conversion (exp)
register tree type;
register enum tree_code code;
if (TREE_CODE (exp) == OFFSET_REF || BASELINK_P (exp))
if (TREE_CODE (exp) == OFFSET_REF)
exp = resolve_offset_ref (exp);
type = TREE_TYPE (exp);
@ -5731,7 +5736,7 @@ build_c_cast (type, expr)
&& TREE_TYPE (value) == TREE_TYPE (TREE_OPERAND (value, 0)))
value = TREE_OPERAND (value, 0);
if (TREE_CODE (value) == OFFSET_REF || BASELINK_P (value))
if (TREE_CODE (value) == OFFSET_REF)
value = resolve_offset_ref (value);
if (TREE_CODE (type) == ARRAY_TYPE)
@ -6703,7 +6708,7 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum)
if (codel == OFFSET_TYPE)
my_friendly_abort (990505);
if (TREE_CODE (rhs) == OFFSET_REF || BASELINK_P (rhs))
if (TREE_CODE (rhs) == OFFSET_REF)
rhs = resolve_offset_ref (rhs);
/* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
@ -7133,7 +7138,7 @@ convert_for_initialization (exp, type, rhs, flags, errtype, fndecl, parmnum)
|| (TREE_CODE (rhs) == TREE_LIST && TREE_VALUE (rhs) == error_mark_node))
return error_mark_node;
if (TREE_CODE (rhs) == OFFSET_REF || BASELINK_P (rhs))
if (TREE_CODE (rhs) == OFFSET_REF)
{
rhs = resolve_offset_ref (rhs);
if (rhs == error_mark_node)