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 Add two levels for -Wunused-const-variable.


On 02/20/2016 06:42 PM, Mark Wielaard wrote:
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
header 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.
Note that given the discussion in the BZ, I'm going to consider this a regression and thus eligible for the trunk.


diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 0a745f0..27a073a 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -971,7 +974,7 @@ check_global_declaration (symtab_node *snode)
  		(TREE_CODE (decl) == FUNCTION_DECL)
  		? OPT_Wunused_function
  		: (TREE_READONLY (decl)
-		   ? OPT_Wunused_const_variable
+		   ? OPT_Wunused_const_variable_
Typo here?


If that's not a typo, then just say so and this is approved. If it is a typo, the patch is approved with the typo fixed appropriately.

jeff


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