aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@gcc.gnu.org>1999-01-18 09:07:32 -0500
committerJason Merrill <jason@gcc.gnu.org>1999-01-18 09:07:32 -0500
commite6f622865f1be3f5db2d521ca2fb28165fd038a6 (patch)
treeb5e1bae7ad0d95526b10b5fcf213722a2c462da6 /gcc
parent6b9b6b150929c20219227d06a968579480447c6b (diff)
downloadgcc-e6f622865f1be3f5db2d521ca2fb28165fd038a6.zip
gcc-e6f622865f1be3f5db2d521ca2fb28165fd038a6.tar.gz
gcc-e6f622865f1be3f5db2d521ca2fb28165fd038a6.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog12
-rw-r--r--gcc/cp/class.c25
-rw-r--r--gcc/cp/decl.c1
-rw-r--r--gcc/cp/typeck.c34
4 files changed, 48 insertions, 24 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9e1a1d8..143ce6c 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,17 @@
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.
1999-01-18 Kriang Lerdsuwanakij <lerdsuwa@scf-fs.usc.edu>
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 622f079..2e6022b 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 13c11bf..bb2ef72 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 662cb50..9882f76 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);