+2015-06-23 Marek Polacek <polacek@redhat.com>
+
+ * c-common.c (warn_logical_operator): Use tree_int_cst_equal
+ when comparing INTEGER_CSTs.
+
2015-06-22 Pierre-Marie de Rodat <derodat@adacore.com>
* c-ada-spec.h (cpp_operation): Add HAS_DEPENDENT_TEMPLATE_ARGS.
}
/* Or warn if the operands have exactly the same range, e.g.
A > 0 && A > 0. */
- else if (low0 == low1 && high0 == high1)
+ else if (tree_int_cst_equal (low0, low1)
+ && tree_int_cst_equal (high0, high1))
{
if (or_op)
warning_at (location, OPT_Wlogical_op,
+2015-06-23 Marek Polacek <polacek@redhat.com>
+
+ * c-c++-common/Wlogical-op-3.c: New test.
+
2015-06-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/66254
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-Wlogical-op" } */
+
+void
+fn1 (int a)
+{
+ const int x = a;
+ if (x && x) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if (x && (int) x) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if ((int) x && x) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if ((int) x && (int) x) {} /* { dg-warning "logical .and. of equal expressions" } */
+}
+
+void
+fn2 (int a)
+{
+ const int x = a;
+ if (x || x) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if (x || (int) x) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if ((int) x || x) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if ((int) x || (int) x) {} /* { dg-warning "logical .or. of equal expressions" } */
+}