Commit e6e174e5 by Jason Merrill Committed by Jason Merrill

call.c (standard_conversion): instantiate_type here.

	* call.c (standard_conversion): instantiate_type here.
	(reference_binding): And here.
	(implicit_conversion): Not here.
	(build_op_delete_call): No need to cons up an OVERLOAD.
	* cvt.c (cp_convert_to_pointer): instantiate_type here.
	(convert_to_reference): And here.
	* decl.c (grok_reference_init): Not here.
	(grokparms): Or here.
	* typeck2.c (digest_init): Or here.
	* typeck.c (decay_conversion): Take the address of overloaded
	functions, too.
	(require_instantiated_type): Lose.
	(convert_arguments): Don't handle unknown types here.
	(build_c_cast): Likewise.
	(build_binary_op): Gut.
	(build_conditional_expr): Don't require_instantiated_type.
	(build_modify_expr): Likewise.
	(build_static_cast): Don't instantiate_type.
	(build_reinterpret_cast): Likewise.
	(build_const_cast): Likewise.
	(convert_for_initialization): Likewise.
	(build_ptrmemfunc): Use type_unknown_p.
	(convert_for_assignment): Also do default_conversion on overloaded
	functions.  Hand them off to ocp_convert.
	* pt.c (convert_nontype_argument): Tell instantiate_type to complain.
	Do complain about overload resolution producing a non-public fn.

