aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-parse.in
diff options
context:
space:
mode:
authorJoseph Myers <jsm28@cam.ac.uk>2001-01-31 10:24:40 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2001-01-31 10:24:40 +0000
commit0aca1a4fd3d3f5fbfbbbfcc8e29a3f1cbb45d56a (patch)
tree34733a2dad346aaafe559de1ce988837b74efabf /gcc/c-parse.in
parent92fa350add2e10d97b012085da56166db9ed4f0c (diff)
downloadgcc-0aca1a4fd3d3f5fbfbbbfcc8e29a3f1cbb45d56a.zip
gcc-0aca1a4fd3d3f5fbfbbbfcc8e29a3f1cbb45d56a.tar.gz
gcc-0aca1a4fd3d3f5fbfbbbfcc8e29a3f1cbb45d56a.tar.bz2
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
Diffstat (limited to 'gcc/c-parse.in')
-rw-r--r--gcc/c-parse.in12
1 files changed, 9 insertions, 3 deletions
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 ($<ttype>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); }
;