aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2014-06-05 06:20:05 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2014-06-05 06:20:05 +0000
commit742938c911864563a8b04b95cbcf53d8f12a4ef9 (patch)
tree10c8e02d49aad0155082bdf3d7725c4ee7041702 /gcc/c
parent6447c55dea95705018ff2bb3de7a81c160a71d4e (diff)
downloadgcc-742938c911864563a8b04b95cbcf53d8f12a4ef9.zip
gcc-742938c911864563a8b04b95cbcf53d8f12a4ef9.tar.gz
gcc-742938c911864563a8b04b95cbcf53d8f12a4ef9.tar.bz2
re PR c/49706 (No warning for (!x > 1) which is always false)
PR c/49706 * doc/invoke.texi: Document -Wlogical-not-parentheses. c-family/ * c-common.c (warn_logical_not_parentheses): New function. * c-common.h (warn_logical_not_parentheses): Declare. * c.opt (Wlogical-not-parentheses): New option. c/ * c-typeck.c (parser_build_binary_op): Warn when logical not is used on the left hand side operand of a comparison. cp/ * parser.c (cp_parser_binary_expression): Warn when logical not is used on the left hand side operand of a comparison. testsuite/ * c-c++-common/pr49706.c: New test. From-SVN: r211255
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-typeck.c4
2 files changed, 10 insertions, 0 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 7bd3ce3..732c9c1 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,5 +1,11 @@
2014-06-05 Marek Polacek <polacek@redhat.com>
+ PR c/49706
+ * c-typeck.c (parser_build_binary_op): Warn when logical not is used
+ on the left hand side operand of a comparison.
+
+2014-06-05 Marek Polacek <polacek@redhat.com>
+
PR c/48062
* c-decl.c (warn_if_shadowing): Call inform instead of warning_at.
Print note only if the warning was printed.
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index a98ce07..e0d3fde 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -3401,6 +3401,10 @@ parser_build_binary_op (location_t location, enum tree_code code,
warn_logical_operator (location, code, TREE_TYPE (result.value),
code1, arg1.value, code2, arg2.value);
+ if (warn_logical_not_paren
+ && code1 == TRUTH_NOT_EXPR)
+ warn_logical_not_parentheses (location, code, arg1.value, arg2.value);
+
/* Warn about comparisons against string literals, with the exception
of testing for equality or inequality of a string literal with NULL. */
if (code == EQ_EXPR || code == NE_EXPR)