]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/40405 (ICE with invalid initialization of template member)
authorJason Merrill <jason@redhat.com>
Fri, 22 Feb 2013 22:26:20 +0000 (17:26 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 22 Feb 2013 22:26:20 +0000 (17:26 -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: r196233

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

index 7145496c052aadf805ae26465fe5484c9b1383d4..4f342c5e33c6b2f4a34597a19a638921d1085927 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++/56395
        * tree.c (strip_typedefs): Strip typedefs from TYPENAME_TYPE template
        args.
index 97305d2bffecde7d70f31f72c508d252236fe92e..d8b77ad0fed4434db05dbc0da3834902e3afd91e 100644 (file)
@@ -4740,6 +4740,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;