aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--evaluate.c6
-rw-r--r--options.c2
-rw-r--r--options.h1
-rw-r--r--parse.c2
-rw-r--r--sparse.17
5 files changed, 13 insertions, 5 deletions
diff --git a/evaluate.c b/evaluate.c
index 1839e35d..3751039f 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -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;
}
diff --git a/options.c b/options.c
index f7e81b84..9538a217 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 070c0dd8..90358752 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/parse.c b/parse.c
index faf8fcb0..31ecef0f 100644
--- a/parse.c
+++ b/parse.c
@@ -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;
}
diff --git a/sparse.1 b/sparse.1
index 60203d5a..34e66088 100644
--- a/sparse.1
+++ b/sparse.1
@@ -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.