re PR c++/51430 (ICE with array as static const member)
authorJakub Jelinek <jakub@redhat.com>
Tue, 6 Dec 2011 19:52:39 +0000 (20:52 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 6 Dec 2011 19:52:39 +0000 (20:52 +0100)
PR c++/51430
* pt.c (tsubst_decl): Don't call strip_array_domain on
error_mark_node.

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

From-SVN: r182063

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

index f979af5..defc0a5 100644 (file)
@@ -1,3 +1,9 @@
+2011-12-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/51430
+       * pt.c (tsubst_decl): Don't call strip_array_domain on
+       error_mark_node.
+
 2011-12-06  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/51431
index 15ef7a0..7603c11 100644 (file)
@@ -10622,7 +10622,9 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
              type = DECL_ORIGINAL_TYPE (t);
            else
              type = TREE_TYPE (t);
-           if (TREE_CODE (t) == VAR_DECL && VAR_HAD_UNKNOWN_BOUND (t))
+           if (TREE_CODE (t) == VAR_DECL
+               && VAR_HAD_UNKNOWN_BOUND (t)
+               && type != error_mark_node)
              type = strip_array_domain (type);
            type = tsubst (type, args, complain, in_decl);
          }
index 2353dd9..507f9df 100644 (file)
@@ -1,3 +1,8 @@
+2011-12-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/51430
+       * g++.dg/template/static32.C: New test.
+
 2011-12-06  Uros Bizjak  <ubizjak@gmail.com>
 
        * g++.dg/opt/pr51396.C: Use dg-additional-options.
diff --git a/gcc/testsuite/g++.dg/template/static32.C b/gcc/testsuite/g++.dg/template/static32.C
new file mode 100644 (file)
index 0000000..b17d14d
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/51430
+// { dg-do compile }
+
+template<int> struct A
+{
+  static const int x[] = 0;    // { dg-error "in-class initialization|initializer fails" }
+};
+
+A<0> a;