aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2015-07-27 12:40:45 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2015-07-27 12:40:45 +0000
commit05b28fd6f91016151e758c2414d7245a54512c99 (patch)
treea50a804e0d3bacf0015564dabec36d9c9121f14d /gcc/doc
parent0fd357f27d55de9d05662ebce1f166974891f52e (diff)
downloadgcc-05b28fd6f91016151e758c2414d7245a54512c99.zip
gcc-05b28fd6f91016151e758c2414d7245a54512c99.tar.gz
gcc-05b28fd6f91016151e758c2414d7245a54512c99.tar.bz2
re PR c++/66555 (Fails to warn for if (j == 0 && i == i))
PR c++/66555 PR c/54979 * c-common.c (find_array_ref_with_const_idx_r): New function. (warn_tautological_cmp): New function. * c-common.h (warn_tautological_cmp): Declare. * c.opt (Wtautological-compare): New option. * c-typeck.c (parser_build_binary_op): Call warn_tautological_cmp. * call.c (build_new_op_1): Call warn_tautological_cmp. * pt.c (tsubst_copy_and_build): Use sentinel to suppress tautological compare warnings. * doc/invoke.texi: Document -Wtautological-compare. * c-c++-common/Wtautological-compare-1.c: New test. From-SVN: r226242
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/invoke.texi17
1 files changed, 16 insertions, 1 deletions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 54e7a67..e988444 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -283,7 +283,8 @@ Objective-C and Objective-C++ Dialects}.
-Wsuggest-final-types @gol -Wsuggest-final-methods -Wsuggest-override @gol
-Wmissing-format-attribute @gol
-Wswitch -Wswitch-default -Wswitch-enum -Wswitch-bool -Wsync-nand @gol
--Wsystem-headers -Wtrampolines -Wtrigraphs -Wtype-limits -Wundef @gol
+-Wsystem-headers -Wtautological-compare -Wtrampolines -Wtrigraphs @gol
+-Wtype-limits -Wundef @gol
-Wuninitialized -Wunknown-pragmas -Wno-pragmas @gol
-Wunsuffixed-float-constants -Wunused -Wunused-function @gol
-Wunused-label -Wunused-local-typedefs -Wunused-parameter @gol
@@ -3452,6 +3453,7 @@ Options} and @ref{Objective-C and Objective-C++ Dialect Options}.
-Wenum-compare @r{(in C/ObjC; this is on by default in C++)} @gol
-Wimplicit-int @r{(C and Objective-C only)} @gol
-Wimplicit-function-declaration @r{(C and Objective-C only)} @gol
+-Wbool-compare @gol
-Wcomment @gol
-Wformat @gol
-Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)} @gol
@@ -3468,6 +3470,7 @@ Options} and @ref{Objective-C and Objective-C++ Dialect Options}.
-Wstrict-aliasing @gol
-Wstrict-overflow=1 @gol
-Wswitch @gol
+-Wtautological-compare @gol
-Wtrigraphs @gol
-Wuninitialized @gol
-Wunknown-pragmas @gol
@@ -4513,6 +4516,18 @@ code. However, note that using @option{-Wall} in conjunction with this
option does @emph{not} warn about unknown pragmas in system
headers---for that, @option{-Wunknown-pragmas} must also be used.
+@item -Wtautological-compare
+@opindex Wtautological-compare
+@opindex Wno-tautological-compare
+Warn if a self-comparison always evaluates to true or false. This
+warning detects various mistakes such as:
+@smallexample
+int i = 1;
+@dots{}
+if (i > i) @{ @dots{} @}
+@end smallexample
+This warning is enabled by @option{-Wall}.
+
@item -Wtrampolines
@opindex Wtrampolines
@opindex Wno-trampolines