1 /* { dg-do compile } */
2 /* { dg-options "-Wlogical-op" } */
3
4 void
5 fn1 (int a)
6 {
7 const int x = a;
8 if (x && x) {} /* { dg-warning "logical .and. of equal expressions" } */
9 if (x && (int) x) {} /* { dg-warning "logical .and. of equal expressions" } */
10 if ((int) x && x) {} /* { dg-warning "logical .and. of equal expressions" } */
11 if ((int) x && (int) x) {} /* { dg-warning "logical .and. of equal expressions" } */
12 }
13
14 void
15 fn2 (int a)
16 {
17 const int x = a;
18 if (x || x) {} /* { dg-warning "logical .or. of equal expressions" } */
19 if (x || (int) x) {} /* { dg-warning "logical .or. of equal expressions" } */
20 if ((int) x || x) {} /* { dg-warning "logical .or. of equal expressions" } */
21 if ((int) x || (int) x) {} /* { dg-warning "logical .or. of equal expressions" } */
22 }