libstdc++: Improve comment for _Hashtable::_M_insert_unique_node
[official-gcc.git] / gcc / testsuite / c-c++-common / Wint-in-bool-context.c
blob42ff14784cc84b811b39f63cf7b9d45122fd6191
1 /* PR c++/77434 */
2 /* { dg-options "-Wint-in-bool-context" } */
3 /* { dg-do compile } */
5 enum truth { yes, no, maybe };
7 int foo (int a, int b)
9 if (a > 0 && a <= (b == 1) ? 1 : 2) /* { dg-warning "boolean context" } */
10 return 1;
12 if (a > 0 && a <= (b == 2) ? 1 : 1) /* { dg-bogus "boolean context" } */
13 return 2;
15 if (a > 0 && a <= (b == 3) ? 0 : 2) /* { dg-warning "boolean context" } */
16 return 3;
18 if (a == b ? 0 : 0) /* { dg-bogus "boolean context" } */
19 return 4;
21 if (a == ((b ? 2|4 : 1) & 3 ? 0 : 2)) /* { dg-bogus "boolean context" } */
22 return 5;
24 if (a ? 1 : 1+1) /* { dg-warning "boolean context" } */
25 return 6;
27 if (b ? 1+1 : 1) /* { dg-warning "boolean context" } */
28 return 7;
30 for (a = 0; 1 << a; a++); /* { dg-warning "boolean context" } */
32 if (yes || no || maybe) /* { dg-warning "boolean context" "" { target c++ } } */
33 return 8;
35 if (yes || no) /* { dg-bogus "boolean context" } */
36 return 9;
38 return 0;