diff options
author | Stephen Hemminger <shemminger@osdl.org> | 2004-07-15 21:13:55 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:02:12 -0700 |
commit | a1ec3c79c0f648d2f96531e068325233c54f101f (patch) | |
tree | abca06ec3ce149d73695f851159c849db9b08f3f /expression.c | |
parent | The base type of an enum is "int". (diff) | |
download | sparse-a1ec3c79c0f648d2f96531e068325233c54f101f.tar.gz sparse-a1ec3c79c0f648d2f96531e068325233c54f101f.tar.bz2 sparse-a1ec3c79c0f648d2f96531e068325233c54f101f.zip |
[PATCH] teach sparse about __alignof__
This teaches sparse what __alignof__ really means, instead of just using
the same code as "__sizeof__"
It gets rid of the warnings in ebtables that does:
struct ebt_entries {
...
char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)));
};
Which caused warning because sparse was evaluating __alignof__ as the same as sizeof,
and sizeof was 57 (ie non-power of 2).
This is just based on the existing code and a peek at the data
structures in expression and symbol.
Diffstat (limited to 'expression.c')
-rw-r--r-- | expression.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/expression.c b/expression.c index 5b817bb..6a705f9 100644 --- a/expression.c +++ b/expression.c @@ -370,17 +370,28 @@ static struct token *postfix_expression(struct token *token, struct expression * static struct token *cast_expression(struct token *token, struct expression **tree); static struct token *unary_expression(struct token *token, struct expression **tree) { - if (token_type(token) == TOKEN_IDENT && - (token->ident == &sizeof_ident || - token->ident == &__alignof___ident)) { - struct expression *sizeof_ex = alloc_expression(token->pos, EXPR_SIZEOF); - *tree = sizeof_ex; - tree = &sizeof_ex->unop; - token = token->next; - if (!match_op(token, '(') || !lookup_type(token->next)) - return unary_expression(token, &sizeof_ex->cast_expression); - token = typename(token->next, &sizeof_ex->cast_type); - return expect(token, ')', "at end of sizeof type-name"); + if (token_type(token) == TOKEN_IDENT) { + if (token->ident == &sizeof_ident) { + struct expression *sizeof_ex + = alloc_expression(token->pos, EXPR_SIZEOF); + *tree = sizeof_ex; + tree = &sizeof_ex->unop; + token = token->next; + if (!match_op(token, '(') || !lookup_type(token->next)) + return unary_expression(token, &sizeof_ex->cast_expression); + token = typename(token->next, &sizeof_ex->cast_type); + return expect(token, ')', "at end of sizeof type-name"); + } else if (token->ident == &__alignof___ident) { + struct expression *alignof_ex + = alloc_expression(token->pos, EXPR_ALIGNOF); + *tree = alignof_ex; + tree = &alignof_ex->unop; + token = token->next; + if (!match_op(token, '(') || !lookup_type(token->next)) + return unary_expression(token, &alignof_ex->cast_expression); + token = typename(token->next, &alignof_ex->cast_type); + return expect(token, ')', "at end of alignof type-name"); + } } if (token_type(token) == TOKEN_SPECIAL) { |