From 7176a4a096decd4a1930e4bd84f8ba2f05f13f81 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Mon, 2 May 2016 11:35:59 +0000 Subject: 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 --- gcc/c/ChangeLog | 6 ++++++ gcc/c/c-decl.c | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'gcc/c') 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 + + PR c/70851 + * c-decl.c (grokdeclarator): Diagnose when array's size has an + incomplete type. + 2016-04-29 Cesar Philippidis 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; } -- cgit v1.1