diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-06-29 00:35:44 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-09-01 22:41:24 +0200 |
| commit | d96da358cfa0432f067a4e66940765883b80ee62 (patch) | |
| tree | e11005607bf311160dbd3ae033abe44be1f1fe20 /lib.c | |
| parent | 4fd434fd65a494592fef81937254ba89c9ae6546 (diff) | |
| download | sparse-dev-d96da358cfa0432f067a4e66940765883b80ee62.tar.gz | |
stricter warning for explicit cast to ulong
sparse issues a warning when user pointers are casted to integer
types except to unsigned longs which are explicitly allowed.
However it may happen that we would like to also be warned
on casts to unsigned long.
Fix this by adding a new warning flag: -Wcast-from-as (to mirrors
-Wcast-to-as) which extends -Waddress-space to all casts that
remove an address space attribute (without using __force).
References: https://lore.kernel.org/lkml/20180628102741.vk6vphfinlj3lvhv@armageddon.cambridge.arm.com/
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'lib.c')
| -rw-r--r-- | lib.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -248,6 +248,7 @@ static struct token *pre_buffer_end = NULL; int Waddress = 0; int Waddress_space = 1; int Wbitwise = 1; +int Wcast_from_as = 0; int Wcast_to_as = 0; int Wcast_truncate = 1; int Wconstexpr_not_const = 0; @@ -682,6 +683,7 @@ static const struct flag warnings[] = { { "address", &Waddress }, { "address-space", &Waddress_space }, { "bitwise", &Wbitwise }, + { "cast-from-as", &Wcast_from_as }, { "cast-to-as", &Wcast_to_as }, { "cast-truncate", &Wcast_truncate }, { "constexpr-not-const", &Wconstexpr_not_const}, |
