aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mmitchell@usa.net>1998-02-02 23:44:19 +0000
committerJason Merrill <jason@gcc.gnu.org>1998-02-02 18:44:19 -0500
commitd7684f2df80bbec945f9b30a49cca3c63ba17bc9 (patch)
tree8fe89150ee3c7beab64f1ebf5927ec31aadea9ce
parent15f05b455062073ff64d905bfbb497616db34cdd (diff)
downloadgcc-d7684f2df80bbec945f9b30a49cca3c63ba17bc9.zip
gcc-d7684f2df80bbec945f9b30a49cca3c63ba17bc9.tar.gz
gcc-d7684f2df80bbec945f9b30a49cca3c63ba17bc9.tar.bz2
call.c (add_template_candidate_real): Pass extra parameter to fn_type_unification.
* call.c (add_template_candidate_real): Pass extra parameter to fn_type_unification. * cp-tree.h (fn_type_unification): Add parameter. * pt.c (fn_type_unification): Add additional parameter to deal with static member functions. (get_bindings): Deal with static member functions. From-SVN: r17609
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/call.c2
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/pt.c47
4 files changed, 48 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 37ed5de..b4a8803 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,12 @@
Mon Feb 2 11:24:22 1998 Mark Mitchell <mmitchell@usa.net>
+ * call.c (add_template_candidate_real): Pass extra parameter to
+ fn_type_unification.
+ * cp-tree.h (fn_type_unification): Add parameter.
+ * pt.c (fn_type_unification): Add additional parameter to deal with
+ static member functions.
+ (get_bindings): Deal with static member functions.
+
* cp-tree.h (DECL_NONSTATIC_MEMBER_FUNCTION_P): New macro.
(revert_static_member_fn): Declare.
* decl.c (revert_static_member_fn): Remove declaration. Change
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index d97f861..18eeb82 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -4176,7 +4176,7 @@ add_template_candidate_real (candidates, tmpl, explicit_targs,
tree fn;
i = fn_type_unification (tmpl, explicit_targs, targs, arglist,
- return_type, 0);
+ return_type, 0, NULL_TREE);
if (i != 0)
return candidates;
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index fc3bc18..6973e66 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -2353,7 +2353,7 @@ extern int uses_template_parms PROTO((tree));
extern tree instantiate_class_template PROTO((tree));
extern tree instantiate_template PROTO((tree, tree));
extern void overload_template_name PROTO((tree));
-extern int fn_type_unification PROTO((tree, tree, tree, tree, tree, int));
+extern int fn_type_unification PROTO((tree, tree, tree, tree, tree, int, tree));
extern int type_unification PROTO((tree, tree *, tree, tree, tree, int *, int, int));
struct tinst_level *tinst_for_decl PROTO((void));
extern void mark_decl_instantiated PROTO((tree, int));
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 6c3508f..780462a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -4599,13 +4599,17 @@ overload_template_name (type)
pushdecl_class_level (decl);
}
+
/* Like type_unification but designed specially to handle conversion
- operators. */
+ operators. The EXTRA_FN_ARG, if any, is the type of an additional
+ parameter to be added to the beginning of FN's parameter list. */
int
-fn_type_unification (fn, explicit_targs, targs, args, return_type, strict)
+fn_type_unification (fn, explicit_targs, targs, args, return_type,
+ strict, extra_fn_arg)
tree fn, explicit_targs, targs, args, return_type;
int strict;
+ tree extra_fn_arg;
{
int i, dummy = 0;
tree fn_arg_types = TYPE_ARG_TYPES (TREE_TYPE (fn));
@@ -4618,13 +4622,17 @@ fn_type_unification (fn, explicit_targs, targs, args, return_type, strict)
/* This is a template conversion operator. Use the return types
as well as the argument types. */
fn_arg_types = scratch_tree_cons (NULL_TREE,
- TREE_TYPE (TREE_TYPE (fn)),
- fn_arg_types);
+ TREE_TYPE (TREE_TYPE (fn)),
+ fn_arg_types);
decl_arg_types = scratch_tree_cons (NULL_TREE,
- return_type,
- decl_arg_types);
+ return_type,
+ decl_arg_types);
}
+ if (extra_fn_arg != NULL_TREE)
+ fn_arg_types = scratch_tree_cons (NULL_TREE, extra_fn_arg,
+ fn_arg_types);
+
i = type_unification (DECL_INNERMOST_TEMPLATE_PARMS (fn),
&TREE_VEC_ELT (targs, 0),
fn_arg_types,
@@ -5261,12 +5269,35 @@ get_bindings (fn, decl, explicit_args)
{
int ntparms = DECL_NTPARMS (fn);
tree targs = make_scratch_vec (ntparms);
+ tree decl_arg_types = TYPE_ARG_TYPES (TREE_TYPE (decl));
+ tree extra_fn_arg = NULL_TREE;
int i;
+ if (DECL_STATIC_FUNCTION_P (fn)
+ && DECL_NONSTATIC_MEMBER_FUNCTION_P (decl))
+ {
+ /* Sometimes we are trying to figure out what's being
+ specialized by a declaration that looks like a method, and it
+ turns out to be a static member function. */
+ if (CLASSTYPE_TEMPLATE_INFO (DECL_REAL_CONTEXT (fn))
+ && !is_member_template (fn))
+ /* The natural thing to do here seems to be to remove the
+ spurious `this' parameter from the DECL, but that prevents
+ unification from making use of the class type. So,
+ instead, we have fn_type_unification add to the parameters
+ for FN. */
+ extra_fn_arg = build_pointer_type (DECL_REAL_CONTEXT (fn));
+ else
+ /* In this case, though, adding the extra_fn_arg can confuse
+ things, so we remove from decl_arg_types instead. */
+ decl_arg_types = TREE_CHAIN (decl_arg_types);
+ }
+
i = fn_type_unification (fn, explicit_args, targs,
- TYPE_ARG_TYPES (TREE_TYPE (decl)),
+ decl_arg_types,
TREE_TYPE (TREE_TYPE (decl)),
- 1);
+ 1,
+ extra_fn_arg);
if (i == 0)
{