aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-10-06 02:43:32 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-12-29 14:39:38 +0100
commita565045f5e89b92d5f9c79b36fe60492d3e3119b (patch)
treefe681824e1b2c7c5f84f1027f36e606cd50db067
parent0c07b5979739336e07c60bf272b80cfe6b0b23fd (diff)
downloadsparse-a565045f5e89b92d5f9c79b36fe60492d3e3119b.tar.gz
struct-attr: fix type attribute like 'struct __attr { ... }'
In a declaration like: struct <some attribute> { ... } the attribute belong to the type but is currently handled as belonging to the whole declaration. Fix this by handling such attributes in a local 'decl_state' and applying them once the closing '}' is reached. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--parse.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/parse.c b/parse.c
index 69bfc2e0..b38615b8 100644
--- a/parse.c
+++ b/parse.c
@@ -719,10 +719,11 @@ static struct token *struct_union_enum_specifier(enum type type,
struct token *token, struct decl_state *ctx,
struct token *(*parse)(struct token *, struct symbol *))
{
+ struct decl_state attr = { };
struct symbol *sym;
struct position *repos;
- token = handle_attributes(token, ctx);
+ token = handle_attributes(token, &attr);
if (token_type(token) == TOKEN_IDENT) {
sym = lookup_symbol(token->ident, NS_STRUCT);
if (!sym ||
@@ -763,6 +764,7 @@ static struct token *struct_union_enum_specifier(enum type type,
token = parse(token->next, sym);
token = expect(token, '}', "at end of specifier");
+ apply_ctype(token->pos, &sym->ctype, &attr.ctype);
sym->endpos = token->pos;