This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/28901] -Wunused-variable ignores unused const initialised variables
- From: "mark at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 22 Feb 2016 22:42:50 +0000
- Subject: [Bug c/28901] -Wunused-variable ignores unused const initialised variables
- Auto-submitted: auto-generated
- References: <bug-28901-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28901
--- Comment #32 from Mark Wielaard <mark at gcc dot gnu.org> ---
Author: mark
Date: Mon Feb 22 22:42:19 2016
New Revision: 233616
URL: https://gcc.gnu.org/viewcvs?rev=233616&root=gcc&view=rev
Log:
PR28901 Add two levels for -Wunused-const-variable.
There is some controversy about enabling -Wunused-const-variable for all
unused static const variables because some feel there are too many errors
exposed in header files. Create two levels for -Wunused-const-variable.
One level to only check for unused static const variables in the main
compilation file. Which is enabled by -Wunused-variable. And a second
level that also checks for unused static const variables in included
files. Which must be explicitly enabled.
gcc/ChangeLog
PR c/28901
* cgraphunit.c (check_global_declaration): Check level of
warn_unused_const_variable and main_input_filename.
* doc/invoke.texi (Warning Options): Add -Wunused-const-variable=.
(-Wunused-variable): For C implies -Wunused-const-variable=1.
(-Wunused-const-variable): Explain levels 1 and 2.
gcc/c-family/ChangeLog
PR c/28901
* c.opt (Wunused-const-variable): Turn into Alias for...
(Wunused-const-variable=): New option.
gcc/testsuite/ChangeLog
PR c/28901
* gcc.dg/unused-variable-3.c: New test.
Added:
trunk/gcc/testsuite/gcc.dg/unused-variable-3.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c.opt
trunk/gcc/cgraphunit.c
trunk/gcc/doc/invoke.texi
trunk/gcc/testsuite/ChangeLog