From e6f622865f1be3f5db2d521ca2fb28165fd038a6 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 18 Jan 1999 09:07:32 -0500 Subject: [PATCH] typeck.c (build_component_ref): Wrap an OVERLOAD around a unique non-static member function. * typeck.c (build_component_ref): Wrap an OVERLOAD around a unique non-static member function. * class.c (instantiate_type): Only diagnose illegal address of member function if complaining. * decl.c (lookup_name_real): Remove duplicate code. From-SVN: r24750 --- gcc/cp/ChangeLog | 12 ++++++++++++ gcc/cp/class.c | 25 ++++++++++++++----------- gcc/cp/decl.c | 1 - gcc/cp/typeck.c | 34 ++++++++++++++++++++++------------ 4 files changed, 48 insertions(+), 24 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9e1a1d8b2f1..143ce6c04bc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,15 @@ +1999-01-18 Jason Merrill + + * typeck.c (build_component_ref): Wrap an OVERLOAD around a unique + non-static member function. + +1999-01-18 Nathan Sidwell + + * 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 * tree.c (copy_template_template_parm): Use permanent_obstack. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 622f079219a..2e6022bc702 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5325,19 +5325,22 @@ instantiate_type (lhstype, rhs, complain) 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; } diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 13c11bfcba7..bb2ef729f3c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5415,7 +5415,6 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only) 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) diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 662cb500c36..9882f764345 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -2055,21 +2055,31 @@ build_component_ref (datum, component, basetype_path, protect) 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); -- 2.30.2