diff options
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-decl.c | 15 |
2 files changed, 19 insertions, 2 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index f02fbdb..793186b 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +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> PR middle-end/70626 diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 16e4250..7094efc 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -5799,10 +5799,21 @@ grokdeclarator (const struct c_declarator *declarator, { if (name) error_at (loc, "size of array %qE has non-integer type", - name); + name); else 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; } |