This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR28901 -Wunused-variable ignores unused const initialised variables


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]