+1998-10-28 Jason Merrill <jason@yorick.cygnus.com>
+
+ * call.c (add_function_candidate): Treat conversion functions
+ as coming from the argument's class.
+ * cp-tree.h (DECL_CONV_FN_P): New fn.
+ (DECL_DESTRUCTOR_P): Also check DECL_LANGUAGE.
+ * class.c (add_method): Use DECL_CONV_FN_P.
+ * decl2.c (check_classfn): Likewise.
+ * error.c (dump_function_name): Likewise.
+ (dump_function_decl): Likewise.
+ * pt.c (fn_type_unification): Likewise.
+ * search.c (add_conversions): Likewise.
+
1998-10-27 Jason Merrill <jason@yorick.cygnus.com>
* lex.c (do_identifier): Also generate LOOKUP_EXPR for RESULT_DECL.
if (parmnode == void_list_node)
break;
- else if (parmnode)
- t = implicit_conversion (TREE_VALUE (parmnode), argtype, arg, flags);
+
+ if (parmnode)
+ {
+ tree parmtype = TREE_VALUE (parmnode);
+
+ /* [over.match.funcs] For conversion functions, the function is
+ considered to be a member of the class of the implicit object
+ argument for the purpose of defining the type of the implicit
+ object parameter.
+
+ Since build_over_call ignores the ICS for the `this' parameter,
+ we can just change the parm type. */
+ if (DECL_CONV_FN_P (fn) && i == 0)
+ {
+ parmtype
+ = build_qualified_type (TREE_TYPE (argtype),
+ TYPE_QUALS (TREE_TYPE (parmtype)));
+ parmtype = build_pointer_type (parmtype);
+ }
+
+ t = implicit_conversion (parmtype, argtype, arg, flags);
+ }
else
{
t = build1 (IDENTITY_CONV, argtype, arg);
}
}
- if (IDENTIFIER_TYPENAME_P (DECL_NAME (method)))
+ if (DECL_CONV_FN_P (method))
{
/* Type conversion operators have to come before
ordinary methods; add_conversions depends on this to
for (i = 2; i < len; ++i)
{
tree fn = TREE_VEC_ELT (method_vec, i);
- tree name;
if (!fn)
/* There are no more entries in the vector, so we
can insert the new conversion operator here. */
break;
- name = DECL_NAME (OVL_CURRENT (fn));
- if (!IDENTIFIER_TYPENAME_P (name))
+ if (! DECL_CONV_FN_P (OVL_CURRENT (fn)))
/* We can insert the new function right at the Ith
position. */
break;
/* For FUNCTION_DECLs: nonzero means that this function is a constructor. */
#define DECL_CONSTRUCTOR_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.constructor_attr)
-#define DECL_DESTRUCTOR_P(NODE) (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME(NODE)))
+
+/* There ought to be a better way to find out whether or not something is
+ a destructor. */
+#define DECL_DESTRUCTOR_P(NODE) \
+ (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (NODE)) \
+ && DECL_LANGUAGE (NODE) == lang_cplusplus)
+
+#define DECL_CONV_FN_P(NODE) \
+ (IDENTIFIER_TYPENAME_P (DECL_NAME (NODE)) && TREE_TYPE (DECL_NAME (NODE)))
/* For FUNCTION_DECLs: nonzero means that this function is a constructor
for an object with virtual baseclasses. */
break; /* loser */
}
else if (TREE_CODE (fndecl) == TEMPLATE_DECL
- && IDENTIFIER_TYPENAME_P (DECL_NAME (fndecl))
- && IDENTIFIER_TYPENAME_P (fn_name))
+ && DECL_CONV_FN_P (fndecl)
+ && DECL_CONV_FN_P (function))
/* The method in the class is a member template
conversion operator. We are declaring another
conversion operator. It is possible that even though
if (DECL_STATIC_FUNCTION_P (t))
OB_PUTS ("static ");
- if (! IDENTIFIER_TYPENAME_P (name)
+ if (! DECL_CONV_FN_P (t)
&& ! DECL_CONSTRUCTOR_P (t)
- && ! DESTRUCTOR_NAME_P (name))
+ && ! DECL_DESTRUCTOR_P (t))
{
dump_type_prefix (TREE_TYPE (fntype), 1, 0);
OB_PUTC (' ');
OB_PUTC (')');
- if (v && ! IDENTIFIER_TYPENAME_P (name))
+ if (v && ! DECL_CONV_FN_P (t))
dump_type_suffix (TREE_TYPE (fntype), 1, 0);
if (TREE_CODE (fntype) == METHOD_TYPE)
{
tree name = DECL_NAME (t);
- /* There ought to be a better way to find out whether or not something is
- a destructor. */
- if (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (t))
- && DECL_LANGUAGE (t) == lang_cplusplus)
+ if (DECL_DESTRUCTOR_P (t))
{
OB_PUTC ('~');
dump_decl (name, 0);
}
- else if (IDENTIFIER_TYPENAME_P (name))
+ else if (DECL_CONV_FN_P (t))
{
/* This cannot use the hack that the operator's return
type is stashed off of its name because it may be
parms = TYPE_ARG_TYPES (TREE_TYPE (fn));
- if (IDENTIFIER_TYPENAME_P (DECL_NAME (fn)))
+ if (DECL_CONV_FN_P (fn))
{
/* This is a template conversion operator. Use the return types
as well as the argument types. */
{
tree tmp = TREE_VEC_ELT (method_vec, i);
- if (!tmp
- || !IDENTIFIER_TYPENAME_P (DECL_NAME (OVL_CURRENT (tmp))))
+ if (!tmp || ! DECL_CONV_FN_P (OVL_CURRENT (tmp)))
break;
conversions = scratch_tree_cons (binfo, tmp, conversions);
}