aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2014-08-19 18:50:00 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2014-08-19 18:50:00 +0000
commit04159acfd818cbc29a9d12dfa2e83716c106f2c7 (patch)
treec01c9d77dc28f6a4d017760a2f0f57809574d010 /gcc/doc
parent8a2e8325e4b35265ea983561eca4a23a13630b07 (diff)
downloadgcc-04159acfd818cbc29a9d12dfa2e83716c106f2c7.zip
gcc-04159acfd818cbc29a9d12dfa2e83716c106f2c7.tar.gz
gcc-04159acfd818cbc29a9d12dfa2e83716c106f2c7.tar.bz2
re PR c++/62153 (warn for bool expression compared with integer different from 0/1)
PR c++/62153 * doc/invoke.texi: Document -Wbool-compare. c-family/ * c-common.c (maybe_warn_bool_compare): New function. * c-common.h (maybe_warn_bool_compare): Declare. * c.opt (Wbool-compare): New option. c/ * c-typeck.c (build_binary_op): If either operand of a comparison is a boolean expression, call maybe_warn_bool_compare. cp/ * call.c (build_new_op_1): Remember the type of arguments for a comparison. If either operand of a comparison is a boolean expression, call maybe_warn_bool_compare. testsuite/ * c-c++-common/Wbool-compare-1.c: New test. From-SVN: r214183
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/invoke.texi14
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 8ea3689..b8e4294 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -240,6 +240,7 @@ Objective-C and Objective-C++ Dialects}.
-pedantic-errors @gol
-w -Wextra -Wall -Waddress -Waggregate-return @gol
-Waggressive-loop-optimizations -Warray-bounds @gol
+-Wbool-compare @gol
-Wno-attributes -Wno-builtin-macro-redefined @gol
-Wc90-c99-compat -Wc99-c11-compat @gol
-Wc++-compat -Wc++11-compat -Wcast-align -Wcast-qual @gol
@@ -4221,6 +4222,19 @@ This option is only active when @option{-ftree-vrp} is active
(default for @option{-O2} and above). It warns about subscripts to arrays
that are always out of bounds. This warning is enabled by @option{-Wall}.
+@item -Wbool-compare
+@opindex Wno-bool-compare
+@opindex Wbool-compare
+Warn about boolean expression compared with an integer value different from
+@code{true}/@code{false}. For instance, the following comparison is
+always false:
+@smallexample
+int n = 5;
+@dots{}
+if ((n > 1) == 2) @{ @dots{} @}
+@end smallexample
+This warning is enabled by @option{-Wall}.
+
@item -Wno-discarded-qualifiers @r{(C and Objective-C only)}
@opindex Wno-discarded-qualifiers
@opindex Wdiscarded-qualifiers