Commit 49012f5c by Mark Mitchell Committed by Mark Mitchell

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
parent 5681c890
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>
......
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.
......
/* { 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() { }
......@@ -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. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment