]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* c-typeck.c (parser_build_binary_op): Don't call
authormpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Jun 2014 16:38:48 +0000 (16:38 +0000)
committermpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Jun 2014 16:38:48 +0000 (16:38 +0000)
warn_logical_not_parentheses if the RHS is TRUTH_NOT_EXPR.

* c-c++-common/pr49706-2.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@211902 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr49706-2.c [new file with mode: 0644]

index cc3e5feda8a3773a4d85425b6890199a15d976e3..0972fdebd24c2e8955b4df1db9722c7ae7f6a8d9 100644 (file)
@@ -1,3 +1,8 @@
+2014-06-23  Marek Polacek  <polacek@redhat.com>
+
+       * c-typeck.c (parser_build_binary_op): Don't call
+       warn_logical_not_parentheses if the RHS is TRUTH_NOT_EXPR.
+
 2014-06-15  Jan Hubicka  <hubicka@ucw.cz>
 
        * c-parser.c (c_parser_omp_threadprivate): Likewise.
index 63bd65ee0be6dafbd9440ebdde2d416863b6b07c..07646307af8b054b7c0ec3300c7bb18b75b7fc4f 100644 (file)
@@ -3402,7 +3402,8 @@ parser_build_binary_op (location_t location, enum tree_code code,
                           code1, arg1.value, code2, arg2.value);
 
   if (warn_logical_not_paren
-      && code1 == TRUTH_NOT_EXPR)
+      && code1 == TRUTH_NOT_EXPR
+      && code2 != TRUTH_NOT_EXPR)
     warn_logical_not_parentheses (location, code, arg1.value, arg2.value);
 
   /* Warn about comparisons against string literals, with the exception
index 33aa8d2920e4e507aec0e374471f324afc78a8ae..d623f6ecb92a1d6cf96c71fd2cb107b3a26976bf 100644 (file)
@@ -1,3 +1,7 @@
+2014-06-23  Marek Polacek  <polacek@redhat.com>
+
+       * c-c++-common/pr49706-2.c: New test.
+
 2014-06-23  Alan Modra  <amodra@gmail.com>
 
        * gcc.dg/pr61583.c: New.
diff --git a/gcc/testsuite/c-c++-common/pr49706-2.c b/gcc/testsuite/c-c++-common/pr49706-2.c
new file mode 100644 (file)
index 0000000..09cc9eb
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-Wlogical-not-parentheses" } */
+
+/* Test that we don't warn if both operands of the comparison
+   are negated.  */
+
+#ifndef __cplusplus
+#define bool _Bool
+#endif
+
+bool r;
+
+int
+same (int a, int b)
+{
+  r = !a == !b;
+  r = !!a == !!b;
+  r = !!a == !b;
+  r = !a == !!b;
+}