]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/42315 (ICE with invalid array initializer)
authorJason Merrill <jason@redhat.com>
Fri, 14 Dec 2012 20:57:55 +0000 (15:57 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 14 Dec 2012 20:57:55 +0000 (15:57 -0500)
PR c++/42315
* decl.c (maybe_deduce_size_from_array_init): Don't change the
variable type.

From-SVN: r194509

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/gomp/pr34964.C
gcc/testsuite/g++.dg/init/array21.C
gcc/testsuite/g++.dg/init/array32.C [new file with mode: 0644]

index ea4cfb203426e9aeb717712359570639852fef19..ee9bf7749efd98125ff2c0cd9fbe363552aab46c 100644 (file)
@@ -1,3 +1,9 @@
+2012-12-14  Jason Merrill  <jason@redhat.com>
+
+       PR c++/42315
+       * decl.c (maybe_deduce_size_from_array_init): Don't change the
+       variable type.
+
 2012-12-13  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/55652
index cdda2f427654cf014e47a30a3d684c82a1975b41..64bd4b5d2c0e770d9ea7d3b11d04aea3dfea60fd 100644 (file)
@@ -4834,14 +4834,12 @@ maybe_deduce_size_from_array_init (tree decl, tree init)
          if (failure == 1)
            {
              error ("initializer fails to determine size of %qD", decl);
-             TREE_TYPE (decl) = error_mark_node;
            }
          else if (failure == 2)
            {
              if (do_default)
                {
                  error ("array size missing in %qD", decl);
-                 TREE_TYPE (decl) = error_mark_node;
                }
              /* If a `static' var's size isn't known, make it extern as
                 well as static, so it does not get allocated.  If it's not
@@ -4853,7 +4851,6 @@ maybe_deduce_size_from_array_init (tree decl, tree init)
          else if (failure == 3)
            {
              error ("zero-size array %qD", decl);
-             TREE_TYPE (decl) = error_mark_node;
            }
        }
 
index f5995a6da9194ec798248396933c34e74a8aad5a..a02faa2a8d46620a45dab9bf6ce3a8b1ced04159 100644 (file)
@@ -2,5 +2,5 @@
 // { dg-do compile }
 // { dg-options "-fopenmp" }
 
-char x[] = 0;  // { dg-error "initializer fails to determine size" }
+char x[] = 0;  // { dg-error "initializer" }
 #pragma omp threadprivate (x)
index f41ce86b1d9069e5b25703f355de3bd1d043ea7c..5438af1d47772cee086ddcbb8d1cf23d3b5c8385 100644 (file)
@@ -2,6 +2,6 @@
 
 void foo()
 {
-  const int x[] = 0; // { dg-error "size" }
+  const int x[] = 0; // { dg-error "initializer" }
   ++x;
 }
diff --git a/gcc/testsuite/g++.dg/init/array32.C b/gcc/testsuite/g++.dg/init/array32.C
new file mode 100644 (file)
index 0000000..06b27a9
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/42315
+
+extern int x[];
+
+int i = x[0];
+
+int x[] = 0;                   // { dg-error "" }