summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2003-01-03 17:21:14 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2003-01-03 17:21:14 +0000
commitb94a104fe3909f90a147b66dc281b1b4c55bc9ca (patch)
tree3cd21cd3c58d2a6b656cd5589e25532b84d97b2c /gcc
parent10b6766d4a11dd231831c20805e4ebe810714436 (diff)
downloadgcc-b94a104fe3909f90a147b66dc281b1b4c55bc9ca.tar.gz
cp:
PR c++/45, c++/3784 * tree.c (cp_tree_equal, TEMPLATE_PARM_INDEX): The types must be the same too. testsuite: * g++.dg/template/ntp2.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@60839 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/tree.c6
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/template/ntp2.C16
4 files changed, 30 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b6a33ff6556..9be11475fd9 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2003-01-03 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.
+
2003-01-03 Graham Stott <graham.stott@btinternet.com>
* parser.c (struct cp_parser): Add access_checks_lists field
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index f301d45400d..20d51d4ac18 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1735,8 +1735,10 @@ cp_tree_equal (t1, t2)
return 0;
case TEMPLATE_PARM_INDEX:
- return TEMPLATE_PARM_IDX (t1) == TEMPLATE_PARM_IDX (t2)
- && TEMPLATE_PARM_LEVEL (t1) == TEMPLATE_PARM_LEVEL (t2);
+ 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:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7fa12a98a3f..ea090a2fa89 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2003-01-03 Nathan Sidwell <nathan@codesourcery.com>
+
+ * g++.dg/template/ntp2.C: New test.
+
2003-01-03 Nathanael Nerode <neroden@gcc.gnu.org>
* g++.dg/parse/extern-C-1.C: New test.
diff --git a/gcc/testsuite/g++.dg/template/ntp2.C b/gcc/testsuite/g++.dg/template/ntp2.C
new file mode 100644
index 00000000000..42219e0fcb0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/ntp2.C
@@ -0,0 +1,16 @@
+// { 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);
+}