1 /* { dg-do compile { target { ilp32 || lp64 } } } */
2 /* { dg-options "-Wsign-compare" } */
3
4 int
5 f1 (unsigned char x)
6 {
7 return (unsigned short) (~(unsigned short) x) == 0; /* { dg-warning "promoted bitwise complement of an unsigned value is always nonzero" "" { target c } } */
8 }
9
10 int
11 f2 (unsigned char x)
12 {
13 return (unsigned short) (~(unsigned short) x) == 5; /* { dg-warning "comparison of promoted bitwise complement of an unsigned value with constant" "" { target c } } */
14 }
15
16 int
17 f3 (unsigned char x)
18 {
19 return (unsigned int) (~(unsigned short) x) == 0xffff0005U; /* { dg-warning "comparison of promoted bitwise complement of an unsigned value with constant" } */
20 }
21
22 int
23 f4 (unsigned char x)
24 {
25 return (unsigned int) (~(unsigned short) x) == 0xffff0005ULL; /* { dg-warning "comparison of promoted bitwise complement of an unsigned value with constant" } */
26 }
27
28 int
29 f5 (unsigned char x)
30 {
31 return (unsigned int) (~(unsigned short) x) == 0xffffff05U; /* { dg-bogus "comparison of promoted bitwise complement of an unsigned value with constant" } */
32 }
33
34 int
35 f6 (unsigned char x)
36 {
37 return (unsigned int) (~(unsigned short) x) == 0xffffff05ULL; /* { dg-bogus "comparison of promoted bitwise complement of an unsigned value with constant" } */
38 }
39
40 int
41 f7 (unsigned char x)
42 {
43 return (unsigned long long) (~(unsigned short) x) == 0xffffffffffffff05ULL; /* { dg-bogus "comparison of promoted bitwise complement of an unsigned value with constant" } */
44 }
45
46 typedef unsigned short T;
47
48 int
49 f8 (T x)
50 {
51 return (unsigned short) (~(unsigned short) x) == 0; /* { dg-bogus "promoted bitwise complement of an unsigned value is always nonzero" } */
52 }
53
54 int
55 f9 (T x)
56 {
57 return (unsigned short) (~(unsigned short) x) == 5; /* { dg-bogus "comparison of promoted bitwise complement of an unsigned value with constant" } */
58 }
59
60 int
61 f10 (T x, unsigned char y)
62 {
63 return (unsigned short) (~(unsigned short) x) == y; /* { dg-bogus "comparison of promoted bitwise complement of an unsigned value with unsigned" } */
64 }
65
66 int
67 f11 (T x, unsigned char y)
68 {
69 return (unsigned short) (~(unsigned short) x) == y; /* { dg-bogus "comparison of promoted bitwise complement of an unsigned value with unsigned" } */
70 }
71
72 int
73 f12 (unsigned char x, unsigned char y)
74 {
75 return (unsigned short) (~(unsigned short) x) == y; /* { dg-warning "comparison of promoted bitwise complement of an unsigned value with unsigned" "" { target c } } */
76 }
77
78 int
79 f13 (unsigned char x, unsigned char y)
80 {
81 return (unsigned short) (~(unsigned short) x) == y; /* { dg-warning "comparison of promoted bitwise complement of an unsigned value with unsigned" "" { target c } } */
82 }
83
84 int
85 f14 (unsigned char x, unsigned int y)
86 {
87 return (unsigned long long) (~x) == y; /* { dg-warning "comparison of promoted bitwise complement of an unsigned value with unsigned" } */
88 }
89
90 int
91 f15 (unsigned short x, unsigned int y)
92 {
93 return (long long) (~x) == y; /* { dg-warning "comparison of promoted bitwise complement of an unsigned value with unsigned" } */
94 }
95
96 int
97 f16 (unsigned char x, unsigned short y)
98 {
99 return (unsigned short) (~(unsigned short) x) == y; /* { dg-bogus "comparison of promoted bitwise complement of an unsigned value with unsigned" } */
100 }
101
102 int
103 f17 (unsigned char x, unsigned short y)
104 {
105 return (unsigned short) (~(unsigned short) x) == y; /* { dg-bogus "comparison of promoted bitwise complement of an unsigned value with unsigned" } */
106 }
107
108 int
109 f18 (unsigned char x)
110 {
111 return (unsigned int) (short) (~(unsigned short) x) == 0xffffff05ULL; /* { dg-bogus "comparison of promoted bitwise complement of an unsigned value with constant" } */
112 }