mirror of git://gcc.gnu.org/git/gcc.git
c-common.c (warn_logical_operator): Use tree_int_cst_equal when comparing INTEGER_CSTs.
* c-common.c (warn_logical_operator): Use tree_int_cst_equal when comparing INTEGER_CSTs. * c-c++-common/Wlogical-op-3.c: New test. From-SVN: r224853
This commit is contained in:
parent
171561ca33
commit
a68ae2e1b1
|
|
@ -1,3 +1,8 @@
|
||||||
|
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>
|
2015-06-22 Pierre-Marie de Rodat <derodat@adacore.com>
|
||||||
|
|
||||||
* c-ada-spec.h (cpp_operation): Add HAS_DEPENDENT_TEMPLATE_ARGS.
|
* c-ada-spec.h (cpp_operation): Add HAS_DEPENDENT_TEMPLATE_ARGS.
|
||||||
|
|
|
||||||
|
|
@ -1838,7 +1838,8 @@ warn_logical_operator (location_t location, enum tree_code code, tree type,
|
||||||
}
|
}
|
||||||
/* Or warn if the operands have exactly the same range, e.g.
|
/* Or warn if the operands have exactly the same range, e.g.
|
||||||
A > 0 && A > 0. */
|
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)
|
if (or_op)
|
||||||
warning_at (location, OPT_Wlogical_op,
|
warning_at (location, OPT_Wlogical_op,
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
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>
|
2015-06-23 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
PR c++/66254
|
PR c++/66254
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
/* { 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" } */
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue