typeck.c (build_component_ref): Wrap an OVERLOAD around a unique non-static member...
authorJason Merrill <jason@gcc.gnu.org>
Mon, 18 Jan 1999 14:07:32 +0000 (09:07 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 18 Jan 1999 14:07:32 +0000 (09:07 -0500)
* 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
gcc/cp/class.c
gcc/cp/decl.c
gcc/cp/typeck.c

index 9e1a1d8b2f1cb26a258038ac44112259a5c46e44..143ce6c04bc61424e38b1cb70b367202afdbbe55 100644 (file)
@@ -1,3 +1,15 @@
+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.
index 622f079219aac48e75b26395d73283c09dc2e343..2e6022bc7028a1d88147f6795de338998ad1ae91 100644 (file)
@@ -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;
          }
        
index 13c11bfcba7f6ae97482f8d2eb5485fd327c3002..bb2ef729f3ca96dff49097f611e34a0400b500b1 100644 (file)
@@ -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)
index 662cb500c363ac628f15fa7540bdb5a152bb3aa4..9882f764345f207d514cb31633deb81ca8c33ae5 100644 (file)
@@ -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);