diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-03-30 09:49:13 -0700 |
---|---|---|
committer | Christopher Li <sparse@chrisli.org> | 2014-04-01 00:39:26 -0700 |
commit | 0f25c6a78e08fdc15af5e599d836fa24349c042f (patch) | |
tree | 7a03723257394bdd2c0768d8f068ae8cae7887cb /evaluate.c | |
parent | 7698bae699639892d639b8a9c270efdb8c46725c (diff) | |
download | sparse-0f25c6a78e08fdc15af5e599d836fa24349c042f.tar.gz |
Add warning about duplicate initializers
Noticed this while looking at an independent bug reported by Hans
Verkuil.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'evaluate.c')
-rw-r--r-- | evaluate.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -3081,10 +3081,18 @@ static void check_duplicates(struct symbol *sym) { int declared = 0; struct symbol *next = sym; + int initialized = sym->initializer != NULL; while ((next = next->same_symbol) != NULL) { const char *typediff; evaluate_symbol(next); + if (initialized && next->initializer) { + sparse_error(sym->pos, "symbol '%s' has multiple initializers (originally initialized at %s:%d)", + show_ident(sym->ident), + stream_name(next->pos.stream), next->pos.line); + /* Only warn once */ + initialized = 0; + } declared++; typediff = type_difference(&sym->ctype, &next->ctype, 0, 0); if (typediff) { |