re PR c++/40405 (ICE with invalid initialization of template member)
authorJason Merrill <jason@redhat.com>
Fri, 22 Feb 2013 22:24:40 +0000 (17:24 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 22 Feb 2013 22:24:40 +0000 (17:24 -0500)
PR c++/40405
* pt.c (push_template_decl_real): Set DECL_INTERFACE_KNOWN
if we got the wrong number of template parms.

From-SVN: r196231

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

index ed5d3995b357d2b6309f7b8dde8faf5c2fcad4b8..4a2baa00ad5c907d92ab0f3854c459b7a09d3943 100644 (file)
@@ -1,5 +1,9 @@
 2013-02-22  Jason Merrill  <jason@redhat.com>
 
+       PR c++/40405
+       * pt.c (push_template_decl_real): Set DECL_INTERFACE_KNOWN
+       if we got the wrong number of template parms.
+
        PR c++/56377
        * pt.c (fn_type_unification): Use explicit args in template
        instantiation context.
index a39d114818f6012f8e77d0e2cad0304b740e62bf..5ff08211ebc42fe002b7cc30f5f11f42f354344f 100644 (file)
@@ -4782,6 +4782,8 @@ push_template_decl_real (tree decl, bool is_friend)
                  error ("got %d template parameters for %q#T",
                         TREE_VEC_LENGTH (a), current);
                error ("  but %d required", TREE_VEC_LENGTH (t));
+               /* Avoid crash in import_export_decl.  */
+               DECL_INTERFACE_KNOWN (decl) = 1;
                return error_mark_node;
              }
 
diff --git a/gcc/testsuite/g++.dg/template/error49.C b/gcc/testsuite/g++.dg/template/error49.C
new file mode 100644 (file)
index 0000000..57789a7
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/40405
+
+template<int, int> struct A
+{
+  static int i;
+};
+
+template<int> int A<0,0>::i = 0; // { dg-error "" }
+
+int j = A<0,0>::i;