aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2016-02-22 22:42:19 +0000
committerMark Wielaard <mark@gcc.gnu.org>2016-02-22 22:42:19 +0000
commit4246c8da675115145c206b475b2a224269bfd228 (patch)
treeca99c93ee8a42bd45375966c5fac2b44cca0e3f8 /gcc/doc
parent07bfc9c103a685d5ad59ce846188c449e81055df (diff)
downloadgcc-4246c8da675115145c206b475b2a224269bfd228.zip
gcc-4246c8da675115145c206b475b2a224269bfd228.tar.gz
gcc-4246c8da675115145c206b475b2a224269bfd228.tar.bz2
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. From-SVN: r233616
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/invoke.texi26
1 files changed, 21 insertions, 5 deletions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index c1ab788..490df93 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -303,7 +303,7 @@ Objective-C and Objective-C++ Dialects}.
-Wunsuffixed-float-constants -Wunused -Wunused-function @gol
-Wunused-label -Wunused-local-typedefs -Wunused-parameter @gol
-Wno-unused-result -Wunused-value @gol -Wunused-variable @gol
--Wunused-const-variable @gol
+-Wunused-const-variable -Wunused-const-variable=@var{n} @gol
-Wunused-but-set-parameter -Wunused-but-set-variable @gol
-Wuseless-cast -Wvariadic-macros -Wvector-operation-performance @gol
-Wvla -Wvolatile-register-var -Wwrite-strings @gol
@@ -4231,23 +4231,39 @@ its return value. The default is @option{-Wunused-result}.
@opindex Wunused-variable
@opindex Wno-unused-variable
Warn whenever a local or static variable is unused aside from its
-declaration. This option implies @option{-Wunused-const-variable} for C,
+declaration. This option implies @option{-Wunused-const-variable=1} for C,
but not for C++. This warning is enabled by @option{-Wall}.
To suppress this warning use the @code{unused} attribute
(@pxref{Variable Attributes}).
@item -Wunused-const-variable
+@itemx -Wunused-const-variable=@var{n}
@opindex Wunused-const-variable
@opindex Wno-unused-const-variable
Warn whenever a constant static variable is unused aside from its declaration.
-This warning is enabled by @option{-Wunused-variable} for C, but not for C++.
-In C++ this is normally not an error since const variables take the place of
-@code{#define}s in C++.
+@option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable}
+for C, but not for C++. In C this declares variable storage, but in C++ this
+is not an error since const variables take the place of @code{#define}s.
To suppress this warning use the @code{unused} attribute
(@pxref{Variable Attributes}).
+@table @gcctabopt
+@item -Wunused-const-variable=1
+This is the warning level that is enabled by @option{-Wunused-variable} for
+C. It warns only about unused static const variables defined in the main
+compilation unit, but not about static const variables declared in any
+header included.
+
+@item -Wunused-const-variable=2
+This warning level also warns for unused constant static variables in
+headers (excluding system headers). This is the warning level of
+@option{-Wunused-const-variable} and must be explicitly requested since
+in C++ this isn't an error and in C it might be harder to clean up all
+headers included.
+@end table
+
@item -Wunused-value
@opindex Wunused-value
@opindex Wno-unused-value