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 member templates and virtual functions



Here's a patch to make sure we don't think member templates are
overriding virtual functions.  Jason, OK?

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

1998-06-13  Mark Mitchell  <mark@markmitchell.com>

	* search.c (get_matching_virtual): Note that member templates
	cannot override virtual functions.

Index: testsuite/g++.old-deja/g++.pt/memtemp76.C
===================================================================
RCS file: memtemp76.C
diff -N memtemp76.C
*** /dev/null	Mon Dec 31 20:00:00 1979
--- memtemp76.C	Sat Jun 13 22:50:19 1998
***************
*** 0 ****
--- 1,17 ----
+ // Build don't link:
+ 
+ class base
+ {
+ public:
+   virtual void method()=0;
+ };
+ 
+ class der: public base
+ {
+ public:
+   template<class C>
+   void method()
+     {
+       C foo;
+     }
+ };
Index: cp/search.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/search.c,v
retrieving revision 1.35
diff -c -p -r1.35 search.c
*** search.c	1998/06/10 21:12:16	1.35
--- search.c	1998/06/14 05:49:55
*************** get_matching_virtual (binfo, fndecl, dto
*** 2232,2237 ****
--- 2232,2244 ----
    tree tmp = NULL_TREE;
    int i;
  
+   if (TREE_CODE (fndecl) == TEMPLATE_DECL)
+     /* In [temp.mem] we have:
+ 
+          A specialization of a member function template does not
+          override a virtual function from a base class.  */
+     return NULL_TREE;
+ 
    /* Breadth first search routines start searching basetypes
       of TYPE, so we must perform first ply of search here.  */
    if (dtorp)


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