diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-08-08 23:37:15 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-08-08 18:44:49 +0200 |
commit | 437aaeabe6f148825c1e7abd36a6a98b5b2244ae (patch) | |
tree | ba19fa6a8a9f5a04c23f6c9e5a1d22d7fd205514 | |
parent | 13252024246cc03fc8cc0d812c61421f96faa3c7 (diff) | |
download | sparse-437aaeabe6f148825c1e7abd36a6a98b5b2244ae.tar.gz |
warning: conditionalize "advancing past deep designator"
The warning "advancing past deep designator" is issued when a
multi-level (deep) designator is followed by a non-designated one.
But it's far from clear what is the value of this warning, what
could be the confusion about this situation and what is special
about these 'deep' designators?
There are hundreds such occurrences in the kernel (394 in the configs
I use for testing) and GCC, clang and sparse have no problems to handle
them correctly. This means that there is also 0 chances that they
will be 'corrected'.
So, add conditionalize this warning with a '-Wpast-deep-designator'
and make it false by default.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | evaluate.c | 4 | ||||
-rw-r--r-- | options.c | 2 | ||||
-rw-r--r-- | options.h | 1 | ||||
-rw-r--r-- | sparse.1 | 7 |
4 files changed, 12 insertions, 2 deletions
@@ -2614,7 +2614,7 @@ static void handle_list_initializer(struct expression *expr, int class, struct symbol *ctype, unsigned long mods) { struct expression *e, *last = NULL, *top = NULL, *next; - int jumped = 0; + int jumped = 0; // has the last designator multiple levels? if (expr->zero_init) free_ptr_list(&expr->expr_list); @@ -2647,7 +2647,7 @@ static void handle_list_initializer(struct expression *expr, ctype->ident ? ": " : "", get_type_name(struct_sym->type), show_ident(struct_sym->ident)); - if (jumped) { + if (jumped && Wpast_deep_designator) { warning(e->pos, "advancing past deep designator"); jumped = 0; } @@ -113,6 +113,7 @@ int Woverride_init = 1; int Woverride_init_all = 0; int Woverride_init_whole_range = 0; int Wparen_string = 0; +int Wpast_deep_designator = 0; int Wpedantic = 0; int Wpointer_arith = 0; int Wpointer_to_int_cast = 1; @@ -850,6 +851,7 @@ static const struct flag warnings[] = { { "override-init", &Woverride_init }, { "override-init-all", &Woverride_init_all }, { "paren-string", &Wparen_string }, + { "past-deep-designator", &Wpast_deep_designator }, { "pedantic", &Wpedantic }, { "pointer-to-int-cast", &Wpointer_to_int_cast }, { "ptr-subtraction-blows", &Wptr_subtraction_blows }, @@ -112,6 +112,7 @@ extern int Woverride_init; extern int Woverride_init_all; extern int Woverride_init_whole_range; extern int Wparen_string; +extern int Wpast_deep_designator; extern int Wpedantic; extern int Wpointer_arith; extern int Wpointer_to_int_cast; @@ -348,6 +348,13 @@ initializer. GCC allows this syntax as an extension. With Sparse does not issue these warnings by default. . .TP +.B -Wpast-deep-designator +Warn when, in a initializer-list, a initializer with a deep (nested) +designator is followed by a non-designated one. + +Sparse does not issue these warnings by default. +. +.TP .B \-Wpointer\-arith Warn about anything that depends on the \fBsizeof\fR a void or function type. |