diff options
author | Mark Mitchell <mark@codesourcery.com> | 2003-11-13 19:40:19 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2003-11-13 19:40:19 +0000 |
commit | 49012f5c0f56b39c22a5bf5cf7a1f3626387eda7 (patch) | |
tree | 716926a333fcf41c178e37db6a6dd1685fe261b5 /gcc | |
parent | 5681c890b67c0f3c3134fb9897293866594cbd5c (diff) | |
download | gcc-49012f5c0f56b39c22a5bf5cf7a1f3626387eda7.zip gcc-49012f5c0f56b39c22a5bf5cf7a1f3626387eda7.tar.gz gcc-49012f5c0f56b39c22a5bf5cf7a1f3626387eda7.tar.bz2 |
re PR c/13029 (static consts and -Wunused-variable)
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/unused-4.c | 2 | ||||
-rw-r--r-- | gcc/toplev.c | 6 |
4 files changed, 19 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4bf3f91..31dfb24 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ba653cb..4d418b0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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. diff --git a/gcc/testsuite/gcc.dg/unused-4.c b/gcc/testsuite/gcc.dg/unused-4.c index 5323600..99e845f 100644 --- a/gcc/testsuite/gcc.dg/unused-4.c +++ b/gcc/testsuite/gcc.dg/unused-4.c @@ -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() { } diff --git a/gcc/toplev.c b/gcc/toplev.c index a1a1d73..cacbb24 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -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. */ |