From 5e7955289faf43ba7ff15c5815d768657fb225d8 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Sat, 13 Jun 1998 23:34:56 +0000 Subject: [PATCH] search.c (get_matching_virtual): Note that member templates cannot override virtual functions. * search.c (get_matching_virtual): Note that member templates cannot override virtual functions. From-SVN: r20497 --- gcc/cp/search.c | 7 +++++++ gcc/testsuite/g++.old-deja/g++.pt/memtemp76.C | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 gcc/testsuite/g++.old-deja/g++.pt/memtemp76.C diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 1478f23f3e2..2e71de303a3 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -2232,6 +2232,13 @@ get_matching_virtual (binfo, fndecl, dtorp) 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) diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp76.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp76.C new file mode 100644 index 00000000000..b2028511a11 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp76.C @@ -0,0 +1,17 @@ +// Build don't link: + +class base +{ +public: + virtual void method()=0; +}; + +class der: public base +{ +public: + template + void method() + { + C foo; + } +};