Merge from mainline (151362:151806)
[official-gcc/graphite-test-results.git] / gcc / testsuite / gcc.dg / Wtype-limits.c
blob16173e5b25c0f037b00629f3b1027a7cd8e6efa8
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" } */
13 return;
14 if (255 >= x) /* { dg-warning "comparison is always true due to limited range of data type" } */
15 return;
16 if ((int)x <= 255) /* { dg-bogus "comparison is always true due to limited range of data type" "" { xfail *-*-* } 16 } */
17 return;
18 if (255 >= (unsigned char) 1)
19 return;
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" } */
40 if (1U >= 0) return;
41 if (1U < 0) return;
42 if (0 <= 1U) return;
43 if (0 > 1U) return;
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" } */
62 int test (int x)
64 if ((long long)x <= 0x123456789ABCLL) /* { dg-bogus "comparison is always true due to limited range of data type" "" { xfail *-*-* } 64 } */
65 return 1;
66 else
67 return 0;