Commit e5214479 by Jason Merrill Committed by Jason Merrill

In partial ordering for a call, ignore parms for which we don't have a real argument.

        In partial ordering for a call, ignore parms for which we don't have
        a real argument.
        * call.c (joust): Pass len to more_specialized.
        (add_template_candidate_real): Strip 'this', pass len.
        * pt.c (more_specialized): Pass len down.  Lose explicit_args parm.
        (get_bindings_order): New fn.  Pass len down.
        (get_bindings_real): Strip 'this', pass len.
        (fn_type_unification): Likewise.
        (type_unification_real): Succeed after checking 'len' args.
        (most_specialized_instantiation): Lose explicit_args parm.
        * class.c (resolve_address_of_overloaded_function): Strip 'this',
        pass len.

From-SVN: r38460
parent 83ab3907
2000-12-20 Jason Merrill <jason@redhat.com>
2000-12-22 Jason Merrill <jason@redhat.com>
In partial ordering for a call, ignore parms for which we don't have
a real argument.
* call.c (joust): Pass len to more_specialized.
(add_template_candidate_real): Strip 'this', pass len.
* pt.c (more_specialized): Pass len down. Lose explicit_args parm.
(get_bindings_order): New fn. Pass len down.
(get_bindings_real): Strip 'this', pass len.
(fn_type_unification): Likewise.
(type_unification_real): Succeed after checking 'len' args.
(most_specialized_instantiation): Lose explicit_args parm.
* class.c (resolve_address_of_overloaded_function): Strip 'this',
pass len.
2000-12-21 Jason Merrill <jason@redhat.com>
* pt.c (tsubst_decl): A FUNCTION_DECL has DECL_RESULT, not
DECL_TEMPLATE_RESULT.
......
......@@ -2147,26 +2147,24 @@ add_template_candidate_real (candidates, tmpl, ctype, explicit_targs,
{
int ntparms = DECL_NTPARMS (tmpl);
tree targs = make_tree_vec (ntparms);
tree args_without_in_chrg;
tree args_without_in_chrg = arglist;
struct z_candidate *cand;
int i;
tree fn;
/* TEMPLATE_DECLs do not have the in-charge parameter, nor the VTT
parameter. So, skip it here before attempting to perform
argument deduction. */
/* We don't do deduction on the in-charge parameter, the VTT
parameter or 'this'. */
if (DECL_NONSTATIC_MEMBER_FUNCTION_P (tmpl))
args_without_in_chrg = TREE_CHAIN (args_without_in_chrg);
if ((DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (tmpl)
|| DECL_BASE_CONSTRUCTOR_P (tmpl))
&& TYPE_USES_VIRTUAL_BASECLASSES (DECL_CONTEXT (tmpl)))
args_without_in_chrg = tree_cons (NULL_TREE,
TREE_VALUE (arglist),
TREE_CHAIN (TREE_CHAIN (arglist)));
else
args_without_in_chrg = arglist;
args_without_in_chrg = TREE_CHAIN (args_without_in_chrg);
i = fn_type_unification (tmpl, explicit_targs, targs,
args_without_in_chrg,
return_type, strict);
return_type, strict, -1);
if (i != 0)
return candidates;
......@@ -5156,7 +5154,8 @@ joust (cand1, cand2, warn)
else if (cand1->template && cand2->template)
winner = more_specialized
(TI_TEMPLATE (cand1->template), TI_TEMPLATE (cand2->template),
NULL_TREE);
/* Never do unification on the 'this' parameter. */
TREE_VEC_LENGTH (cand1->convs) - !DECL_STATIC_FUNCTION_P (cand1->fn));
/* or, if not that,
the context is an initialization by user-defined conversion (see
......
......@@ -5953,6 +5953,10 @@ resolve_address_of_overloaded_function (target_type,
target_fn_type = TREE_TYPE (target_type);
target_arg_types = TYPE_ARG_TYPES (target_fn_type);
target_ret_type = TREE_TYPE (target_fn_type);
/* Never do unification on the 'this' parameter. */
if (TREE_CODE (target_fn_type) == METHOD_TYPE)
target_arg_types = TREE_CHAIN (target_arg_types);
for (fns = overload; fns; fns = OVL_CHAIN (fns))
{
......@@ -5975,7 +5979,7 @@ resolve_address_of_overloaded_function (target_type,
targs = make_tree_vec (DECL_NTPARMS (fn));
if (fn_type_unification (fn, explicit_targs, targs,
target_arg_types, target_ret_type,
DEDUCE_EXACT) != 0)
DEDUCE_EXACT, -1) != 0)
/* Argument deduction failed. */
continue;
......@@ -5999,8 +6003,7 @@ resolve_address_of_overloaded_function (target_type,
/* Now, remove all but the most specialized of the matches. */
if (matches)
{
tree match = most_specialized_instantiation (matches,
explicit_targs);
tree match = most_specialized_instantiation (matches);
if (match != error_mark_node)
matches = tree_cons (match, NULL_TREE, NULL_TREE);
......
// Test that partial ordering ignores defaulted parms and 'this'.
struct A {
template<class T> int f(T) { return 1; }
template<class T> int f(T*, int=0) { return 0; }
template<class T> int g(T*) { return 0; }
template<class T> static int g(T, int=0) { return 1; }
template<class T> int h(T*) { return 0; }
template<class T> static int h(T, int=0) { return 1; }
template<class T> static int j(T*, short y=0) { return 0; }
template<class T> static int j(T, int=0) { return 1; }
};
int main(void) {
A a;
int *p;
return (a.f(p) || a.g(p) || a.h(p) || a.j(p));
}
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