This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix PR 40032 (ICE on incomplete enum bit-field)
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 6 May 2009 13:03:45 +0000 (UTC)
- Subject: Fix PR 40032 (ICE on incomplete enum bit-field)
This patch fixes PR 40032, a regression caused by my recent changes to
diagnostics from C grokdeclarator (to handle extended identifiers and
improve i18n) where I missed a case that could occur without an
identifier being present.
Bootstrapped with no regressions on x86_64-unknown-linux-gnu. Applied
to mainline.
2009-05-06 Joseph Myers <joseph@codesourcery.com>
PR c/40032
* c-decl.c (grokdeclarator): Handle incomplete type of unnamed
field.
testsuite:
2009-05-06 Joseph Myers <joseph@codesourcery.com>
PR c/40032
* gcc.dg/noncompile/incomplete-5.c: New test.
Index: c-decl.c
===================================================================
--- c-decl.c (revision 147123)
+++ c-decl.c (working copy)
@@ -5021,7 +5021,10 @@ grokdeclarator (const struct c_declarato
else if (TREE_CODE (type) != ERROR_MARK
&& !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 = c_build_qualified_type (type, type_quals);
Index: testsuite/gcc.dg/noncompile/incomplete-5.c
===================================================================
--- testsuite/gcc.dg/noncompile/incomplete-5.c (revision 0)
+++ testsuite/gcc.dg/noncompile/incomplete-5.c (revision 0)
@@ -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 } */
+};
--
Joseph S. Myers
joseph@codesourcery.com