diff options
author | Christopher Li <sparse@chrisli.org> | 2013-04-25 18:09:43 -0700 |
---|---|---|
committer | Christopher Li <sparse@chrisli.org> | 2013-04-26 08:27:41 -0700 |
commit | 5449cfbfe55eea2a602a40122c122b5040d67243 (patch) | |
tree | 5338288223e6433c0c805f4d54665ca034191ee5 | |
parent | 9aadf85a29be2a74e46fc67b5313d41aee81dac7 (diff) | |
download | sparse-5449cfbfe55eea2a602a40122c122b5040d67243.tar.gz |
Allow forced attribute in function argumentv0.4.5-rc1
It will indicate this argument will skip the type compatible check.
It allow PTR_ERR() to accept __iomem pointer without complaining.
Signed-off-by: Christopher Li <sparse@chrisli.org>
-rw-r--r-- | evaluate.c | 2 | ||||
-rw-r--r-- | parse.c | 1 | ||||
-rw-r--r-- | symbol.h | 3 | ||||
-rw-r--r-- | validation/fored_arg.c | 18 |
4 files changed, 22 insertions, 2 deletions
@@ -2137,7 +2137,7 @@ static int evaluate_arguments(struct symbol *f, struct symbol *fn, struct expres else degenerate(expr); } - } else { + } else if (!target->forced_arg){ static char where[30]; examine_symbol_type(target); sprintf(where, "argument %d", i); @@ -1841,6 +1841,7 @@ static struct token *parameter_declaration(struct token *token, struct symbol *s sym->ctype = ctx.ctype; sym->ctype.modifiers |= storage_modifiers(&ctx); sym->endpos = token->pos; + sym->forced_arg = ctx.storage_class == SForced; return token; } @@ -157,7 +157,8 @@ struct symbol { expanding:1, evaluated:1, string:1, - designated_init:1; + designated_init:1, + forced_arg:1; struct expression *array_size; struct ctype ctype; struct symbol_list *arguments; diff --git a/validation/fored_arg.c b/validation/fored_arg.c new file mode 100644 index 00000000..4ab71419 --- /dev/null +++ b/validation/fored_arg.c @@ -0,0 +1,18 @@ +/* + * check-name: Forced function argument type. + */ + +#define __iomem __attribute__((noderef, address_space(2))) +#define __force __attribute__((force)) + +static void foo(__force void * addr) +{ +} + + +static void bar(void) +{ + void __iomem *a; + foo(a); +} + |