1 |
693 |
jeremybenn |
/* { dg-do compile } */
|
2 |
|
|
/* { dg-options "-Wtype-limits" } */
|
3 |
|
|
|
4 |
|
|
extern void assert (int);
|
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 *-*-* } 16 } */
|
17 |
|
|
return;
|
18 |
|
|
if (255 >= (unsigned char) 1)
|
19 |
|
|
return;
|
20 |
|
|
|
21 |
|
|
}
|
22 |
|
|
|
23 |
|
|
void b (unsigned short x)
|
24 |
|
|
{
|
25 |
|
|
if (x < 0) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
|
26 |
|
|
if (x >= 0) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
|
27 |
|
|
if (0 > x) return;/* { dg-warning "comparison is always false due to limited range of data type" } */
|
28 |
|
|
if (0 <= x) return;/* { dg-warning "comparison is always true due to limited range of data type" } */
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
void c (unsigned int x)
|
32 |
|
|
{
|
33 |
|
|
if (x < 0) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
|
34 |
|
|
if (x >= 0) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
|
35 |
|
|
if (0 > x) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
|
36 |
|
|
if (0 <= x) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
|
37 |
|
|
if (1U >= 0) return;
|
38 |
|
|
if (1U < 0) return;
|
39 |
|
|
if (0 <= 1U) return;
|
40 |
|
|
if (0 > 1U) return;
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
void d (unsigned long x)
|
44 |
|
|
{
|
45 |
|
|
if (x < 0) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
|
46 |
|
|
if (x >= 0) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
|
47 |
|
|
if (0 > x) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
|
48 |
|
|
if (0 <= x) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
void e (unsigned long long x)
|
52 |
|
|
{
|
53 |
|
|
if (x < 0) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
|
54 |
|
|
if (x >= 0) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
|
55 |
|
|
if (0 > x) return;/* { dg-warning "comparison of unsigned expression < 0 is always false" } */
|
56 |
|
|
if (0 <= x) return;/* { dg-warning "comparison of unsigned expression >= 0 is always true" } */
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
int test (int x)
|
60 |
|
|
{
|
61 |
|
|
if ((long long)x <= 0x123456789ABCLL) /* { dg-bogus "comparison is always true due to limited range of data type" "" { xfail *-*-* } 61 } */
|
62 |
|
|
return 1;
|
63 |
|
|
else
|
64 |
|
|
return 0;
|
65 |
|
|
}
|
66 |
|
|
|
67 |
|
|
template
|
68 |
|
|
void f(Int x) {
|
69 |
|
|
assert(0 <= x and x <= D); // { dg-warning "comparison is always true due to limited range of data type" }
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
int ff(void) {
|
73 |
|
|
f(5);
|
74 |
|
|
f(5);
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
template
|
78 |
|
|
void g(void) {
|
79 |
|
|
assert(0 <= D);
|
80 |
|
|
}
|
81 |
|
|
int gg(void) {
|
82 |
|
|
g();
|
83 |
|
|
}
|
84 |
|
|
|