• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation %s -DV0 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V0
2 // RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation %s -DV1 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V1
3 // RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation %s -DV2 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V2
4 // RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation %s -DV3 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V3
5 // RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation %s -DV4 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V4
6 // RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation %s -DV5 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V5
7 // RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation %s -DV6 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V6
8 // RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation %s -DV7 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V7
9 
10 // RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation %s -DV0 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V0
11 // RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation %s -DV1 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V1
12 // RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation %s -DV2 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V2
13 // RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation %s -DV3 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V3
14 // RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation %s -DV4 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V4
15 // RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation %s -DV5 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V5
16 // RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation %s -DV6 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V6
17 // RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation %s -DV7 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V7
18 
19 #include <stdint.h>
20 
21 // Test plan:
22 //  * Two types - int and char
23 //  * Two signs - signed and unsigned
24 //  * Square that - we have input and output types.
25 // Thus, there are total of (2*2)^2 == 16 tests.
26 // These are all the possible variations/combinations of casts.
27 // However, not all of them should result in the check.
28 // So here, we *only* check which should and which should not result in checks.
29 
convert_unsigned_int_to_unsigned_int(uint32_t x)30 uint32_t convert_unsigned_int_to_unsigned_int(uint32_t x) {
31 #line 100
32   return x;
33 }
34 
convert_unsigned_char_to_unsigned_char(uint8_t x)35 uint8_t convert_unsigned_char_to_unsigned_char(uint8_t x) {
36 #line 200
37   return x;
38 }
39 
convert_signed_int_to_signed_int(int32_t x)40 int32_t convert_signed_int_to_signed_int(int32_t x) {
41 #line 300
42   return x;
43 }
44 
convert_signed_char_to_signed_char(int8_t x)45 int8_t convert_signed_char_to_signed_char(int8_t x) {
46 #line 400
47   return x;
48 }
49 
convert_unsigned_int_to_unsigned_char(uint32_t x)50 uint8_t convert_unsigned_int_to_unsigned_char(uint32_t x) {
51 #line 500
52   return x;
53 }
54 
convert_unsigned_char_to_unsigned_int(uint8_t x)55 uint32_t convert_unsigned_char_to_unsigned_int(uint8_t x) {
56 #line 600
57   return x;
58 }
59 
convert_unsigned_char_to_signed_int(uint8_t x)60 int32_t convert_unsigned_char_to_signed_int(uint8_t x) {
61 #line 700
62   return x;
63 }
64 
convert_signed_char_to_signed_int(int8_t x)65 int32_t convert_signed_char_to_signed_int(int8_t x) {
66 #line 800
67   return x;
68 }
69 
convert_unsigned_int_to_signed_int(uint32_t x)70 int32_t convert_unsigned_int_to_signed_int(uint32_t x) {
71 #line 900
72   return x;
73 }
74 
convert_signed_int_to_unsigned_int(int32_t x)75 uint32_t convert_signed_int_to_unsigned_int(int32_t x) {
76 #line 1000
77   return x;
78 }
79 
convert_signed_int_to_unsigned_char(int32_t x)80 uint8_t convert_signed_int_to_unsigned_char(int32_t x) {
81 #line 1100
82   return x;
83 }
84 
convert_signed_char_to_unsigned_char(int8_t x)85 uint8_t convert_signed_char_to_unsigned_char(int8_t x) {
86 #line 1200
87   return x;
88 }
89 
convert_unsigned_char_to_signed_char(uint8_t x)90 int8_t convert_unsigned_char_to_signed_char(uint8_t x) {
91 #line 1300
92   return x;
93 }
94 
convert_signed_char_to_unsigned_int(int8_t x)95 uint32_t convert_signed_char_to_unsigned_int(int8_t x) {
96 #line 1400
97   return x;
98 }
99 
convert_unsigned_int_to_signed_char(uint32_t x)100 int8_t convert_unsigned_int_to_signed_char(uint32_t x) {
101 #line 1500
102   return x;
103 }
104 
convert_signed_int_to_signed_char(int32_t x)105 int8_t convert_signed_int_to_signed_char(int32_t x) {
106 #line 1600
107   return x;
108 }
109 
110 #line 1111 // !!!
111 
main()112 int main() {
113   // No bits set.
114   convert_unsigned_int_to_unsigned_int(0);
115   convert_unsigned_char_to_unsigned_char(0);
116   convert_signed_int_to_signed_int(0);
117   convert_signed_char_to_signed_char(0);
118   convert_unsigned_int_to_unsigned_char(0);
119   convert_unsigned_char_to_unsigned_int(0);
120   convert_unsigned_char_to_signed_int(0);
121   convert_signed_char_to_signed_int(0);
122   convert_unsigned_int_to_signed_int(0);
123   convert_signed_int_to_unsigned_int(0);
124   convert_signed_int_to_unsigned_char(0);
125   convert_signed_char_to_unsigned_char(0);
126   convert_unsigned_char_to_signed_char(0);
127   convert_signed_char_to_unsigned_int(0);
128   convert_unsigned_int_to_signed_char(0);
129   convert_signed_int_to_signed_char(0);
130 
131   // One lowest bit set.
132   convert_unsigned_int_to_unsigned_int(1);
133   convert_unsigned_char_to_unsigned_char(1);
134   convert_signed_int_to_signed_int(1);
135   convert_signed_char_to_signed_char(1);
136   convert_unsigned_int_to_unsigned_char(1);
137   convert_unsigned_char_to_unsigned_int(1);
138   convert_unsigned_char_to_signed_int(1);
139   convert_signed_char_to_signed_int(1);
140   convert_unsigned_int_to_signed_int(1);
141   convert_signed_int_to_unsigned_int(1);
142   convert_signed_int_to_unsigned_char(1);
143   convert_signed_char_to_unsigned_char(1);
144   convert_unsigned_char_to_signed_char(1);
145   convert_signed_char_to_unsigned_int(1);
146   convert_unsigned_int_to_signed_char(1);
147   convert_signed_int_to_signed_char(1);
148 
149 #if defined(V0)
150   // All source bits set.
151   convert_unsigned_int_to_unsigned_int((uint32_t)UINT32_MAX);
152   convert_unsigned_char_to_unsigned_char((uint8_t)UINT8_MAX);
153   convert_signed_int_to_signed_int((int32_t)(uint32_t)UINT32_MAX);
154   convert_signed_char_to_signed_char((int8_t)UINT8_MAX);
155   convert_unsigned_int_to_unsigned_char((uint32_t)UINT32_MAX);
156   convert_unsigned_char_to_unsigned_int((uint8_t)UINT8_MAX);
157   convert_unsigned_char_to_signed_int((uint8_t)UINT8_MAX);
158   convert_signed_char_to_signed_int((int8_t)UINT8_MAX);
159   convert_unsigned_int_to_signed_int((uint32_t)UINT32_MAX);
160   convert_signed_int_to_unsigned_int((int32_t)(uint32_t)UINT32_MAX);
161   convert_signed_int_to_unsigned_char((int32_t)(uint32_t)UINT32_MAX);
162 // CHECK-V0: {{.*}}signed-integer-truncation.c:1100:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -1 (32-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 255 (8-bit, unsigned)
163   convert_signed_char_to_unsigned_char((int8_t)UINT8_MAX);
164   convert_unsigned_char_to_signed_char((uint8_t)UINT8_MAX);
165   convert_signed_char_to_unsigned_int((int8_t)UINT8_MAX);
166   convert_unsigned_int_to_signed_char((uint32_t)UINT32_MAX);
167   convert_signed_int_to_signed_char((int32_t)(uint32_t)UINT32_MAX);
168 #elif defined(V1)
169    // Source 'Sign' bit set.
170   convert_unsigned_int_to_unsigned_int((uint32_t)INT32_MIN);
171   convert_unsigned_char_to_unsigned_char((uint8_t)INT8_MIN);
172   convert_signed_int_to_signed_int((int32_t)(uint32_t)INT32_MIN);
173   convert_signed_char_to_signed_char((int8_t)INT8_MIN);
174   convert_unsigned_int_to_unsigned_char((uint32_t)INT32_MIN);
175   convert_unsigned_char_to_unsigned_int((uint8_t)INT8_MIN);
176   convert_unsigned_char_to_signed_int((uint8_t)INT8_MIN);
177   convert_signed_char_to_signed_int((int8_t)INT8_MIN);
178   convert_unsigned_int_to_signed_int((uint32_t)INT32_MIN);
179   convert_signed_int_to_unsigned_int((int32_t)(uint32_t)INT32_MIN);
180   convert_signed_int_to_unsigned_char((int32_t)(uint32_t)INT32_MIN);
181 // CHECK-V1: {{.*}}signed-integer-truncation.c:1100:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -2147483648 (32-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 0 (8-bit, unsigned)
182   convert_signed_char_to_unsigned_char((int8_t)INT8_MIN);
183   convert_unsigned_char_to_signed_char((uint8_t)INT8_MIN);
184   convert_signed_char_to_unsigned_int((int8_t)INT8_MIN);
185   convert_unsigned_int_to_signed_char((uint32_t)INT32_MIN);
186 // CHECK-V1: {{.*}}signed-integer-truncation.c:1500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483648 (32-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to 0 (8-bit, signed)
187   convert_signed_int_to_signed_char((int32_t)(uint32_t)INT32_MIN);
188 // CHECK-V1: {{.*}}signed-integer-truncation.c:1600:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -2147483648 (32-bit, signed) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to 0 (8-bit, signed)
189 #elif defined(V2)
190   // All bits except the source 'Sign' bit are set.
191   convert_unsigned_int_to_unsigned_int((uint32_t)INT32_MAX);
192   convert_unsigned_char_to_unsigned_char((uint8_t)INT8_MAX);
193   convert_signed_int_to_signed_int((int32_t)(uint32_t)INT32_MAX);
194   convert_signed_char_to_signed_char((int8_t)INT8_MAX);
195   convert_unsigned_int_to_unsigned_char((uint32_t)INT32_MAX);
196   convert_unsigned_char_to_unsigned_int((uint8_t)INT8_MAX);
197   convert_unsigned_char_to_signed_int((uint8_t)INT8_MAX);
198   convert_signed_char_to_signed_int((int8_t)INT8_MAX);
199   convert_unsigned_int_to_signed_int((uint32_t)INT32_MAX);
200   convert_signed_int_to_unsigned_int((int32_t)(uint32_t)INT32_MAX);
201   convert_signed_int_to_unsigned_char((int32_t)(uint32_t)INT32_MAX);
202 // CHECK-V2: {{.*}}signed-integer-truncation.c:1100:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value 2147483647 (32-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 255 (8-bit, unsigned)
203   convert_signed_char_to_unsigned_char((int8_t)INT8_MAX);
204   convert_unsigned_char_to_signed_char((uint8_t)INT8_MAX);
205   convert_signed_char_to_unsigned_int((int8_t)INT8_MAX);
206   convert_unsigned_int_to_signed_char((uint32_t)INT32_MAX);
207 // CHECK-V2: {{.*}}signed-integer-truncation.c:1500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483647 (32-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -1 (8-bit, signed)
208   convert_signed_int_to_signed_char((int32_t)(uint32_t)INT32_MAX);
209 // CHECK-V2: {{.*}}signed-integer-truncation.c:1600:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value 2147483647 (32-bit, signed) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -1 (8-bit, signed)
210 #elif defined(V3)
211   // All destination bits set.
212   convert_unsigned_int_to_unsigned_int((uint32_t)UINT8_MAX);
213   convert_unsigned_char_to_unsigned_char((uint8_t)UINT8_MAX);
214   convert_signed_int_to_signed_int((int32_t)(uint32_t)UINT8_MAX);
215   convert_signed_char_to_signed_char((int8_t)UINT8_MAX);
216   convert_unsigned_int_to_unsigned_char((uint32_t)UINT8_MAX);
217   convert_unsigned_char_to_unsigned_int((uint8_t)UINT8_MAX);
218   convert_unsigned_char_to_signed_int((uint8_t)UINT8_MAX);
219   convert_signed_char_to_signed_int((int8_t)UINT8_MAX);
220   convert_unsigned_int_to_signed_int((uint32_t)UINT8_MAX);
221   convert_signed_int_to_unsigned_int((int32_t)(uint32_t)UINT8_MAX);
222   convert_signed_int_to_unsigned_char((int32_t)(uint32_t)UINT8_MAX);
223   convert_signed_char_to_unsigned_char((int8_t)UINT8_MAX);
224   convert_unsigned_char_to_signed_char((uint8_t)UINT8_MAX);
225   convert_signed_char_to_unsigned_int((int8_t)UINT8_MAX);
226   convert_unsigned_int_to_signed_char((uint32_t)UINT8_MAX);
227 // CHECK-V3: {{.*}}signed-integer-truncation.c:1500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 255 (32-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -1 (8-bit, signed)
228   convert_signed_int_to_signed_char((int32_t)(uint32_t)UINT8_MAX);
229 // CHECK-V3: {{.*}}signed-integer-truncation.c:1600:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value 255 (32-bit, signed) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -1 (8-bit, signed)
230 #elif defined(V4)
231   // Destination 'sign' bit set.
232   convert_unsigned_int_to_unsigned_int((uint32_t)(uint8_t)INT8_MIN);
233   convert_unsigned_char_to_unsigned_char((uint8_t)(uint8_t)INT8_MIN);
234   convert_signed_int_to_signed_int((int32_t)(uint32_t)(uint8_t)INT8_MIN);
235   convert_signed_char_to_signed_char((int8_t)(uint8_t)INT8_MIN);
236   convert_unsigned_int_to_unsigned_char((uint32_t)(uint8_t)INT8_MIN);
237   convert_unsigned_char_to_unsigned_int((uint8_t)(uint8_t)INT8_MIN);
238   convert_unsigned_char_to_signed_int((uint8_t)(uint8_t)INT8_MIN);
239   convert_signed_char_to_signed_int((int8_t)(uint8_t)INT8_MIN);
240   convert_unsigned_int_to_signed_int((uint32_t)(uint8_t)INT8_MIN);
241   convert_signed_int_to_unsigned_int((int32_t)(uint32_t)(uint8_t)INT8_MIN);
242   convert_signed_int_to_unsigned_char((int32_t)(uint32_t)(uint8_t)INT8_MIN);
243   convert_signed_char_to_unsigned_char((int8_t)(uint8_t)INT8_MIN);
244   convert_unsigned_char_to_signed_char((uint8_t)(uint8_t)INT8_MIN);
245   convert_signed_char_to_unsigned_int((int8_t)(uint8_t)INT8_MIN);
246   convert_unsigned_int_to_signed_char((uint32_t)(uint8_t)INT8_MIN);
247 // CHECK-V4: {{.*}}signed-integer-truncation.c:1500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 128 (32-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -128 (8-bit, signed)
248   convert_signed_int_to_signed_char((int32_t)(uint32_t)(uint8_t)INT8_MIN);
249 // CHECK-V4: {{.*}}signed-integer-truncation.c:1600:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value 128 (32-bit, signed) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -128 (8-bit, signed)
250 #elif defined(V5)
251   // All bits except the destination 'sign' bit are set.
252   convert_unsigned_int_to_unsigned_int((~((uint32_t)(uint8_t)INT8_MIN)));
253   convert_unsigned_char_to_unsigned_char((uint8_t)(uint8_t)INT8_MIN);
254   convert_signed_int_to_signed_int((int32_t)(~((uint32_t)(uint8_t)INT8_MIN)));
255   convert_signed_char_to_signed_char((int8_t)(uint8_t)INT8_MIN);
256   convert_unsigned_int_to_unsigned_char((~((uint32_t)(uint8_t)INT8_MIN)));
257   convert_unsigned_char_to_unsigned_int((uint8_t)(uint8_t)INT8_MIN);
258   convert_unsigned_char_to_signed_int((uint8_t)(uint8_t)INT8_MIN);
259   convert_signed_char_to_signed_int((int8_t)(uint8_t)INT8_MIN);
260   convert_unsigned_int_to_signed_int((~((uint32_t)(uint8_t)INT8_MIN)));
261   convert_signed_int_to_unsigned_int((int32_t)(~((uint32_t)(uint8_t)INT8_MIN)));
262   convert_signed_int_to_unsigned_char((int32_t)(~((uint32_t)(uint8_t)INT8_MIN)));
263 // CHECK-V5: {{.*}}signed-integer-truncation.c:1100:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -129 (32-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 127 (8-bit, unsigned)
264   convert_signed_char_to_unsigned_char((int8_t)(uint8_t)INT8_MIN);
265   convert_unsigned_char_to_signed_char((uint8_t)(uint8_t)INT8_MIN);
266   convert_signed_char_to_unsigned_int((int8_t)(uint8_t)INT8_MIN);
267   convert_unsigned_int_to_signed_char((~((uint32_t)(uint8_t)INT8_MIN)));
268 // CHECK-V5: {{.*}}signed-integer-truncation.c:1500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 4294967167 (32-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to 127 (8-bit, signed)
269   convert_signed_int_to_signed_char((int32_t)(~((uint32_t)(uint8_t)INT8_MIN)));
270 // CHECK-V5: {{.*}}signed-integer-truncation.c:1600:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -129 (32-bit, signed) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to 127 (8-bit, signed)
271 #elif defined(V6)
272   // Only the source and destination sign bits are set.
273   convert_unsigned_int_to_unsigned_int((uint32_t)INT32_MIN);
274   convert_unsigned_char_to_unsigned_char((uint8_t)INT8_MIN);
275   convert_signed_int_to_signed_int((int32_t)INT32_MIN);
276   convert_signed_char_to_signed_char((int8_t)INT8_MIN);
277   convert_unsigned_int_to_unsigned_char(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN));
278   convert_unsigned_char_to_unsigned_int((uint8_t)INT8_MIN);
279   convert_unsigned_char_to_signed_int((uint8_t)INT8_MIN);
280   convert_signed_char_to_signed_int((int8_t)INT8_MIN);
281   convert_unsigned_int_to_signed_int((uint32_t)INT32_MIN);
282   convert_signed_int_to_unsigned_int((uint32_t)INT32_MIN);
283   convert_signed_int_to_unsigned_char((int32_t)(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
284 // CHECK-V6: {{.*}}signed-integer-truncation.c:1100:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -2147483520 (32-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 128 (8-bit, unsigned)
285   convert_signed_char_to_unsigned_char((int8_t)INT8_MIN);
286   convert_unsigned_char_to_signed_char((uint8_t)INT8_MIN);
287   convert_signed_char_to_unsigned_int((int8_t)INT8_MIN);
288   convert_unsigned_int_to_signed_char((((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
289 // CHECK-V6: {{.*}}signed-integer-truncation.c:1500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483776 (32-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -128 (8-bit, signed)
290   convert_signed_int_to_signed_char((int32_t)(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
291 // CHECK-V6: {{.*}}signed-integer-truncation.c:1600:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -2147483520 (32-bit, signed) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -128 (8-bit, signed)
292 #elif defined(V7)
293   // All bits except the source and destination sign bits are set.
294   convert_unsigned_int_to_unsigned_int((uint32_t)INT32_MAX);
295   convert_unsigned_char_to_unsigned_char((uint8_t)INT8_MAX);
296   convert_signed_int_to_signed_int((int32_t)INT32_MAX);
297   convert_signed_char_to_signed_char((int8_t)INT8_MAX);
298   convert_unsigned_int_to_unsigned_char(~(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
299   convert_unsigned_char_to_unsigned_int((uint8_t)INT8_MAX);
300   convert_unsigned_char_to_signed_int((uint8_t)INT8_MAX);
301   convert_signed_char_to_signed_int((int8_t)INT8_MAX);
302   convert_unsigned_int_to_signed_int((uint32_t)INT32_MAX);
303   convert_signed_int_to_unsigned_int((uint32_t)INT32_MAX);
304   convert_signed_int_to_unsigned_char((int32_t)(~(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN))));
305 // CHECK-V7: {{.*}}signed-integer-truncation.c:1100:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value 2147483519 (32-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 127 (8-bit, unsigned)
306   convert_signed_char_to_unsigned_char((int8_t)INT8_MAX);
307   convert_unsigned_char_to_signed_char((uint8_t)INT8_MAX);
308   convert_signed_char_to_unsigned_int((int8_t)INT8_MAX);
309   convert_unsigned_int_to_signed_char(~(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
310 // CHECK-V7: {{.*}}signed-integer-truncation.c:1500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483519 (32-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to 127 (8-bit, signed)
311   convert_signed_int_to_signed_char((int32_t)~(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
312 // CHECK-V7: {{.*}}signed-integer-truncation.c:1600:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value 2147483519 (32-bit, signed) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to 127 (8-bit, signed)
313 #else
314 #error Some V* needs to be defined!
315 #endif
316 
317   return 0;
318 }
319