PR c++/42315
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 14 Dec 2012 20:57:55 +0000 (20:57 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 14 Dec 2012 20:57:55 +0000 (20:57 +0000)
* decl.c (maybe_deduce_size_from_array_init): Don't change the
variable type.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@194509 138bc75d-0d04-0410-961f-82ee72b054a4

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 ea4cfb2..ee9bf77 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 cdda2f4..64bd4b5 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 f5995a6..a02faa2 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 f41ce86..5438af1 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 "" }