diff options
author | Al Viro <viro@ftp.linux.org.uk> | 2009-03-09 07:12:58 +0000 |
---|---|---|
committer | Christopher Li <sparse@chrisli.org> | 2009-07-18 05:29:55 +0000 |
commit | e0c5b2f5c4c54389ea02259221a2895c526784ff (patch) | |
tree | 4f75a9c6e8deb2bbd8448e83c234fc42a7332091 /parse.c | |
parent | Pass decl_state down to ->declarator() and handle_attributes() (diff) | |
download | sparse-e0c5b2f5c4c54389ea02259221a2895c526784ff.tar.gz sparse-e0c5b2f5c4c54389ea02259221a2895c526784ff.tar.bz2 sparse-e0c5b2f5c4c54389ea02259221a2895c526784ff.zip |
Pass decl_state down to ->attribute()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'parse.c')
-rw-r--r-- | parse.c | 37 |
1 files changed, 19 insertions, 18 deletions
@@ -58,7 +58,8 @@ static struct token *parse_range_statement(struct token *token, struct statement static struct token *parse_asm_statement(struct token *token, struct statement *stmt); static struct token *toplevel_asm_declaration(struct token *token, struct symbol_list **list); -typedef struct token *attr_t(struct token *, struct symbol *, struct ctype *); +typedef struct token *attr_t(struct token *, struct symbol *, + struct decl_state *); static attr_t attribute_packed, attribute_aligned, attribute_modifier, @@ -912,7 +913,7 @@ static struct token *typeof_specifier(struct token *token, struct decl_state *ct return expect(token, ')', "after typeof"); } -static struct token *ignore_attribute(struct token *token, struct symbol *attr, struct ctype *ctype) +static struct token *ignore_attribute(struct token *token, struct symbol *attr, struct decl_state *ctx) { struct expression *expr = NULL; if (match_op(token, '(')) @@ -920,14 +921,14 @@ static struct token *ignore_attribute(struct token *token, struct symbol *attr, return token; } -static struct token *attribute_packed(struct token *token, struct symbol *attr, struct ctype *ctype) +static struct token *attribute_packed(struct token *token, struct symbol *attr, struct decl_state *ctx) { - if (!ctype->alignment) - ctype->alignment = 1; + if (!ctx->ctype.alignment) + ctx->ctype.alignment = 1; return token; } -static struct token *attribute_aligned(struct token *token, struct symbol *attr, struct ctype *ctype) +static struct token *attribute_aligned(struct token *token, struct symbol *attr, struct decl_state *ctx) { int alignment = max_alignment; struct expression *expr = NULL; @@ -940,8 +941,8 @@ static struct token *attribute_aligned(struct token *token, struct symbol *attr, if (alignment & (alignment-1)) { warning(token->pos, "I don't like non-power-of-2 alignments"); return token; - } else if (alignment > ctype->alignment) - ctype->alignment = alignment; + } else if (alignment > ctx->ctype.alignment) + ctx->ctype.alignment = alignment; return token; } @@ -952,13 +953,13 @@ static void apply_qualifier(struct position *pos, struct ctype *ctx, unsigned lo ctx->modifiers |= qual; } -static struct token *attribute_modifier(struct token *token, struct symbol *attr, struct ctype *ctype) +static struct token *attribute_modifier(struct token *token, struct symbol *attr, struct decl_state *ctx) { - apply_qualifier(&token->pos, ctype, attr->ctype.modifiers); + apply_qualifier(&token->pos, &ctx->ctype, attr->ctype.modifiers); return token; } -static struct token *attribute_address_space(struct token *token, struct symbol *attr, struct ctype *ctype) +static struct token *attribute_address_space(struct token *token, struct symbol *attr, struct decl_state *ctx) { struct expression *expr = NULL; int as; @@ -967,19 +968,19 @@ static struct token *attribute_address_space(struct token *token, struct symbol if (expr) { as = const_expression_value(expr); if (as) - ctype->as = as; + ctx->ctype.as = as; } token = expect(token, ')', "after address_space attribute"); return token; } -static struct token *attribute_mode(struct token *token, struct symbol *attr, struct ctype *ctype) +static struct token *attribute_mode(struct token *token, struct symbol *attr, struct decl_state *ctx) { token = expect(token, '(', "after mode attribute"); if (token_type(token) == TOKEN_IDENT) { struct symbol *mode = lookup_keyword(token->ident, NS_KEYWORD); if (mode && mode->op->type == KW_MODE) - ctype->modifiers |= mode->ctype.modifiers; + ctx->ctype.modifiers |= mode->ctype.modifiers; else sparse_error(token->pos, "unknown mode attribute %s\n", show_ident(token->ident)); token = token->next; @@ -989,7 +990,7 @@ static struct token *attribute_mode(struct token *token, struct symbol *attr, st return token; } -static struct token *attribute_context(struct token *token, struct symbol *attr, struct ctype *ctype) +static struct token *attribute_context(struct token *token, struct symbol *attr, struct decl_state *ctx) { struct context *context = alloc_context(); struct expression *args[3]; @@ -1027,13 +1028,13 @@ static struct token *attribute_context(struct token *token, struct symbol *attr, } if (argc) - add_ptr_list(&ctype->contexts, context); + add_ptr_list(&ctx->ctype.contexts, context); token = expect(token, ')', "after context attribute"); return token; } -static struct token *attribute_transparent_union(struct token *token, struct symbol *attr, struct ctype *ctype) +static struct token *attribute_transparent_union(struct token *token, struct symbol *attr, struct decl_state *ctx) { if (Wtransparent_union) warning(token->pos, "ignoring attribute __transparent_union__"); @@ -1069,7 +1070,7 @@ static struct token *attribute_specifier(struct token *token, struct decl_state attribute_name = token->ident; attr = lookup_keyword(attribute_name, NS_KEYWORD); if (attr && attr->op->attribute) - token = attr->op->attribute(token->next, attr, &ctx->ctype); + token = attr->op->attribute(token->next, attr, ctx); else token = recover_unknown_attribute(token); |