1 /* { dg-do compile } */
2 /* { dg-options "-Wtype-limits" } */
6 void a (unsigned char x
)
8 if (x
< 0) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
9 if (x
>= 0) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
10 if (0 > x
) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
11 if (0 <= x
) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
12 if (x
<= 255) /* { dg-warning "comparison is always true due to limited range of data type" } */
14 if (255 >= x
) /* { dg-warning "comparison is always true due to limited range of data type" } */
16 if ((int)x
<= 255) /* { dg-bogus "comparison is always true due to limited range of data type" "" { xfail *-*-* } 16 } */
18 if (255 >= (unsigned char) 1)
23 void b (unsigned short x
)
24 { /* { dg-warning "comparison of unsigned expression < 0 is always false" "" { target { ! int32plus } } 25 } */
25 if (x
< 0) return;/* { dg-warning "comparison is always false due to limited range of data type" "" { target { int32plus } } } */
26 /* { dg-warning "comparison of unsigned expression >= 0 is always true" "" { target { ! int32plus } } 27 } */
27 if (x
>= 0) return;/* { dg-warning "comparison is always true due to limited range of data type" "" { target { int32plus } } } */
28 /* { dg-warning "comparison of unsigned expression < 0 is always false" "" { target { ! int32plus } } 29 } */
29 if (0 > x
) return;/* { dg-warning "comparison is always false due to limited range of data type" "" { target { int32plus } } } */
30 /* { dg-warning "comparison of unsigned expression >= 0 is always true" "" { target { ! int32plus } } 31 } */
31 if (0 <= x
) return;/* { dg-warning "comparison is always true due to limited range of data type" "" { target { int32plus } } } */
34 void c (unsigned int x
)
36 if (x
< 0) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
37 if (x
>= 0) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
38 if (0 > x
) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
39 if (0 <= x
) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
46 void d (unsigned long x
)
48 if (x
< 0) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
49 if (x
>= 0) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
50 if (0 > x
) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
51 if (0 <= x
) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
54 void e (unsigned long long x
)
56 if (x
< 0) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
57 if (x
>= 0) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
58 if (0 > x
) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
59 if (0 <= x
) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
64 if ((long long)x
<= 0x123456789ABCLL
) /* { dg-bogus "comparison is always true due to limited range of data type" "" { xfail *-*-* } 64 } */