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@xxxxxxxxx> --- evaluate.c | 4 ++-- options.c | 2 ++ options.h | 1 + sparse.1 | 7 +++++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/evaluate.c b/evaluate.c index 9990b57bba78..794f8425f064 100644 --- a/evaluate.c +++ b/evaluate.c @@ -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; } diff --git a/options.c b/options.c index f7e81b84d749..9538a2171d33 100644 --- a/options.c +++ b/options.c @@ -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 }, diff --git a/options.h b/options.h index 070c0dd87183..90358752f213 100644 --- a/options.h +++ b/options.h @@ -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; diff --git a/sparse.1 b/sparse.1 index 60203d5a6463..34e66088f307 100644 --- a/sparse.1 +++ b/sparse.1 @@ -345,6 +345,13 @@ Standard C syntax does not permit a parenthesized string as an array initializer. GCC allows this syntax as an extension. With \fB\-Wparen\-string\fR, Sparse will warn about this syntax. +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 -- 2.28.0