diff options
author | 2006-07-31 22:24:56 -0700 | |
---|---|---|
committer | 2006-07-31 22:24:56 -0700 | |
commit | bcf44fe7402c3d1a1c9c21226d1ae5e9afefb10a (patch) | |
tree | 4f2483661fab643857598cc60e8464b72d82caa0 /symbol.c | |
parent | [PATCH] Fix -Wtypesign (diff) | |
download | sparse-bcf44fe7402c3d1a1c9c21226d1ae5e9afefb10a.tar.gz sparse-bcf44fe7402c3d1a1c9c21226d1ae5e9afefb10a.tar.bz2 sparse-bcf44fe7402c3d1a1c9c21226d1ae5e9afefb10a.zip |
First cut at something that approaches a sane -Wshadow
Let's see if it's useful. The ones it reported for git seemed
reasonable, certainly more so than the gcc ones.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'symbol.c')
-rw-r--r-- | symbol.c | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -427,6 +427,7 @@ struct symbol *examine_symbol_type(struct symbol * sym) void check_declaration(struct symbol *sym) { + int warned = 0; struct symbol *next = sym; while ((next = next->next_id) != NULL) { @@ -440,16 +441,14 @@ void check_declaration(struct symbol *sym) sym->same_symbol = next; return; } -#if 0 - // This may make sense from a warning standpoint: - // consider top-level symbols to clash with everything - // (but the scoping rules will mean that we actually - // _use_ the innermost version) - if (toplevel(next->scope)) { - sym->same_symbol = next; - return; - } -#endif + + if (!Wshadow || warned) + continue; + if (get_sym_type(next) == SYM_FN) + continue; + warned = 1; + warning(sym->pos, "symbol '%s' shadows an earlier one", show_ident(sym->ident)); + info(next->pos, "originally declared here"); } } |