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