This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Fix PR 45, 3784
- From: Nathan Sidwell <nathan dot sidwell at blueyonder dot co dot uk>
- To: gcc-patches at gcc dot gnu dot org, neroden at twcny dot rr dot com
- Date: Fri, 03 Jan 2003 17:22:30 +0000
- Subject: [C++ PATCH] Fix PR 45, 3784
Hi,
I've installed this patch which fixed 45 and 3784.
Although a template parm's level and index are sufficient to identify it
within a single instantiation, it is not enough across instantiations of
non-type template parms.
booted & tested on i686-pc-linux-gnu. It will shortly go on the 3.3 branch
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
The voices in my head said this was stupid too
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2002-12-26 Nathan Sidwell <nathan@codesourcery.com>
PR c++/45, c++/3784
* tree.c (cp_tree_equal, TEMPLATE_PARM_INDEX): The types must be
the same too.
Index: cp/tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/tree.c,v
retrieving revision 1.308
diff -c -3 -p -r1.308 tree.c
*** cp/tree.c 16 Dec 2002 18:22:20 -0000 1.308
--- cp/tree.c 26 Dec 2002 18:56:34 -0000
*************** cp_tree_equal (t1, t2)
*** 1750,1757 ****
return 0;
case TEMPLATE_PARM_INDEX:
! return TEMPLATE_PARM_IDX (t1) == TEMPLATE_PARM_IDX (t2)
! && TEMPLATE_PARM_LEVEL (t1) == TEMPLATE_PARM_LEVEL (t2);
case SIZEOF_EXPR:
case ALIGNOF_EXPR:
--- 1750,1759 ----
return 0;
case TEMPLATE_PARM_INDEX:
! return (TEMPLATE_PARM_IDX (t1) == TEMPLATE_PARM_IDX (t2)
! && TEMPLATE_PARM_LEVEL (t1) == TEMPLATE_PARM_LEVEL (t2)
! && same_type_p (TREE_TYPE (TEMPLATE_PARM_DECL (t1)),
! TREE_TYPE (TEMPLATE_PARM_DECL (t2))));
case SIZEOF_EXPR:
case ALIGNOF_EXPR:
// { dg-do compile }
// Copyright (C) 2002 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 26 Dec 2002 <nathan@codesourcery.com>
// PR 3784: We were confusing non-type template parms.
template <unsigned N> class X { };
template <short N> void foo1(X<N>);
template <unsigned N> void foo2(X<N>);
int main() {
X<2> x;
foo2(x);
}