diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-02-18 22:14:03 +0100 |
|---|---|---|
| committer | Christopher Li <sparse@chrisli.org> | 2017-03-04 00:45:38 +0800 |
| commit | 0dfda0d1f0fe672c5aabdaf67665ec9b5aeaa4ac (patch) | |
| tree | 017e6e4933f25653d7762e3f1af3a7e6a7bea209 | |
| parent | df57533b37f0dc37b3e57f4647e3b7db423b5a61 (diff) | |
| download | sparse-dev-0dfda0d1f0fe672c5aabdaf67665ec9b5aeaa4ac.tar.gz | |
make -Wbitwise operational again
The flag -Wbitwise have no effect since patch 02a886bfa
("Introduce keyword driven attribute parsing"): the corresponding
checks are now always done.
Fix that by reintroducing it in the same way as it was:
ignore the bitwise attribute if the flag is not set.
It's less invasive that checking the flag at each place
an corresponding warning is emitted.
Also, to not perturb the current situation the flag is now
enabled by default.
Reported-by: Edward Cree <ecree@solarflare.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
| -rw-r--r-- | lib.c | 2 | ||||
| -rw-r--r-- | parse.c | 16 |
2 files changed, 15 insertions, 3 deletions
@@ -216,7 +216,7 @@ static struct token *pre_buffer_begin = NULL; static struct token *pre_buffer_end = NULL; int Waddress_space = 1; -int Wbitwise = 0; +int Wbitwise = 1; int Wcast_to_as = 0; int Wcast_truncate = 1; int Wcontext = 1; @@ -79,6 +79,7 @@ typedef struct token *attr_t(struct token *, struct symbol *, static attr_t attribute_packed, attribute_aligned, attribute_modifier, + attribute_bitwise, attribute_address_space, attribute_context, attribute_designated_init, attribute_transparent_union, ignore_attribute, @@ -339,6 +340,10 @@ static struct symbol_op attr_mod_op = { .attribute = attribute_modifier, }; +static struct symbol_op attr_bitwise_op = { + .attribute = attribute_bitwise, +}; + static struct symbol_op attr_force_op = { .attribute = attribute_force, }; @@ -496,8 +501,8 @@ static struct init_keyword { { "noderef", NS_KEYWORD, MOD_NODEREF, .op = &attr_mod_op }, { "safe", NS_KEYWORD, MOD_SAFE, .op = &attr_mod_op }, { "force", NS_KEYWORD, .op = &attr_force_op }, - { "bitwise", NS_KEYWORD, MOD_BITWISE, .op = &attr_mod_op }, - { "__bitwise__",NS_KEYWORD, MOD_BITWISE, .op = &attr_mod_op }, + { "bitwise", NS_KEYWORD, MOD_BITWISE, .op = &attr_bitwise_op }, + { "__bitwise__",NS_KEYWORD, MOD_BITWISE, .op = &attr_bitwise_op }, { "address_space",NS_KEYWORD, .op = &address_space_op }, { "mode", NS_KEYWORD, .op = &mode_op }, { "context", NS_KEYWORD, .op = &context_op }, @@ -1105,6 +1110,13 @@ static struct token *attribute_modifier(struct token *token, struct symbol *attr return token; } +static struct token *attribute_bitwise(struct token *token, struct symbol *attr, struct decl_state *ctx) +{ + if (Wbitwise) + attribute_modifier(token, attr, ctx); + return token; +} + static struct token *attribute_address_space(struct token *token, struct symbol *attr, struct decl_state *ctx) { struct expression *expr = NULL; |
