aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-08-08 23:37:15 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-08-08 18:44:49 +0200
commit437aaeabe6f148825c1e7abd36a6a98b5b2244ae (patch)
treeba19fa6a8a9f5a04c23f6c9e5a1d22d7fd205514
parent13252024246cc03fc8cc0d812c61421f96faa3c7 (diff)
downloadsparse-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.c4
-rw-r--r--options.c2
-rw-r--r--options.h1
-rw-r--r--sparse.17
4 files changed, 12 insertions, 2 deletions
diff --git a/evaluate.c b/evaluate.c
index 9990b57b..794f8425 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 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/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.