commit 1c880bb1328d3815435cf0695e180ab7fe1c47ec
Author: Jason Merrill <jason@redhat.com>
Date: Fri Dec 14 11:36:43 2012 -0500
PR c++/42315
* decl.c (maybe_deduce_size_from_array_init): Don't change the
variable type.
@@ -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;
}
}
@@ -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)
@@ -2,6 +2,6 @@
void foo()
{
- const int x[] = 0; // { dg-error "size" }
+ const int x[] = 0; // { dg-error "initializer" }
++x;
}
new file mode 100644
@@ -0,0 +1,7 @@
+// PR c++/42315
+
+extern int x[];
+
+int i = x[0];
+
+int x[] = 0; // { dg-error "" }