From 0aca1a4fd3d3f5fbfbbbfcc8e29a3f1cbb45d56a Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Wed, 31 Jan 2001 10:24:40 +0000 Subject: c-parse.in (structsp): Pedwarn when "enum foo" refers to an incomplete type. * c-parse.in (structsp): Pedwarn when "enum foo" refers to an incomplete type. (typename): Call pending_xref_error after parsing typed_typespecs. * c-decl.c (lookup_tag): Give error immediately rather than leaving it pending if the tag of the wrong type is in the same binding level. (xref_tag): Don't pedwarn for forward declarations of enum types here. * gcc.texi (Actual Bugs): Remove entry for misuse of struct, union and enum tags. testsuite: * gcc.dg/c99-tag-1.c: New test. From-SVN: r39372 --- gcc/c-parse.in | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'gcc/c-parse.in') diff --git a/gcc/c-parse.in b/gcc/c-parse.in index 5b32768..a51161c 100644 --- a/gcc/c-parse.in +++ b/gcc/c-parse.in @@ -1397,7 +1397,11 @@ structsp: { $$ = finish_enum ($3, nreverse ($4), chainon ($1, $7)); } | enum_head identifier - { $$ = xref_tag (ENUMERAL_TYPE, $2); } + { $$ = xref_tag (ENUMERAL_TYPE, $2); + /* In ISO C, enumerated types can be referred to + only if already defined. */ + if (pedantic && !COMPLETE_TYPE_P ($$)) + pedwarn ("ISO C forbids forward references to `enum' types"); } ; maybecomma: @@ -1534,8 +1538,10 @@ enumerator: ; typename: - typed_typespecs absdcl - { $$ = build_tree_list ($1, $2); } + typed_typespecs + { pending_xref_error (); } + absdcl + { $$ = build_tree_list ($1, $3); } | nonempty_type_quals absdcl { $$ = build_tree_list ($1, $2); } ; -- cgit v1.1