Commit 8b299be6 by Jason Merrill Committed by Jason Merrill

re PR c++/42315 (ICE with invalid array initializer)

	PR c++/42315
	* decl.c (maybe_deduce_size_from_array_init): Don't change the
	variable type.

From-SVN: r194509
parent 5e3b173a
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> 2012-12-13 Jakub Jelinek <jakub@redhat.com>
PR c++/55652 PR c++/55652
......
...@@ -4834,14 +4834,12 @@ maybe_deduce_size_from_array_init (tree decl, tree init) ...@@ -4834,14 +4834,12 @@ maybe_deduce_size_from_array_init (tree decl, tree init)
if (failure == 1) if (failure == 1)
{ {
error ("initializer fails to determine size of %qD", decl); error ("initializer fails to determine size of %qD", decl);
TREE_TYPE (decl) = error_mark_node;
} }
else if (failure == 2) else if (failure == 2)
{ {
if (do_default) if (do_default)
{ {
error ("array size missing in %qD", decl); 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 /* 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 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) ...@@ -4853,7 +4851,6 @@ maybe_deduce_size_from_array_init (tree decl, tree init)
else if (failure == 3) else if (failure == 3)
{ {
error ("zero-size array %qD", decl); error ("zero-size array %qD", decl);
TREE_TYPE (decl) = error_mark_node;
} }
} }
......
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
// { dg-do compile } // { dg-do compile }
// { dg-options "-fopenmp" } // { dg-options "-fopenmp" }
char x[] = 0; // { dg-error "initializer fails to determine size" } char x[] = 0; // { dg-error "initializer" }
#pragma omp threadprivate (x) #pragma omp threadprivate (x)
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
void foo() void foo()
{ {
const int x[] = 0; // { dg-error "size" } const int x[] = 0; // { dg-error "initializer" }
++x; ++x;
} }
// PR c++/42315
extern int x[];
int i = x[0];
int x[] = 0; // { dg-error "" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment