1 /* PR c++/77434 */
2 /* { dg-options "-Wint-in-bool-context" } */
3 /* { dg-do compile } */
4
5 enum truth { yes, no, maybe };
6
foo(int a,int b)7 int foo (int a, int b)
8 {
9 if (a > 0 && a <= (b == 1) ? 1 : 2) /* { dg-warning "boolean context" } */
10 return 1;
11
12 if (a > 0 && a <= (b == 2) ? 1 : 1) /* { dg-bogus "boolean context" } */
13 return 2;
14
15 if (a > 0 && a <= (b == 3) ? 0 : 2) /* { dg-warning "boolean context" } */
16 return 3;
17
18 if (a == b ? 0 : 0) /* { dg-bogus "boolean context" } */
19 return 4;
20
21 if (a == ((b ? 2|4 : 1) & 3 ? 0 : 2)) /* { dg-bogus "boolean context" } */
22 return 5;
23
24 if (a ? 1 : 1+1) /* { dg-warning "boolean context" } */
25 return 6;
26
27 if (b ? 1+1 : 1) /* { dg-warning "boolean context" } */
28 return 7;
29
30 for (a = 0; 1 << a; a++); /* { dg-warning "boolean context" } */
31
32 if (yes || no || maybe) /* { dg-warning "boolean context" "" { target c++ } } */
33 return 8;
34
35 if (yes || no) /* { dg-bogus "boolean context" } */
36 return 9;
37
38 return 0;
39 }
40