diff options
author | Steven Bosscher <stevenb@suse.de> | 2005-10-19 14:48:29 +0000 |
---|---|---|
committer | Steven Bosscher <steven@gcc.gnu.org> | 2005-10-19 14:48:29 +0000 |
commit | f95f80d1a762998d6b8731d506f6667ccbdaf996 (patch) | |
tree | 988fb136daa7814e2926da81d9c274aa06aefc9d /gcc/c-decl.c | |
parent | e48050bd060e5faeae80c4c833e14fe3885ed599 (diff) | |
download | gcc-f95f80d1a762998d6b8731d506f6667ccbdaf996.zip gcc-f95f80d1a762998d6b8731d506f6667ccbdaf996.tar.gz gcc-f95f80d1a762998d6b8731d506f6667ccbdaf996.tar.bz2 |
re PR c/23228 (Silly "unused variable" warning after redeclaration of a local variable)
PR c/23228
* c-decl.c (pop_scope): Don't warn about an unused variable
if it is marked with TREE_NO_WARNING.
(duplicate_decls): Set TREE_NO_WARNING if olddecl and newdecl
somenow mismatch and olddecl is to be replaced.
From-SVN: r105621
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index c274df4..f7cad3b 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -803,6 +803,7 @@ pop_scope (void) case VAR_DECL: /* Warnings for unused variables. */ if (!TREE_USED (p) + && !TREE_NO_WARNING (p) && !DECL_IN_SYSTEM_HEADER (p) && DECL_NAME (p) && !DECL_ARTIFICIAL (p) @@ -1876,7 +1877,11 @@ duplicate_decls (tree newdecl, tree olddecl) tree newtype = NULL, oldtype = NULL; if (!diagnose_mismatched_decls (newdecl, olddecl, &newtype, &oldtype)) - return false; + { + /* Avoid `unused variable' and other warnings warnings for OLDDECL. */ + TREE_NO_WARNING (olddecl) = 1; + return false; + } merge_decls (newdecl, olddecl, newtype, oldtype); return true; |