re PR c/40032 (ICE with incomplete type in struct)

PR c/40032
	* c-decl.c (grokdeclarator): Handle incomplete type of unnamed
	field.

testsuite:
	* gcc.dg/noncompile/incomplete-5.c: New test.

From-SVN: r147174
This commit is contained in:
Joseph Myers 2009-05-06 14:02:48 +01:00 committed by Joseph Myers
parent 483c78cb8e
commit 1202aec13a
4 changed files with 23 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2009-05-06 Joseph Myers <joseph@codesourcery.com>
PR c/40032
* c-decl.c (grokdeclarator): Handle incomplete type of unnamed
field.
2009-05-05 Jakub Jelinek <jakub@redhat.com> 2009-05-05 Jakub Jelinek <jakub@redhat.com>
* tree.h: Remove DECL_BY_REFERENCE from private_flag comment. * tree.h: Remove DECL_BY_REFERENCE from private_flag comment.

View File

@ -5021,7 +5021,10 @@ grokdeclarator (const struct c_declarator *declarator,
else if (TREE_CODE (type) != ERROR_MARK else if (TREE_CODE (type) != ERROR_MARK
&& !COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (type)) && !COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (type))
{ {
error ("field %qE has incomplete type", name); if (name)
error ("field %qE has incomplete type", name);
else
error ("unnamed field has incomplete type");
type = error_mark_node; type = error_mark_node;
} }
type = c_build_qualified_type (type, type_quals); type = c_build_qualified_type (type, type_quals);

View File

@ -1,3 +1,8 @@
2009-05-06 Joseph Myers <joseph@codesourcery.com>
PR c/40032
* gcc.dg/noncompile/incomplete-5.c: New test.
2009-05-05 Jakub Jelinek <jakub@redhat.com> 2009-05-05 Jakub Jelinek <jakub@redhat.com>
PR middle-end/39666 PR middle-end/39666

View File

@ -0,0 +1,8 @@
/* ICE on unnamed field with incomplete enum type: PR 40032. */
/* { dg-do compile } */
/* { dg-options "" } */
struct A
{
enum E : 8; /* { dg-warning "narrower than values of its type" } */
/* { dg-error "has incomplete type" "incomplete" { target *-*-* } 6 } */
};