From-SVN: r23373
parent 950ad3c3
1998-10-27 Jason Merrill <jason@yorick.cygnus.com>
* call.c (standard_conversion): instantiate_type here.
(reference_binding): And here.
(implicit_conversion): Not here.
(build_op_delete_call): No need to cons up an OVERLOAD.
* cvt.c (cp_convert_to_pointer): instantiate_type here.
(convert_to_reference): And here.
* decl.c (grok_reference_init): Not here.
(grokparms): Or here.
* typeck2.c (digest_init): Or here.
* typeck.c (decay_conversion): Take the address of overloaded
functions, too.
(require_instantiated_type): Lose.
(convert_arguments): Don't handle unknown types here.
(build_c_cast): Likewise.
(build_binary_op): Gut.
(build_conditional_expr): Don't require_instantiated_type.
(build_modify_expr): Likewise.
(build_static_cast): Don't instantiate_type.
(build_reinterpret_cast): Likewise.
(build_const_cast): Likewise.
(convert_for_initialization): Likewise.
(build_ptrmemfunc): Use type_unknown_p.
(convert_for_assignment): Also do default_conversion on overloaded
functions. Hand them off to ocp_convert.
* pt.c (convert_nontype_argument): Tell instantiate_type to complain.
Do complain about overload resolution producing a non-public fn.
1998-10-26 Mark Mitchell <mark@markmitchell.com>
* error.c (dump_decl): Deal with TEMPLATE_DECLs that are
......
......@@ -803,6 +803,15 @@ standard_conversion (to, from, expr)
to = strip_top_quals (to);
from = strip_top_quals (from);
if ((TYPE_PTRFN_P (to) || TYPE_PTRMEMFUNC_P (to))
&& expr && type_unknown_p (expr))
{
expr = instantiate_type (to, expr, 0);
if (expr == error_mark_node)
return NULL_TREE;
from = TREE_TYPE (expr);
}
fcode = TREE_CODE (from);
tcode = TREE_CODE (to);
......@@ -968,6 +977,14 @@ reference_binding (rto, rfrom, expr, flags)
tree from = rfrom;
int related;
if (TREE_CODE (to) == FUNCTION_TYPE && expr && type_unknown_p (expr))
{
expr = instantiate_type (to, expr, 0);
if (expr == error_mark_node)
return NULL_TREE;
from = TREE_TYPE (expr);
}
if (TREE_CODE (from) == REFERENCE_TYPE)
from = TREE_TYPE (from);
else if (! expr || ! real_lvalue_p (expr))
......@@ -1032,14 +1049,6 @@ implicit_conversion (to, from, expr, flags)
tree conv;
struct z_candidate *cand;
if (expr && type_unknown_p (expr))
{
expr = instantiate_type (to, expr, 0);
if (expr == error_mark_node)
return 0;
from = TREE_TYPE (expr);
}
if (TREE_CODE (to) == REFERENCE_TYPE)
conv = reference_binding (to, from, expr, flags);
else
......@@ -1049,7 +1058,7 @@ implicit_conversion (to, from, expr, flags)
;
else if (expr != NULL_TREE
&& (IS_AGGR_TYPE (non_reference (from))
|| IS_AGGR_TYPE (non_reference (to)))
|| IS_AGGR_TYPE (non_reference (to)))
&& (flags & LOOKUP_NO_CONVERSION) == 0)
{
cand = build_user_type_conversion_1
......@@ -2907,11 +2916,6 @@ build_op_delete_call (code, addr, size, flags, placement)
if (type != TYPE_MAIN_VARIANT (type))
addr = cp_convert (build_pointer_type (TYPE_MAIN_VARIANT (type)), addr);
/* instantiate_type will always return a plain function; pretend it's
overloaded. */
if (TREE_CODE (fns) == FUNCTION_DECL)
fns = scratch_ovl_cons (fns, NULL_TREE);
fn = instantiate_type (fntype, fns, 0);
if (fn != error_mark_node)
......
......@@ -4968,8 +4968,8 @@ validate_lhs (lhstype, complain)
try many possible instantiations, in hopes that at least one will
work.
This function is used in build_modify_expr, convert_arguments,
build_c_cast, and compute_conversion_costs. */
For non-recursive calls, LHSTYPE should be a function, pointer to
function, or a pointer to member function. */
tree
instantiate_type (lhstype, rhs, complain)
......@@ -5132,8 +5132,8 @@ instantiate_type (lhstype, rhs, complain)
{
if (complain)
cp_error("cannot resolve overloaded function `%D' "
"based on non-function type",
DECL_NAME (OVL_FUNCTION (rhs)));
"based on non-function type `%T'",
DECL_NAME (OVL_FUNCTION (rhs)), lhstype);
return error_mark_node;
}
......
......@@ -3136,7 +3136,6 @@ extern tree complete_type PROTO((tree));
extern tree complete_type_or_else PROTO((tree));
extern int type_unknown_p PROTO((tree));
extern int fntype_p PROTO((tree));
extern tree require_instantiated_type PROTO((tree, tree, tree));
extern tree commonparms PROTO((tree, tree));
extern tree original_type PROTO((tree));
extern tree common_type PROTO((tree, tree));
......
......@@ -249,6 +249,9 @@ cp_convert_to_pointer (type, expr)
return convert_to_pointer (type, expr);
}
if (type_unknown_p (expr))
return instantiate_type (type, expr, 1);
cp_error ("cannot convert `%E' from type `%T' to type `%T'",
expr, intype, type);
return error_mark_node;
......@@ -407,6 +410,12 @@ convert_to_reference (reftype, expr, convtype, flags, decl)
tree rval_as_conversion = NULL_TREE;
int i;
if (TREE_CODE (type) == FUNCTION_TYPE && intype == unknown_type_node)
{
expr = instantiate_type (type, expr, 0);
intype = TREE_TYPE (expr);
}
if (TREE_CODE (intype) == REFERENCE_TYPE)
my_friendly_abort (364);
......
......@@ -6921,10 +6921,6 @@ grok_reference_init (decl, type, init)
return;
}
if (TREE_TYPE (init) && TREE_CODE (TREE_TYPE (init)) == UNKNOWN_TYPE)
/* decay_conversion is probably wrong for references to functions. */
init = decay_conversion (instantiate_type (TREE_TYPE (type), init, 1));
if (TREE_CODE (init) == TREE_LIST)
init = build_compound_expr (init);
......@@ -11146,8 +11142,12 @@ grokparms (first_parm, funcdef_flag)
else if (TREE_READONLY_DECL_P (init))
init = decl_constant_value (init);
}
else
init = require_instantiated_type (type, init, integer_zero_node);
else if (TREE_TYPE (init) == NULL_TREE)
{
error ("argument list may not have an initializer list");
init = error_mark_node;
}
if (! processing_template_decl
&& init != error_mark_node
&& TREE_CODE (init) != DEFAULT_ARG
......
......@@ -2510,7 +2510,7 @@ convert_nontype_argument (type, expr)
else
fns = expr;
fn = instantiate_type (type_pointed_to, fns, 0);
fn = instantiate_type (type_pointed_to, fns, 1);
if (fn == error_mark_node)
return error_mark_node;
......@@ -2567,22 +2567,24 @@ convert_nontype_argument (type, expr)
tree fns = expr;
tree fn;
fn = instantiate_type (type_referred_to, fns, 0);
fn = instantiate_type (type_referred_to, fns, 1);
if (fn == error_mark_node)
return error_mark_node;
if (!TREE_PUBLIC (fn))
{
#if 0
if (really_overloaded_fn (fns))
/* Don't issue an error here; we might get a different
function if the overloading had worked out
differently. */
return error_mark_node;
else
#endif
goto bad_argument;
}
if (fn == error_mark_node)
return error_mark_node;
my_friendly_assert (comptypes (type_referred_to, TREE_TYPE (fn), 1),
0);
......@@ -2646,7 +2648,7 @@ convert_nontype_argument (type, expr)
fns = TREE_OPERAND (expr, 0);
fn = instantiate_type (TREE_TYPE (TREE_TYPE (type)),
fns, 0);
fns, 1);
if (fn == error_mark_node)
return error_mark_node;
......
......@@ -646,13 +646,6 @@ store_init_value (decl, init)
else
init = TREE_VALUE (init);
}
else if (TREE_TYPE (init) != 0
&& TREE_CODE (TREE_TYPE (init)) == OFFSET_TYPE)
{
/* Use the type of our variable to instantiate
the type of our initializer. */
init = instantiate_type (type, init, 1);
}
else if (TREE_CODE (init) == TREE_LIST
&& TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
{
......
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