This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH for templates and method calls



My previous patch still did not completely solve the problem.  I
checked in this version, instead.

-- 
Mark Mitchell 			mark@markmitchell.com
Mark Mitchell Consulting	http://www.markmitchell.com

1998-07-16  Mark Mitchell  <mark@markmitchell.com>

	* semantics.c (finish_object_call_expr): Revert previous change.
	* call.c (build_new_method_call): Likewise.  Instead, convert
	TYPE_DECLs to IDENTIFIERs here, in the presence of templates.

Index: testsuite/g++.old-deja/g++.pt/call1.C
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/testsuite/g++.old-deja/g++.pt/call1.C,v
retrieving revision 1.1
diff -c -p -r1.1 call1.C
*** call1.C	1998/07/16 11:46:41	1.1
--- call1.C	1998/07/17 06:33:45
*************** for_each(const Field& p, IsCompressed, C
*** 11,13 ****
--- 11,15 ----
  {
    return p.IsCompressed();
  }
+ 
+ template bool for_each<int>(const Field& p, IsCompressed, int);
Index: cp/semantics.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/semantics.c,v
retrieving revision 1.16
diff -c -p -r1.16 semantics.c
*** semantics.c	1998/07/16 11:46:41	1.16
--- semantics.c	1998/07/17 06:33:50
*************** finish_object_call_expr (fn, object, arg
*** 922,927 ****
--- 922,946 ----
    tree real_fn = build_component_ref (object, fn, NULL_TREE, 1);
    return finish_call_expr (real_fn, args);
  #else
+   if (TREE_CODE (fn) == TYPE_DECL)
+     {
+       if (processing_template_decl)
+ 	/* This can happen on code like:
+ 
+ 	   class X;
+ 	   template <class T> void f(T t) {
+ 	     t.X();
+ 	   }  
+ 
+ 	   We just grab the underlying IDENTIFIER.  */
+ 	fn = DECL_NAME (fn);
+       else
+ 	{
+ 	  cp_error ("calling type `%T' like a method", fn);
+ 	  return error_mark_node;
+ 	}
+     }
+ 
    return build_method_call (object, fn, args, NULL_TREE, LOOKUP_NORMAL);
  #endif
  }
Index: cp/call.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/call.c,v
retrieving revision 1.95
diff -c -p -r1.95 call.c
*** call.c	1998/07/16 11:46:42	1.95
--- call.c	1998/07/17 06:34:01
*************** build_new_method_call (instance, name, a
*** 3552,3563 ****
        template_only = 1;
      }
  
-   if (TREE_CODE (name) == TYPE_DECL)
-     {
-       cp_error ("calling type `%T' like a method", name);
-       return error_mark_node;
-     }
-     
    /* If there is an extra argument for controlling virtual bases,
       remove it for error reporting.  */
    if (flags & LOOKUP_HAS_IN_CHARGE)
--- 3552,3557 ----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]