This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH for member templates and virtual functions
- To: Jason Merrill <jason at cygnus dot com>
- Subject: PATCH for member templates and virtual functions
- From: Mark Mitchell <mark at markmitchell dot com>
- Date: Sat, 13 Jun 1998 23:14:32 -0700
- Cc: egcs-patches at cygnus dot com
- Reply-to: mark at markmitchell dot com
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)