diff options
author | Marek Polacek <polacek@redhat.com> | 2015-09-15 17:19:11 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2015-09-15 17:19:11 +0000 |
commit | 0e36f5c7c103e2d897fcbc9728fa98768b386f9a (patch) | |
tree | ea4ad4601177b57e46c4c68bebdfb4668db9e541 /gcc/c/c-decl.c | |
parent | c33c18cdc6b29a312464cb16996530b47a333c98 (diff) | |
download | gcc-0e36f5c7c103e2d897fcbc9728fa98768b386f9a.zip gcc-0e36f5c7c103e2d897fcbc9728fa98768b386f9a.tar.gz gcc-0e36f5c7c103e2d897fcbc9728fa98768b386f9a.tar.bz2 |
re PR c/67580 (Improve error message on missing "struct" tag)
PR c/67580
* c-decl.c (tag_exists_p): New function.
* c-parser.c (c_parser_declaration_or_fndef): Give a hint when
struct/union/enum keywords are missing.
* c-tree.h (tag_exists_p): Declare.
* gcc.dg/pr67580.c: New test.
From-SVN: r227803
Diffstat (limited to 'gcc/c/c-decl.c')
-rw-r--r-- | gcc/c/c-decl.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 989ff99..a110226 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -3856,6 +3856,18 @@ lookup_tag (enum tree_code code, tree name, bool thislevel_only, return b->decl; } +/* Return true if a definition exists for NAME with code CODE. */ + +bool +tag_exists_p (enum tree_code code, tree name) +{ + struct c_binding *b = I_TAG_BINDING (name); + + if (b == NULL || b->decl == NULL_TREE) + return false; + return TREE_CODE (b->decl) == code; +} + /* Print an error message now for a recent invalid struct, union or enum cross reference. We don't print them immediately because they are not invalid |