Commit 7176a4a0 by Marek Polacek Committed by Marek Polacek

re PR c/70851 (internal compiler error: in create_tmp_var, at gimple-expr.c:473)

	PR c/70851
	* c-decl.c (grokdeclarator): Diagnose when array's size has an
	incomplete type.

	* gcc.dg/enum-incomplete-3.c: New test.

From-SVN: r235750
parent b5a5ade8
2016-05-02 Marek Polacek <polacek@redhat.com>
PR c/70851
* c-decl.c (grokdeclarator): Diagnose when array's size has an
incomplete type.
2016-04-29 Cesar Philippidis <cesar@codesourcery.com> 2016-04-29 Cesar Philippidis <cesar@codesourcery.com>
PR middle-end/70626 PR middle-end/70626
......
...@@ -5799,10 +5799,21 @@ grokdeclarator (const struct c_declarator *declarator, ...@@ -5799,10 +5799,21 @@ grokdeclarator (const struct c_declarator *declarator,
{ {
if (name) if (name)
error_at (loc, "size of array %qE has non-integer type", error_at (loc, "size of array %qE has non-integer type",
name); name);
else else
error_at (loc, error_at (loc,
"size of unnamed array has non-integer type"); "size of unnamed array has non-integer type");
size = integer_one_node;
}
/* This can happen with enum forward declaration. */
else if (!COMPLETE_TYPE_P (TREE_TYPE (size)))
{
if (name)
error_at (loc, "size of array %qE has incomplete type",
name);
else
error_at (loc, "size of unnamed array has incomplete "
"type");
size = integer_one_node; size = integer_one_node;
} }
......
2016-05-02 Marek Polacek <polacek@redhat.com> 2016-05-02 Marek Polacek <polacek@redhat.com>
PR c/70851
* gcc.dg/enum-incomplete-3.c: New test.
2016-05-02 Marek Polacek <polacek@redhat.com>
Tom de Vries <tom@codesourcery.com> Tom de Vries <tom@codesourcery.com>
PR tree-optimization/70700 PR tree-optimization/70700
......
/* PR c/70851 */
/* { dg-do compile } */
/* { dg-options "" } */
enum E e; /* { dg-error "storage size" } */
void bar (int [e]); /* { dg-error "size of unnamed array has incomplete type" } */
void bar2 (int [][e]); /* { dg-error "size of unnamed array has incomplete type" } */
void
foo (void)
{
int a1[e]; /* { dg-error "size of array .a1. has incomplete type" } */
int a2[e][3]; /* { dg-error "size of array .a2. has incomplete type" } */
struct S
{
int a3[e]; /* { dg-error "size of array .a3. has incomplete type" } */
};
}
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