This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH]: Fix 7676
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: mark at codesourcery dot com
- Date: Fri, 18 Oct 2002 09:13:29 +0100
- Subject: [C++ PATCH]: Fix 7676
- Organization: Codesourcery LLC
Hi,
I've installed this obvious patch for 7676 regression where we rejected
valid member template overloads, (and would also erroneously hide base
templates introduced with a using decl).
booted & tested on i686-pc-linux-gnu.
I will shortly commit this to the 3.2 branch as well.
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2002-10-17 Nathan Sidwell <nathan@codesourcery.com>
* class.c (add_method): Compare template parms too.
Index: cp/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.474
diff -c -3 -p -r1.474 class.c
*** cp/class.c 11 Oct 2002 16:50:39 -0000 1.474
--- cp/class.c 17 Oct 2002 16:44:41 -0000
*************** add_method (type, method, error_p)
*** 953,958 ****
--- 953,965 ----
&& (TYPE_QUALS (TREE_TYPE (TREE_VALUE (parms1)))
!= TYPE_QUALS (TREE_TYPE (TREE_VALUE (parms2)))))
same = 0;
+
+ /* For templates, the template parms must be identical. */
+ if (TREE_CODE (fn) == TEMPLATE_DECL
+ && !comp_template_parms (DECL_TEMPLATE_PARMS (fn),
+ DECL_TEMPLATE_PARMS (method)))
+ same = 0;
+
if (! DECL_STATIC_FUNCTION_P (fn))
parms1 = TREE_CHAIN (parms1);
if (! DECL_STATIC_FUNCTION_P (method))
// { dg-do run }
// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 17 Oct 2002 <nathan@codesourcery.com>
// PR 7676. We didn't notice template members were different.
struct foo
{
template<class T>
int bar() {return 1;}
template<int I>
int bar() {return 2;}
};
struct baz : foo
{
using foo::bar;
template<int I>
int bar () {return 3;}
};
int main ()
{
baz b;
foo f;
if (f.bar<1> () != 2)
return 1;
if (f.bar<int> () != 1)
return 2;
if (b.bar<1> () != 3)
return 1;
if (b.bar<int> () != 1)
return 2;
return 0;
}