re PR c/23228 (Silly "unused variable" warning after redeclaration of a local variable)
authorSteven Bosscher <stevenb@suse.de>
Wed, 19 Oct 2005 14:48:29 +0000 (14:48 +0000)
committerSteven Bosscher <steven@gcc.gnu.org>
Wed, 19 Oct 2005 14:48:29 +0000 (14:48 +0000)
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

gcc/ChangeLog
gcc/c-decl.c

index 45d936ae2730fcec96403b221b32053958034e24..886d1f8f431e565c20f03de62d5fc042a62eb942 100644 (file)
@@ -1,3 +1,11 @@
+2005-10-19  Steven Bosscher  <stevenb@suse.de>
+
+       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.
+
 2005-10-19  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        PR middle-end/23199
index c274df47ac4066c6553523034930207aa7ef609b..f7cad3b71051c8bddb87043d09bef069b533f488 100644 (file)
@@ -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;