From 0e36f5c7c103e2d897fcbc9728fa98768b386f9a Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Tue, 15 Sep 2015 17:19:11 +0000 Subject: 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 --- gcc/c/c-decl.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gcc/c/c-decl.c') 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 -- cgit v1.1