OSDN Git Service

cp:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 3 Jan 2003 17:21:14 +0000 (17:21 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 3 Jan 2003 17:21:14 +0000 (17:21 +0000)
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

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/ntp2.C [new file with mode: 0644]

index b6a33ff..9be1147 100644 (file)
@@ -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
index f301d45..20d51d4 100644 (file)
@@ -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:
index 7fa12a9..ea090a2 100644 (file)
@@ -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 (file)
index 0000000..42219e0
--- /dev/null
@@ -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);
+}