+1999-01-18 Jason Merrill <jason@yorick.cygnus.com>
+
+ * typeck.c (build_component_ref): Wrap an OVERLOAD around a unique
+ non-static member function.
+
+1999-01-18 Nathan Sidwell <nathan@acm.org>
+
+ * class.c (instantiate_type): Only diagnose illegal address of member
+ function if complaining.
+
+ * decl.c (lookup_name_real): Remove duplicate code.
+
1999-01-18 Jason Merrill <jason@yorick.cygnus.com>
* tree.c (copy_template_template_parm): Use permanent_obstack.
if (r != error_mark_node && TYPE_PTRMEMFUNC_P (lhstype))
{
- tree t = TYPE_PTRMEMFUNC_OBJECT_TYPE (lhstype);
- tree fn = TREE_VALUE (field);
- if (TREE_CODE (fn) == OVERLOAD)
- fn = OVL_FUNCTION (fn);
- if (TREE_CODE (fn) == FUNCTION_DECL)
+ if (complain)
{
- cp_error ("object-dependent reference `%E' can only be used in a call",
- DECL_NAME (fn));
- cp_error (" to form a pointer to member function, say `&%T::%E'",
- t, DECL_NAME (fn));
+ tree t = TYPE_PTRMEMFUNC_OBJECT_TYPE (lhstype);
+ tree fn = TREE_VALUE (field);
+ if (TREE_CODE (fn) == OVERLOAD)
+ fn = OVL_FUNCTION (fn);
+ if (TREE_CODE (fn) == FUNCTION_DECL)
+ {
+ cp_error ("object-dependent reference `%E' can only be used in a call",
+ DECL_NAME (fn));
+ cp_error (" to form a pointer to member function, say `&%T::%E'",
+ t, DECL_NAME (fn));
+ }
+ else
+ cp_error ("object-dependent reference can only be used in a call");
}
- else
- cp_error ("object-dependent reference can only be used in a call");
return error_mark_node;
}
flags = lookup_flags (prefer_type, namespaces_only);
/* First, look in non-namespace scopes. */
- val = IDENTIFIER_BINDING (name);
for (val = IDENTIFIER_BINDING (name); val; val = TREE_CHAIN (val))
{
if (!LOCAL_BINDING_P (val) && nonclass)
now. Otherwise, we have to wait and see what context it is
used in; a component_ref involving a non-static member
function can only be used in a call (expr.ref). */
+
if (TREE_CHAIN (fndecls) == NULL_TREE
- && TREE_CODE (TREE_VALUE (fndecls)) == FUNCTION_DECL
- && DECL_STATIC_FUNCTION_P (TREE_VALUE (fndecls)))
+ && TREE_CODE (TREE_VALUE (fndecls)) == FUNCTION_DECL)
{
- tree fndecl = TREE_VALUE (fndecls);
- enforce_access (TREE_PURPOSE (fndecls), fndecl);
- mark_used (fndecl);
- return fndecl;
- }
- else
- {
- ref = build (COMPONENT_REF, unknown_type_node,
- datum, fndecls);
- return ref;
+ if (DECL_STATIC_FUNCTION_P (TREE_VALUE (fndecls)))
+ {
+ tree fndecl = TREE_VALUE (fndecls);
+ enforce_access (TREE_PURPOSE (fndecls), fndecl);
+ mark_used (fndecl);
+ return fndecl;
+ }
+ else
+ {
+ /* A unique non-static member function. Other parts
+ of the compiler expect something with
+ unknown_type_node to be really overloaded, so
+ let's oblige. */
+ TREE_VALUE (fndecls)
+ = scratch_ovl_cons (TREE_VALUE (fndecls), NULL_TREE);
+ }
}
+
+ ref = build (COMPONENT_REF, unknown_type_node,
+ datum, fndecls);
+ return ref;
}
cp_error ("`%#T' has no member named `%D'", basetype, name);