111
|
1 /* Test that -Wtype-limits is enabled by -Wextra */
|
|
2 /* { dg-do compile } */
|
|
3 /* { dg-excess-errors "short=int" { target { avr-*-* } } } */
|
|
4 /* { dg-options "-Wextra" } */
|
|
5
|
|
6 void a (unsigned char x)
|
|
7 {
|
|
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 *-*-* } } */
|
|
17 return;
|
|
18 if (255 >= (unsigned char) 1)
|
|
19 return;
|
|
20
|
|
21 }
|
|
22
|
|
23 void b (unsigned short x)
|
|
24 { /* { dg-warning "comparison of unsigned expression < 0 is always false" "" { target { ! int32plus } } .+1 } */
|
|
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 } } .+1 } */
|
|
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 } } .+1 } */
|
|
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 } } .+1 } */
|
|
31 if (0 <= x) return;/* { dg-warning "comparison is always true due to limited range of data type" "" { target { int32plus } } } */
|
|
32 }
|
|
33
|
|
34 void c (unsigned int x)
|
|
35 {
|
|
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;
|
|
44 }
|
|
45
|
|
46 void d (unsigned long x)
|
|
47 {
|
|
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" } */
|
|
52 }
|
|
53
|
|
54 void e (unsigned long long x)
|
|
55 {
|
|
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" } */
|
|
60 }
|
|
61
|
|
62 int test (int x)
|
|
63 {
|
|
64 if ((long long)x <= 0x123456789ABCLL) /* { dg-bogus "comparison is always true due to limited range of data type" "" { xfail *-*-* } } */
|
|
65 return 1;
|
|
66 else
|
|
67 return 0;
|
|
68 }
|
|
69
|
|
70
|