diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-10-07 06:24:25 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-12-29 14:39:38 +0100 |
commit | d9087a616640c02d39a8f5307ead92cf035f9d1a (patch) | |
tree | ed279edd27eef79a86b47222ae32c86a4e31e25e | |
parent | c2922bf8df232fd30adff7ee4314fdbe1f73db87 (diff) | |
download | sparse-d9087a616640c02d39a8f5307ead92cf035f9d1a.tar.gz |
struct-attr: prepare to handle attributes at the end of struct definitions (2)
Type attributes for struct can be placed either just after the
keyword 'struct' or after the '}' ending its definition but this
later case is currently ignored.
Prepare the handling of this by restructuring the code handling
struct specifiers, namely inverting the condition so that the
function can return early to make next patch's job easier.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | parse.c | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -738,19 +738,19 @@ static struct token *struct_union_enum_specifier(enum type type, ctx->ctype.base_type = sym; repos = &token->pos; token = token->next; - if (match_op(token, '{')) { - // The following test is actually wrong for empty - // structs, but (1) they are not C99, (2) gcc does - // the same thing, and (3) it's easier. - if (sym->symbol_list) - error_die(token->pos, "redefinition of %s", show_typename (sym)); - sym->pos = *repos; - - // Mark the structure as needing re-examination - sym->examined = 0; - goto end; - } - return token; + if (!match_op(token, '{')) + return token; + + // The following test is actually wrong for empty + // structs, but (1) they are not C99, (2) gcc does + // the same thing, and (3) it's easier. + if (sym->symbol_list) + error_die(token->pos, "redefinition of %s", show_typename (sym)); + sym->pos = *repos; + + // Mark the structure as needing re-examination + sym->examined = 0; + goto end; } // private struct/union/enum type |