aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2005-04-01 08:29:50 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2005-04-01 08:29:50 +0000
commita34d33361e9fd3e7d6c1eae05484b4ee381b0caa (patch)
tree786304f7491132f451b00dd2f37be9afeba859b9
parent40ce6bf64841651b0d9dc4a686246b4a828a613a (diff)
downloadgcc-a34d33361e9fd3e7d6c1eae05484b4ee381b0caa.zip
gcc-a34d33361e9fd3e7d6c1eae05484b4ee381b0caa.tar.gz
gcc-a34d33361e9fd3e7d6c1eae05484b4ee381b0caa.tar.bz2
call.c (add_template_candidates_real): Remove length parameter from fn_type_unification call.
* call.c (add_template_candidates_real): Remove length parameter from fn_type_unification call. * class.c (resolve_address_of_overloaded_function): Likewise * cp-tree.h (fn_type_unification): Remove length parameter. * pt.c (get_bindings_overload): Remove. (get_bindings_real): Rename to ... (get_bindings): ... here. Remove length and strict parameters. Change return type flag to boolean. Remove original forwarding function. (determine_specialization): Adjust get_bindings call. (fn_type_unification): Remove length parameter. Adjust. (type_unification_real): Remove length parameter. Adjust. (resolve_overloaded_unification): Adjust get_bindings call. (try_one_overload): Simplify confusing cascaded if control flow. (unify): Remove length paramter from type_unification_real call. (most_specialized_instantiation): Adjust get_bindings calls. (most_specialized): Likewise. From-SVN: r97379
-rw-r--r--gcc/cp/ChangeLog20
-rw-r--r--gcc/cp/call.c2
-rw-r--r--gcc/cp/class.c2
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/pt.c135
5 files changed, 65 insertions, 96 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 93c7170..4065f17 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,23 @@
+2005-04-01 Nathan Sidwell <nathan@codesourcery.com>
+
+ * call.c (add_template_candidates_real): Remove length parameter
+ from fn_type_unification call.
+ * class.c (resolve_address_of_overloaded_function): Likewise
+ * cp-tree.h (fn_type_unification): Remove length parameter.
+ * pt.c (get_bindings_overload): Remove.
+ (get_bindings_real): Rename to ...
+ (get_bindings): ... here. Remove length and strict
+ parameters. Change return type flag to boolean. Remove original
+ forwarding function.
+ (determine_specialization): Adjust get_bindings call.
+ (fn_type_unification): Remove length parameter. Adjust.
+ (type_unification_real): Remove length parameter. Adjust.
+ (resolve_overloaded_unification): Adjust get_bindings call.
+ (try_one_overload): Simplify confusing cascaded if control flow.
+ (unify): Remove length paramter from type_unification_real call.
+ (most_specialized_instantiation): Adjust get_bindings calls.
+ (most_specialized): Likewise.
+
2005-03-31 Nathan Sidwell <nathan@codesourcery.com>
PR c++/19203, implement DR 214
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 9d76276c..7dbb4d6 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -2187,7 +2187,7 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl,
i = fn_type_unification (tmpl, explicit_targs, targs,
args_without_in_chrg,
- return_type, strict, -1);
+ return_type, strict);
if (i != 0)
return NULL;
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index c684e81..df0587e 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5733,7 +5733,7 @@ resolve_address_of_overloaded_function (tree 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, -1) != 0)
+ DEDUCE_EXACT))
/* Argument deduction failed. */
continue;
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 7f4efc3..b83b5dc 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3995,7 +3995,7 @@ extern int uses_template_parms (tree);
extern int uses_template_parms_level (tree, int);
extern tree instantiate_class_template (tree);
extern tree instantiate_template (tree, tree, tsubst_flags_t);
-extern int fn_type_unification (tree, tree, tree, tree, tree, unification_kind_t, int);
+extern int fn_type_unification (tree, tree, tree, tree, tree, unification_kind_t);
extern void mark_decl_instantiated (tree, int);
extern int more_specialized_fn (tree, tree, int);
extern void mark_class_instantiated (tree, int);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index b80faae..f92ce90 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -108,13 +108,12 @@ static tree add_outermost_template_args (tree, tree);
static bool check_instantiated_args (tree, tree, tsubst_flags_t);
static int maybe_adjust_types_for_deduction (unification_kind_t, tree*, tree*);
static int type_unification_real (tree, tree, tree, tree,
- int, unification_kind_t, int, int);
+ int, unification_kind_t, int);
static void note_template_header (int);
static tree convert_nontype_argument_function (tree, tree);
static tree convert_nontype_argument (tree, tree);
static tree convert_template_argument (tree, tree, tree,
tsubst_flags_t, int, tree);
-static tree get_bindings_overload (tree, tree, tree);
static int for_each_template_parm (tree, tree_fn_t, void*,
struct pointer_set_t*);
static tree build_template_parm_index (int, int, int, tree, tree);
@@ -128,8 +127,7 @@ static int template_parm_this_level_p (tree, void *);
static tree tsubst_friend_function (tree, tree);
static tree tsubst_friend_class (tree, tree);
static int can_complete_type_without_circularity (tree);
-static tree get_bindings (tree, tree, tree);
-static tree get_bindings_real (tree, tree, tree, int, int, int);
+static tree get_bindings (tree, tree, tree, bool);
static int template_decl_level (tree);
static int check_cv_quals_for_unify (int, tree, tree);
static tree tsubst_template_arg (tree, tree, tsubst_flags_t, tree);
@@ -1433,7 +1431,7 @@ determine_specialization (tree template_id,
/* See whether this function might be a specialization of this
template. */
- targs = get_bindings (fn, decl, explicit_targs);
+ targs = get_bindings (fn, decl, explicit_targs, /*check_ret=*/true);
if (!targs)
/* We cannot deduce template arguments that when used to
@@ -1532,7 +1530,7 @@ determine_specialization (tree template_id,
tree tmpl = most_specialized (templates, decl, explicit_targs);
if (tmpl && tmpl != error_mark_node)
{
- targs = get_bindings (tmpl, decl, explicit_targs);
+ targs = get_bindings (tmpl, decl, explicit_targs, /*check_ret=*/true);
templates = tree_cons (targs, tmpl, NULL_TREE);
}
}
@@ -9062,13 +9060,7 @@ instantiate_template (tree tmpl, tree targ_ptr, tsubst_flags_t complain)
We are deducing arguments when doing an explicit instantiation
as in [temp.explicit], when determining an explicit specialization
as in [temp.expl.spec], or when taking the address of a function
- template, as in [temp.deduct.funcaddr].
-
- LEN is the number of parms to consider before returning success, or -1
- for all. This is used in partial ordering to avoid comparing parms for
- which no actual argument was passed, since they are not considered in
- overload resolution (and are explicitly excluded from consideration in
- partial ordering in [temp.func.order]/6). */
+ template, as in [temp.deduct.funcaddr]. */
int
fn_type_unification (tree fn,
@@ -9076,8 +9068,7 @@ fn_type_unification (tree fn,
tree targs,
tree args,
tree return_type,
- unification_kind_t strict,
- int len)
+ unification_kind_t strict)
{
tree parms;
tree fntype;
@@ -9148,8 +9139,6 @@ fn_type_unification (tree fn,
/* We've been given a return type to match, prepend it. */
parms = tree_cons (NULL_TREE, TREE_TYPE (fntype), parms);
args = tree_cons (NULL_TREE, return_type, args);
- if (len >= 0)
- ++len;
}
/* We allow incomplete unification without an error message here
@@ -9158,7 +9147,7 @@ fn_type_unification (tree fn,
event. */
result = type_unification_real (DECL_INNERMOST_TEMPLATE_PARMS (fn),
targs, parms, args, /*subr=*/0,
- strict, /*allow_incomplete*/1, len);
+ strict, /*allow_incomplete*/1);
if (result == 0)
/* All is well so far. Now, check:
@@ -9275,8 +9264,7 @@ type_unification_real (tree tparms,
tree xargs,
int subr,
unification_kind_t strict,
- int allow_incomplete,
- int xlen)
+ int allow_incomplete)
{
tree parm, arg;
int i;
@@ -9284,7 +9272,6 @@ type_unification_real (tree tparms,
int sub_strict;
int saw_undeduced = 0;
tree parms, args;
- int len;
gcc_assert (TREE_CODE (tparms) == TREE_VEC);
gcc_assert (xparms == NULL_TREE || TREE_CODE (xparms) == TREE_LIST);
@@ -9310,18 +9297,12 @@ type_unification_real (tree tparms,
gcc_unreachable ();
}
- if (xlen == 0)
- return 0;
-
again:
parms = xparms;
args = xargs;
- len = xlen;
- while (parms
- && parms != void_list_node
- && args
- && args != void_list_node)
+ while (parms && parms != void_list_node
+ && args && args != void_list_node)
{
parm = TREE_VALUE (parms);
parms = TREE_CHAIN (parms);
@@ -9393,25 +9374,20 @@ type_unification_real (tree tparms,
if (unify (tparms, targs, parm, arg, arg_strict))
return 1;
}
-
- /* Are we done with the interesting parms? */
- if (--len == 0)
- goto done;
}
+
/* Fail if we've reached the end of the parm list, and more args
are present, and the parm list isn't variadic. */
if (args && args != void_list_node && parms == void_list_node)
return 1;
/* Fail if parms are left and they don't have default values. */
- if (parms
- && parms != void_list_node
+ if (parms && parms != void_list_node
&& TREE_PURPOSE (parms) == NULL_TREE)
return 1;
- done:
if (!subr)
for (i = 0; i < ntparms; i++)
- if (TREE_VEC_ELT (targs, i) == NULL_TREE)
+ if (!TREE_VEC_ELT (targs, i))
{
tree tparm = TREE_VALUE (TREE_VEC_ELT (tparms, i));
@@ -9428,6 +9404,7 @@ type_unification_real (tree tparms,
error ("incomplete type unification");
return 2;
}
+
return 0;
}
@@ -9485,8 +9462,8 @@ resolve_overloaded_unification (tree tparms,
if (TREE_CODE (fn) != TEMPLATE_DECL)
continue;
- subargs = get_bindings_overload (fn, DECL_TEMPLATE_RESULT (fn),
- expl_subargs);
+ subargs = get_bindings (fn, DECL_TEMPLATE_RESULT (fn),
+ expl_subargs, /*check_ret=*/false);
if (subargs)
{
elem = tsubst (TREE_TYPE (fn), subargs, tf_none, NULL_TREE);
@@ -9583,17 +9560,14 @@ try_one_overload (tree tparms,
tree elt = TREE_VEC_ELT (tempargs, i);
tree oldelt = TREE_VEC_ELT (orig_targs, i);
- if (elt == NULL_TREE)
- continue;
+ if (!elt)
+ /*NOP*/;
else if (uses_template_parms (elt))
- {
- /* Since we're unifying against ourselves, we will fill in template
- args used in the function parm list with our own template parms.
- Discard them. */
- TREE_VEC_ELT (tempargs, i) = NULL_TREE;
- continue;
- }
- else if (oldelt && ! template_args_equal (oldelt, elt))
+ /* Since we're unifying against ourselves, we will fill in
+ template args used in the function parm list with our own
+ template parms. Discard them. */
+ TREE_VEC_ELT (tempargs, i) = NULL_TREE;
+ else if (oldelt && !template_args_equal (oldelt, elt))
return 0;
}
@@ -10254,7 +10228,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict)
return 1;
return type_unification_real (tparms, targs, TYPE_ARG_TYPES (parm),
TYPE_ARG_TYPES (arg), 1,
- DEDUCE_EXACT, 0, -1);
+ DEDUCE_EXACT, 0);
case OFFSET_TYPE:
/* Unify a pointer to member with a pointer to member function, which
@@ -10585,23 +10559,17 @@ more_specialized_class (tree pat1, tree pat2, tree full_args)
/* Return the template arguments that will produce the function signature
DECL from the function template FN, with the explicit template
- arguments EXPLICIT_ARGS. If CHECK_RETTYPE is 1, the return type must
+ arguments EXPLICIT_ARGS. If CHECK_RETTYPE is true, the return type must
also match. Return NULL_TREE if no satisfactory arguments could be
- found. DEDUCE and LEN are passed through to fn_type_unification. */
+ found. */
static tree
-get_bindings_real (tree fn,
- tree decl,
- tree explicit_args,
- int check_rettype,
- int deduce,
- int len)
+get_bindings (tree fn, tree decl, tree explicit_args, bool check_rettype)
{
int ntparms = DECL_NTPARMS (fn);
tree targs = make_tree_vec (ntparms);
tree decl_type;
tree decl_arg_types;
- int i;
/* Substitute the explicit template arguments into the type of DECL.
The call to fn_type_unification will handle substitution into the
@@ -10635,35 +10603,16 @@ get_bindings_real (tree fn,
if (DECL_NONSTATIC_MEMBER_FUNCTION_P (decl))
decl_arg_types = TREE_CHAIN (decl_arg_types);
- i = fn_type_unification (fn, explicit_args, targs,
+ if (fn_type_unification (fn, explicit_args, targs,
decl_arg_types,
(check_rettype || DECL_CONV_FN_P (fn)
? TREE_TYPE (decl_type) : NULL_TREE),
- deduce, len);
-
- if (i != 0)
+ DEDUCE_EXACT))
return NULL_TREE;
return targs;
}
-/* For most uses, we want to check the return type. */
-
-static tree
-get_bindings (tree fn, tree decl, tree explicit_args)
-{
- return get_bindings_real (fn, decl, explicit_args, 1, DEDUCE_EXACT, -1);
-}
-
-/* But for resolve_overloaded_unification, we only care about the parameter
- types. */
-
-static tree
-get_bindings_overload (tree fn, tree decl, tree explicit_args)
-{
- return get_bindings_real (fn, decl, explicit_args, 0, DEDUCE_EXACT, -1);
-}
-
/* Return the innermost template arguments that, when applied to a
template specialization whose innermost template parameters are
TPARMS, and whose specialization arguments are PARMS, yield the
@@ -10721,14 +10670,14 @@ most_specialized_instantiation (tree instantiations)
{
int fate = 0;
- if (get_bindings_real (TREE_VALUE (champ),
- DECL_TEMPLATE_RESULT (TREE_VALUE (fn)),
- NULL_TREE, 0, DEDUCE_EXACT, -1))
+ if (get_bindings (TREE_VALUE (champ),
+ DECL_TEMPLATE_RESULT (TREE_VALUE (fn)),
+ NULL_TREE, /*check_ret=*/false))
fate--;
- if (get_bindings_real (TREE_VALUE (fn),
- DECL_TEMPLATE_RESULT (TREE_VALUE (champ)),
- NULL_TREE, 0, DEDUCE_EXACT, -1))
+ if (get_bindings (TREE_VALUE (fn),
+ DECL_TEMPLATE_RESULT (TREE_VALUE (champ)),
+ NULL_TREE, /*check_ret=*/false))
fate++;
if (fate != 1)
@@ -10745,12 +10694,12 @@ most_specialized_instantiation (tree instantiations)
/* Now verify that champ is better than everything earlier in the
instantiation list. */
for (fn = instantiations; fn != champ; fn = TREE_CHAIN (fn))
- if (get_bindings_real (TREE_VALUE (champ),
- DECL_TEMPLATE_RESULT (TREE_VALUE (fn)),
- NULL_TREE, 0, DEDUCE_EXACT, -1)
- || !get_bindings_real (TREE_VALUE (fn),
- DECL_TEMPLATE_RESULT (TREE_VALUE (champ)),
- NULL_TREE, 0, DEDUCE_EXACT, -1))
+ if (get_bindings (TREE_VALUE (champ),
+ DECL_TEMPLATE_RESULT (TREE_VALUE (fn)),
+ NULL_TREE, /*check_ret=*/false)
+ || !get_bindings (TREE_VALUE (fn),
+ DECL_TEMPLATE_RESULT (TREE_VALUE (champ)),
+ NULL_TREE, /*check_ret=*/false))
{
champ = NULL_TREE;
break;
@@ -10778,7 +10727,7 @@ most_specialized (tree fns, tree decl, tree explicit_args)
{
tree candidate = TREE_VALUE (fn);
- args = get_bindings (candidate, decl, explicit_args);
+ args = get_bindings (candidate, decl, explicit_args, /*check_ret=*/true);
if (args)
candidates = tree_cons (NULL_TREE, candidate, candidates);
}