re PR c++/20157 (Internal compiler error on invalid code)
authorMark Mitchell <mark@codesourcery.com>
Mon, 14 Mar 2005 03:54:21 +0000 (03:54 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Mon, 14 Mar 2005 03:54:21 +0000 (03:54 +0000)
PR c++/20157
* pt.c (determine_specialization): Reject non-specializations.

PR c++/20157
* g++.dg/template/error18.C: New test.

From-SVN: r96414

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

index 2d9999287c71b89cea1bcad130b75c747158dc51..fefffd8056ed7f0af296d8cd37a95627d9328d0e 100644 (file)
@@ -1,3 +1,8 @@
+2005-03-13  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/20157
+       * pt.c (determine_specialization): Reject non-specializations. 
+
 2005-03-11  Per Bothner  <per@bothner.com>
 
        * cp-tree.h (struct cp_declarator): New id_loc field.
index 2ad20b34aced4986306c6d54f338ea99d69b489a..c9d2f96e38376ddf82691d4efcb360bb706cf643 100644 (file)
@@ -1353,8 +1353,8 @@ determine_specialization (tree template_id,
   /* Count the number of template headers specified for this
      specialization.  */
   header_count = 0;
-  for (b = current_binding_level;
-       b->kind == sk_template_parms || b->kind == sk_template_spec;
+  for (b = current_binding_level; 
+       b->kind == sk_template_parms;
        b = b->level_chain)
     ++header_count;
 
@@ -1423,6 +1423,14 @@ determine_specialization (tree template_id,
          if (header_count && header_count != template_count + 1)
            continue;
 
+         /* Check that the number of template arguments at the
+            innermost level for DECL is the same as for FN.  */
+         if (current_binding_level->kind == sk_template_parms
+             && !current_binding_level->explicit_spec_p
+             && (TREE_VEC_LENGTH (DECL_INNERMOST_TEMPLATE_PARMS (fn))
+                 != TREE_VEC_LENGTH (TREE_VALUE (current_template_parms))))
+           continue;
          /* See whether this function might be a specialization of this
             template.  */
          targs = get_bindings (fn, decl, explicit_targs);
index 111020facd77f8358ee83448b6e176298a935cc6..1b6603f1c950cb1ff0af97c21369b22c4de94e8b 100644 (file)
@@ -1,3 +1,8 @@
+2005-03-13  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/20157
+       * g++.dg/template/error18.C: New test.
+
 2005-03-09  Ben Elliston  <bje@au.ibm.com>
 
        PR debug/16792
diff --git a/gcc/testsuite/g++.dg/template/error18.C b/gcc/testsuite/g++.dg/template/error18.C
new file mode 100644 (file)
index 0000000..ca0762e
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/20157
+
+template<typename AT>
+struct A{
+  template<typename T>
+  void function(T);
+};
+
+template<>
+template<typename ABC,typename DEF>
+void A<int>::function(ABC); // { dg-error "" }