aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2016-09-05 12:17:09 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2016-09-05 12:17:09 +0000
commit25ff5dd35471b2b20f2b2681c8ff24c0d086ec00 (patch)
treecbe9638e9cb6159d1a15ccd556a01d2ef8a445c8 /gcc/testsuite/c-c++-common
parentc5cb79681df13acc02894b4df8314c797895e2bb (diff)
downloadgcc-25ff5dd35471b2b20f2b2681c8ff24c0d086ec00.zip
gcc-25ff5dd35471b2b20f2b2681c8ff24c0d086ec00.tar.gz
gcc-25ff5dd35471b2b20f2b2681c8ff24c0d086ec00.tar.bz2
re PR c/77423 (-Wlogical-not-parentheses false positive for bitwise expression with _Bool operands)
PR c/77423 * doc/invoke.texi: Update -Wlogical-not-parentheses documentation. * c-common.c (bool_promoted_to_int_p): New function. (expr_has_boolean_operands_p): New function. (warn_logical_not_parentheses): Return if expr_has_boolean_operands_p. (maybe_warn_bool_compare): Use bool_promoted_to_int_p. * c-c++-common/Wlogical-not-parentheses-3.c: New test. From-SVN: r239988
Diffstat (limited to 'gcc/testsuite/c-c++-common')
-rw-r--r--gcc/testsuite/c-c++-common/Wlogical-not-parentheses-3.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/Wlogical-not-parentheses-3.c b/gcc/testsuite/c-c++-common/Wlogical-not-parentheses-3.c
new file mode 100644
index 0000000..00aa747
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wlogical-not-parentheses-3.c
@@ -0,0 +1,31 @@
+/* PR c/77423 */
+/* { dg-do compile } */
+/* { dg-options "-Wlogical-not-parentheses" } */
+
+#ifndef __cplusplus
+# define bool _Bool
+#endif
+
+int
+f (int a, bool b, bool c)
+{
+ int r = 0;
+
+ r += !a == (b | c);
+ r += !a == (b ^ c);
+ r += !a == (b & c);
+ r += !a == ~b;
+ r += !a == ~(int) b;
+ r += !a == ((b & c) | c);
+ r += !a == ((b & c) | (b ^ c));
+ r += !a == (int) (b ^ c);
+ r += !a == (int) ~b;
+ r += !a == ~~b;
+ r += !a == ~(b | c);
+ r += !a == ~(b | (a == 1));
+ r += !a == ~(a == 1);
+
+ r += !a == ((b & c) | (b ^ a)); /* { dg-warning "logical not is only applied to the left hand side of comparison" } */
+
+ return r;
+}