This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR28901 -Wunused-variable ignores unused const initialised variables
- From: Bernd Schmidt <bschmidt at redhat dot com>
- To: Mark Wielaard <mjw at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Sat, 12 Sep 2015 00:29:05 +0200
- Subject: Re: [PATCH] PR28901 -Wunused-variable ignores unused const initialised variables
- Authentication-results: sourceware.org; auth=none
- References: <1442009555-13690-1-git-send-email-mjw at redhat dot com>
On 09/12/2015 12:12 AM, Mark Wielaard wrote:
12 years ago it was decided that -Wunused-variable shouldn't warn about
static const variables because some code used const static char rcsid[]
strings which were never used but wanted in the code anyway. But as the
bug points out this hides some real bugs. These days the usage of rcsids
is not very popular anymore. So this patch changes the default to warn
about unused static const variables with -Wunused-variable. And it adds
a new option -Wno-unused-const-variable to turn this warning off. New
testcases are included to test the new warning with -Wunused-variable
and suppressing it with -Wno-unused-const-variable or unused attribute.
PR c/28901
* gcc.dg/unused-4.c: Adjust warning for static const.
* gcc.dg/unused-variable-1.c: New test.
* gcc.dg/unused-variable-2.c: Likewise.
Should these go into c-c++-common? Otherwise I'm ok with the patch,
please wait a few days to see if there are objections to this change
then commit.
Bernd