public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/23228] New: Silly "unused variable" warning after redeclaration of a local variable
@ 2005-08-04 11:16 steven at gcc dot gnu dot org
  2005-08-04 12:20 ` [Bug c/23228] " gdr at integrable-solutions dot net
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-08-04 11:16 UTC (permalink / raw)
  To: gcc-bugs

Maybe there are similar issues elsewhere, but this one happened  
to bother me...  This warning is also issed by GCC 3.3, so I guess 
it is not a regression.  But it's a silly warning after errors. 
 
=================== t.c ===================  
int bar (void);  
int foo (void)  
{  
  int i;  
  int i;  
  i = bar ();  
  return 2*i;  
}  
===========================================  
  
$ gcc -Wall -Wextra -O2 t.c  
t.c: In function 'foo':  
t.c:5: error: redeclaration of 'i' with no linkage  
t.c:4: error: previous declaration of 'i' was here  
t.c:4: warning: unused variable 'i'  
$

-- 
           Summary: Silly "unused variable" warning after redeclaration of a
                    local variable
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: steven at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org,jsm28 at gcc dot gnu dot
                    org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23228


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c/23228] Silly "unused variable" warning after redeclaration of a local variable
  2005-08-04 11:16 [Bug c/23228] New: Silly "unused variable" warning after redeclaration of a local variable steven at gcc dot gnu dot org
@ 2005-08-04 12:20 ` gdr at integrable-solutions dot net
  2005-08-04 13:04 ` [Bug c/23228] [3.4/4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-08-04 12:20 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2005-08-04 12:20 -------
Subject: Re:  New: Silly "unused variable" warning after redeclaration of a local variable

"steven at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| Maybe there are similar issues elsewhere, but this one happened  
| to bother me...  This warning is also issed by GCC 3.3, so I guess 
| it is not a regression.  But it's a silly warning after errors. 

Agreed.

-- Gaby


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23228


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c/23228] [3.4/4.0/4.1 Regression] Silly "unused variable" warning after redeclaration of a local variable
  2005-08-04 11:16 [Bug c/23228] New: Silly "unused variable" warning after redeclaration of a local variable steven at gcc dot gnu dot org
  2005-08-04 12:20 ` [Bug c/23228] " gdr at integrable-solutions dot net
@ 2005-08-04 13:04 ` pinskia at gcc dot gnu dot org
  2005-08-08 18:19 ` pinskia at gcc dot gnu dot org
  2005-09-27 16:17 ` mmitchel at gcc dot gnu dot org
  3 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-04 13:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-04 13:04 -------
Confirmed, a regression from 3.0.4 and 2.95.3.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
      Known to fail|                            |3.3 3.2.3 3.4.0 4.0.0 4.1.0
      Known to work|                            |3.0.4 2.95.3
   Last reconfirmed|0000-00-00 00:00:00         |2005-08-04 13:04:17
               date|                            |
            Summary|Silly "unused variable"     |[3.4/4.0/4.1 Regression]
                   |warning after redeclaration |Silly "unused variable"
                   |of a local variable         |warning after redeclaration
                   |                            |of a local variable
   Target Milestone|---                         |4.0.2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23228


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c/23228] [3.4/4.0/4.1 Regression] Silly "unused variable" warning after redeclaration of a local variable
  2005-08-04 11:16 [Bug c/23228] New: Silly "unused variable" warning after redeclaration of a local variable steven at gcc dot gnu dot org
  2005-08-04 12:20 ` [Bug c/23228] " gdr at integrable-solutions dot net
  2005-08-04 13:04 ` [Bug c/23228] [3.4/4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
@ 2005-08-08 18:19 ` pinskia at gcc dot gnu dot org
  2005-09-27 16:17 ` mmitchel at gcc dot gnu dot org
  3 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-08 18:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-08 18:19 -------
This was introduced between 20020216  and 20020223. 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23228


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c/23228] [3.4/4.0/4.1 Regression] Silly "unused variable" warning after redeclaration of a local variable
  2005-08-04 11:16 [Bug c/23228] New: Silly "unused variable" warning after redeclaration of a local variable steven at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2005-08-08 18:19 ` pinskia at gcc dot gnu dot org
@ 2005-09-27 16:17 ` mmitchel at gcc dot gnu dot org
  3 siblings, 0 replies; 7+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-09-27 16:17 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.2                       |4.0.3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23228


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c/23228] [3.4/4.0/4.1 Regression] Silly "unused variable" warning after redeclaration of a local variable
       [not found] <bug-23228-280@http.gcc.gnu.org/bugzilla/>
  2005-10-12 19:37 ` steven at gcc dot gnu dot org
@ 2005-10-19 14:48 ` cvs-commit at gcc dot gnu dot org
  1 sibling, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-10-19 14:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from cvs-commit at gcc dot gnu dot org  2005-10-19 14:48 -------
Subject: Bug 23228

CVSROOT:        /cvs/gcc
Module name:    gcc
Changes by:     steven@gcc.gnu.org      2005-10-19 14:48:34

Modified files:
        gcc            : ChangeLog c-decl.c 

Log message:
        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.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.10188&r2=2.10189
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&r1=1.687&r2=1.688


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23228


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c/23228] [3.4/4.0/4.1 Regression] Silly "unused variable" warning after redeclaration of a local variable
       [not found] <bug-23228-280@http.gcc.gnu.org/bugzilla/>
@ 2005-10-12 19:37 ` steven at gcc dot gnu dot org
  2005-10-19 14:48 ` cvs-commit at gcc dot gnu dot org
  1 sibling, 0 replies; 7+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-10-12 19:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from steven at gcc dot gnu dot org  2005-10-12 19:37 -------
What about this....

Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.687
diff -u -3 -p -r1.687 c-decl.c
--- c-decl.c    4 Oct 2005 13:58:41 -0000       1.687
+++ c-decl.c    12 Oct 2005 19:33:17 -0000
@@ -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 oldd
   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;


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23228


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-10-19 14:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-04 11:16 [Bug c/23228] New: Silly "unused variable" warning after redeclaration of a local variable steven at gcc dot gnu dot org
2005-08-04 12:20 ` [Bug c/23228] " gdr at integrable-solutions dot net
2005-08-04 13:04 ` [Bug c/23228] [3.4/4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
2005-08-08 18:19 ` pinskia at gcc dot gnu dot org
2005-09-27 16:17 ` mmitchel at gcc dot gnu dot org
     [not found] <bug-23228-280@http.gcc.gnu.org/bugzilla/>
2005-10-12 19:37 ` steven at gcc dot gnu dot org
2005-10-19 14:48 ` cvs-commit at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).