diff options
-rw-r--r-- | evaluate.c | 6 | ||||
-rw-r--r-- | options.c | 2 | ||||
-rw-r--r-- | options.h | 1 | ||||
-rw-r--r-- | parse.c | 2 | ||||
-rw-r--r-- | sparse.1 | 7 |
5 files changed, 13 insertions, 5 deletions
@@ -2198,8 +2198,6 @@ static int is_promoted(struct expression *expr) } -static struct symbol *evaluate_cast(struct expression *); - static struct symbol *evaluate_type_information(struct expression *expr) { struct symbol *sym = expr->cast_type; @@ -2618,7 +2616,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); @@ -2651,7 +2649,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; @@ -1180,7 +1180,7 @@ static struct token *attribute_address_space(struct token *token, struct symbol if (Waddress_space && as) { if (ctx->ctype.as) sparse_error(token->pos, - "multiple address space given: %s & %s", + "multiple address spaces given: %s & %s", show_as(ctx->ctype.as), show_as(as)); ctx->ctype.as = as; } @@ -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. |