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]

C++ PATCH for member templates



This patch fixes a couple of problems reported recently by Corey
Kosak.

-- 
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

1999-03-19  Mark Mitchell  <mark@codesourcery.com>

	* init.c (build_member_call): Handle template-id expressions
	correctly.
	* typeck.c (build_x_function_call): Likewise.

Index: testsuite/g++.old-deja/g++.pt/crash31.C
===================================================================
RCS file: crash31.C
diff -N crash31.C
*** /dev/null	Sat Dec  5 20:30:03 1998
--- crash31.C	Fri Mar 19 12:06:53 1999
***************
*** 0 ****
--- 1,19 ----
+ // Build don't link:
+ // Origin: Corey Kosak
+ 
+ struct cow_t {
+   template<bool Q>
+   static void tfunc(cow_t *cowp) {}
+ 
+   void moo() {
+     cow_t *cowp;
+     cow_t::tfunc<true>(cowp);
+   }
+ };
+ 
+ 
+ int main()
+ {
+   cow_t *cowp;
+   cow_t::tfunc<true>(cowp);
+ }
Index: testsuite/g++.old-deja/g++.pt/memtemp82.C
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/testsuite/g++.old-deja/g++.pt/memtemp82.C,v
retrieving revision 1.1
diff -c -p -r1.1 memtemp82.C
*** memtemp82.C	1999/01/16 16:34:32	1.1
--- memtemp82.C	1999/03/19 20:06:53
***************
*** 1,5 ****
  // Build don't link:
! // excess errors test - XFAIL *-*-*
  
  struct foo {
         template<typename T> T bar() { return staticbar<T>( this ); }
--- 1,5 ----
  // Build don't link:
! // excess errors test
  
  struct foo {
         template<typename T> T bar() { return staticbar<T>( this ); }
Index: testsuite/g++.old-deja/g++.pt/memtemp83.C
===================================================================
RCS file: memtemp83.C
diff -N memtemp83.C
*** /dev/null	Sat Dec  5 20:30:03 1998
--- memtemp83.C	Fri Mar 19 12:06:53 1999
***************
*** 0 ****
--- 1,19 ----
+ // Build don't link:
+ // Origin: Corey Kosak <kosak@cs.cmu.edu>
+ 
+ struct cow_t {
+   template<bool Q>
+   static void tfunc(cow_t *cowp) {}
+ 
+   void moo() {
+     cow_t *cowp;
+     tfunc<true>(cowp);
+   }
+ };
+ 
+ 
+ int main()
+ {
+   cow_t *cowp;
+   cow_t::tfunc<true>(cowp);
+ }
Index: testsuite/g++.old-deja/cp/init.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/init.c,v
retrieving revision 1.89
diff -c -p -r1.89 init.c
*** init.c	1999/03/09 23:02:34	1.89
--- init.c	1999/03/19 20:06:56
*************** build_member_call (type, name, parmlist)
*** 1381,1387 ****
    if (TREE_CODE (name) != TEMPLATE_ID_EXPR)
      method_name = name;
    else
!     method_name = TREE_OPERAND (name, 0);
  
    if (TREE_CODE (method_name) == BIT_NOT_EXPR)
      {
--- 1381,1391 ----
    if (TREE_CODE (name) != TEMPLATE_ID_EXPR)
      method_name = name;
    else
!     {
!       method_name = TREE_OPERAND (name, 0);
!       if (is_overloaded_fn (method_name))
! 	method_name = DECL_NAME (OVL_CURRENT (method_name));
!     }
  
    if (TREE_CODE (method_name) == BIT_NOT_EXPR)
      {
Index: testsuite/g++.old-deja/cp/typeck.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/typeck.c,v
retrieving revision 1.143
diff -c -p -r1.143 typeck.c
*** typeck.c	1999/03/13 01:16:34	1.143
--- typeck.c	1999/03/19 20:07:05
*************** build_x_function_call (function, params,
*** 2585,2590 ****
--- 2585,2599 ----
  				TYPE_BINFO (type), LOOKUP_NORMAL);
      }
      
+   if ((TREE_CODE (function) == FUNCTION_DECL
+        && DECL_STATIC_FUNCTION_P (function))
+       || (TREE_CODE (function) == TEMPLATE_DECL
+ 	  && DECL_STATIC_FUNCTION_P (DECL_RESULT (function))))
+       return build_member_call(DECL_CONTEXT (function), 
+ 			       template_id 
+ 			       ? template_id : DECL_NAME (function), 
+ 			       params);
+ 
    is_method = ((TREE_CODE (function) == TREE_LIST
  		&& current_class_type != NULL_TREE
  		&& (IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (function))
*************** build_x_function_call (function, params,
*** 2593,2605 ****
  	       || TREE_CODE (type) == METHOD_TYPE
  	       || TYPE_PTRMEMFUNC_P (type));
  
-   if ((TREE_CODE (function) == FUNCTION_DECL
-        && DECL_STATIC_FUNCTION_P (function))
-       || (TREE_CODE (function) == TEMPLATE_DECL
- 	  && DECL_STATIC_FUNCTION_P (DECL_RESULT (function))))
-     return build_member_call
-       (DECL_CONTEXT (function), DECL_NAME (function), params);
- 
    /* A friend template.  Make it look like a toplevel declaration.  */
    if (! is_method && TREE_CODE (function) == TEMPLATE_DECL)
      function = scratch_ovl_cons (function, NULL_TREE);
--- 2602,2607 ----


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