re PR c++/28743 (ICE with invalid specialization)
authorJason Merrill <jason@redhat.com>
Wed, 26 Nov 2008 03:51:40 +0000 (22:51 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 26 Nov 2008 03:51:40 +0000 (22:51 -0500)
        PR c++/28743
        * decl2.c (check_classfn): Error rather than abort on parameter
        list mismatch.

From-SVN: r142212

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

index 98808152cb8e501d605945b2ba226f4f3b11bb47..e128fe1f3826cfe6caea860f4039177a7b984389 100644 (file)
@@ -1,3 +1,9 @@
+2008-11-25  Jason Merrill  <jason@redhat.com>
+
+       PR c++/28743
+       * decl2.c (check_classfn): Error rather than abort on parameter
+       list mismatch.
+
 2008-11-20  Jason Merrill  <jason@redhat.com>
 
        PR c++/28513
index a0ae6e4f7be2d4c91d441b5b5db447c4dde51095..da9201e88909faf2deb8e9a19489657a9b543d65 100644 (file)
@@ -572,9 +572,14 @@ check_classfn (tree ctype, tree function, tree template_parms)
      either were not passed, or they are the same of DECL_TEMPLATE_PARMS.  */
   if (TREE_CODE (function) == TEMPLATE_DECL)
     {
-      gcc_assert (!template_parms
-                 || comp_template_parms (template_parms,
-                                         DECL_TEMPLATE_PARMS (function)));
+      if (template_parms
+         && !comp_template_parms (template_parms,
+                                  DECL_TEMPLATE_PARMS (function)))
+       {
+         error ("template parameter lists provided don't match the "
+                "template parameters of %qD", function);
+         return error_mark_node;
+       }
       template_parms = DECL_TEMPLATE_PARMS (function);
     }
 
index a508f752d13f6af0067e79f1b9e1296c2d64e086..08ee43c77e38ab6bade2a3fd45026259b43bd977 100644 (file)
@@ -1,3 +1,8 @@
+2008-11-25  Jason Merrill  <jason@redhat.com>
+
+       PR c++/28743
+       * g++.dg/template/nontype18.C: New test.
+
 2008-11-25  Maxim Kuvyrkov  <maxim@codesourcery.com>
 
        * gcc.c-torture/compile/20080929-1.c: New.
diff --git a/gcc/testsuite/g++.dg/template/nontype18.C b/gcc/testsuite/g++.dg/template/nontype18.C
new file mode 100644 (file)
index 0000000..cbe0a1b
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/28743
+
+template<int I> struct A
+{
+    template<typename T> void foo();
+};
+
+template<int I> template<typename T> void A<0>::foo() {} // { dg-error "template parameter" }