PATCH:ice981006 (template deduction)

Nathan Sidwell nathan@acm.org
Thu Jan 7 12:47:00 GMT 1999


Nathan Sidwell wrote:
>[patch for ice981006]

oh fart, it clobbered non-overloaded static member functions. Here's a
corrected patch, which doesn't do that. A minor modification on the
previous one, this time lookup_fnfields checks if it's not a static
member function too.

nathan
-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
      You can up the bandwidth, but you can't up the speed of light      
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk
egcs/gcc/cp/ChangeLog:

Wed Jan  6 16:28:13 BST 1999  Nathan Sidwell  <nathan@acm.org>

        * pt.c (resolve_overloaded_unification): Cope with singleton
        overloaded functions.
        * class.c (instantiate_type): Only diagnose illegal address of member
        function if complaining.
        * search.c (lookup_fnfields): Always return an OVERLOAD list for
        non-static, non-dtor member functions.

        * decl.c (lookup_name_real): Remove duplicate code.
							
Index: egcs/gcc/cp/pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.248
diff -c -3 -p -r1.248 pt.c
*** pt.c	1998/12/17 15:08:34	1.248
--- pt.c	1999/01/06 16:15:38
*************** resolve_overloaded_unification (tparms, 
*** 7170,7176 ****
  	    }
  	}
      }
!   else if (TREE_CODE (arg) == OVERLOAD)
      {
        for (; arg; arg = OVL_NEXT (arg))
  	{
--- 7170,7176 ----
  	    }
  	}
      }
!   else if (TREE_CODE (arg) == OVERLOAD || TREE_CODE (arg) == FUNCTION_DECL)
      {
        for (; arg; arg = OVL_NEXT (arg))
  	{
Index: egcs/gcc/cp/class.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/class.c,v
retrieving revision 1.124
diff -c -3 -p -r1.124 class.c
*** class.c	1998/12/16 21:15:07	1.124
--- class.c	1999/01/06 16:16:06
*************** instantiate_type (lhstype, rhs, complain
*** 5312,5330 ****
  
  	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)
  	      {
! 		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");
  	    return error_mark_node;
  	  }
  	
--- 5324,5345 ----
  
  	if (r != error_mark_node && TYPE_PTRMEMFUNC_P (lhstype))
  	  {
! 	    if (complain)
  	      {
! 	        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");
  	      }
  	    return error_mark_node;
  	  }
  	
Index: egcs/gcc/cp/decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.288
diff -c -3 -p -r1.288 decl.c
*** decl.c	1998/12/16 21:15:14	1.288
--- decl.c	1999/01/06 16:17:13
*************** lookup_name_real (name, prefer_type, non
*** 5415,5421 ****
      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)
--- 5417,5422 ----
Index: egcs/gcc/cp/search.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/search.c,v
retrieving revision 1.76
diff -c -3 -p -r1.76 search.c
*** search.c	1998/12/16 21:16:08	1.76
--- search.c	1999/01/06 16:17:16
*************** lookup_fnfields (basetype_path, name, co
*** 1434,1439 ****
--- 1434,1444 ----
    if (idx >= 0)
      {
        rval = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), idx);
+       /* a singleton member function will not be on an overload list, make it
+        * so */
+       if (idx != 1 && TREE_CODE (rval) == FUNCTION_DECL
+           && !DECL_STATIC_FUNCTION_P (rval))
+         rval = scratch_ovl_cons (rval, NULL);
        rvals = scratch_tree_cons (basetype_path, rval, rvals);
        if (BINFO_BASETYPES (binfo) && CLASSTYPE_BASELINK_VEC (type))
  	TREE_TYPE (rvals) = TREE_VEC_ELT (CLASSTYPE_BASELINK_VEC (type), idx);
*************** lookup_fnfields (basetype_path, name, co
*** 1537,1542 ****
--- 1542,1552 ----
  	      if (idx >= 0)
  		{
  		  rval = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), idx);
+                   /* a singleton member function will not be on an overload
+                    * list, make it so */
+                   if (idx != 1 && TREE_CODE (rval) == FUNCTION_DECL
+                       && !DECL_STATIC_FUNCTION_P (rval))
+                     rval = scratch_ovl_cons (rval, NULL);
  		  /* Note, rvals can only be previously set if find_all is
  		     true.  */
  		  rvals = scratch_tree_cons (basetype_path, rval, rvals);


More information about the Gcc-patches mailing list