re PR c++/22233 (ICE with wrong number of template parameters)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Mon, 22 Aug 2005 09:48:26 +0000 (09:48 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Mon, 22 Aug 2005 09:48:26 +0000 (09:48 +0000)
PR c++/22233
* pt.c (push_template_decl_real): Return error_mark_node if the
number of template parameters does not match previous definition.

* g++.dg/template/param1.C: New test.

From-SVN: r103339

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

index 765ce9cc0b56e449afec14628f6b6747e589655a..0ad264f6798eacb2c79e47cf5a0a35a28b8b36cf 100644 (file)
@@ -1,3 +1,9 @@
+2005-08-22  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/22233
+       * pt.c (push_template_decl_real): Return error_mark_node if the
+       number of template parameters does not match previous definition.
+
 2005-08-22  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/23089
index 73e2a259a0f4b5958261cebb5919e06a8a76a433..f217198faa26108ea97f88ef49d8fd4b4363d7c1 100644 (file)
@@ -3109,6 +3109,7 @@ push_template_decl_real (tree decl, int is_friend)
                  error ("got %d template parameters for %q#T",
                         TREE_VEC_LENGTH (a), current);
                error ("  but %d required", TREE_VEC_LENGTH (t));
+               return error_mark_node;
              }
 
            /* Perhaps we should also check that the parms are used in the
index 5d6a6823659fc9d8ae848e4f2c3b2201ff36df0f..b85a569c58fb47cdc23767b9efcb47df5b034966 100644 (file)
@@ -1,3 +1,8 @@
+2005-08-22  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/22233
+       * g++.dg/template/param1.C: New test.
+
 2005-08-22  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/23089
diff --git a/gcc/testsuite/g++.dg/template/param1.C b/gcc/testsuite/g++.dg/template/param1.C
new file mode 100644 (file)
index 0000000..ad7fc8c
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/22233
+// Origin: Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+// { dg-do compile }
+
+template<int> struct A
+{
+  A();
+};
+
+template<int N, char> A<N>::A() {}  // { dg-error "got 2|but 1 required" }
+
+A<0> a;