]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/13029 (static consts and -Wunused-variable)
authorMark Mitchell <mark@codesourcery.com>
Thu, 13 Nov 2003 19:40:19 +0000 (19:40 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 13 Nov 2003 19:40:19 +0000 (19:40 +0000)
PR c/13029
* toplev.c (check_global_declarations): Do not warn about unused
static consts.

PR c/13029
* gcc.dg/unused-4.c: Update.

Co-Authored-By: Kean Johnston <jkj@sco.com>
From-SVN: r73554

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/unused-4.c
gcc/toplev.c

index 4bf3f91a5e860aeb47089ab3b117b646ade737d8..31dfb24199b002da59381e06e0ef7f1df05efdfa 100644 (file)
@@ -1,3 +1,10 @@
+2003-11-13  Mark Mitchell  <mark@codesourcery.com>
+            Kean Johnston <jkj@sco.com>
+
+       PR c/13029
+       * toplev.c (check_global_declarations): Do not warn about unused
+       static consts.
+
 2003-11-13  Pavel Pisa  <pisa@cmp.felk.cvut.cz>
            Kazu Hirata  <kazu@cs.umass.edu>
 
index ba653cbe109ddfe73e782882f381c4797f0174ae..4d418b034c65c2ce8ccdac83721bda7c10ef1b3e 100644 (file)
@@ -1,3 +1,9 @@
+2003-11-13  Mark Mitchell  <mark@codesourcery.com>
+            Kean Johnston <jkj@sco.com>
+
+       PR c/13029
+       * gcc.dg/unused-4.c: Update.
+
 2003-11-13  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * g++.dg/opt/const3.C: New test.
index 53236008007ad9338d1dbc5b34a329966a440844..99e845f45a3c1bb1d2ff434edfe9b97f447e331c 100644 (file)
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-Wunused -O3" } */
 
-static const int i = 0;                /* { dg-warning "defined but not used" } */
+static const int i = 0;
 static void f() { }            /* { dg-warning "defined but not used" } */
 static inline void g() { }
index a1a1d73f3782a8c4c8f139816a1850784a679e53..cacbb244ae4251e1450abbfe4a9cbf7b6d4d3200 100644 (file)
@@ -1720,7 +1720,11 @@ check_global_declarations (tree *vec, int len)
 
       /* Warn about static fns or vars defined but not used.  */
       if (((warn_unused_function && TREE_CODE (decl) == FUNCTION_DECL)
-          || (warn_unused_variable && TREE_CODE (decl) == VAR_DECL))
+          /* We don't warn about "static const" variables because the
+             "rcs_id" idiom uses that construction.  */
+          || (warn_unused_variable
+              && TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
+         && ! DECL_IN_SYSTEM_HEADER (decl)
          && ! TREE_USED (decl)
          /* The TREE_USED bit for file-scope decls is kept in the identifier,
             to handle multiple external decls in different scopes.  */