1f11d5646SRoman Lebedev // RUN: %clang -x c -fsanitize=implicit-conversion %s -DV0 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V0
2f11d5646SRoman Lebedev // RUN: %clang -x c -fsanitize=implicit-conversion %s -DV1 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V1
3f11d5646SRoman Lebedev // RUN: %clang -x c -fsanitize=implicit-conversion %s -DV2 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V2
4f11d5646SRoman Lebedev // RUN: %clang -x c -fsanitize=implicit-conversion %s -DV3 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V3
5f11d5646SRoman Lebedev // RUN: %clang -x c -fsanitize=implicit-conversion %s -DV4 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V4
6f11d5646SRoman Lebedev // RUN: %clang -x c -fsanitize=implicit-conversion %s -DV5 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V5
7f11d5646SRoman Lebedev // RUN: %clang -x c -fsanitize=implicit-conversion %s -DV6 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V6
8f11d5646SRoman Lebedev // RUN: %clang -x c -fsanitize=implicit-conversion %s -DV7 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V7
9630fa0eeSRoman Lebedev
10f11d5646SRoman Lebedev // RUN: %clang -x c++ -fsanitize=implicit-conversion %s -DV0 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V0
11f11d5646SRoman Lebedev // RUN: %clang -x c++ -fsanitize=implicit-conversion %s -DV1 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V1
12f11d5646SRoman Lebedev // RUN: %clang -x c++ -fsanitize=implicit-conversion %s -DV2 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V2
13f11d5646SRoman Lebedev // RUN: %clang -x c++ -fsanitize=implicit-conversion %s -DV3 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V3
14f11d5646SRoman Lebedev // RUN: %clang -x c++ -fsanitize=implicit-conversion %s -DV4 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V4
15f11d5646SRoman Lebedev // RUN: %clang -x c++ -fsanitize=implicit-conversion %s -DV5 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V5
16f11d5646SRoman Lebedev // RUN: %clang -x c++ -fsanitize=implicit-conversion %s -DV6 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V6
17f11d5646SRoman Lebedev // RUN: %clang -x c++ -fsanitize=implicit-conversion %s -DV7 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V7
18630fa0eeSRoman Lebedev
19630fa0eeSRoman Lebedev #include <stdint.h>
20630fa0eeSRoman Lebedev
21f11d5646SRoman Lebedev // Test plan:
22f11d5646SRoman Lebedev // * Two types - int and char
23f11d5646SRoman Lebedev // * Two signs - signed and unsigned
24f11d5646SRoman Lebedev // * Square that - we have input and output types.
25f11d5646SRoman Lebedev // Thus, there are total of (2*2)^2 == 16 tests.
26f11d5646SRoman Lebedev // These are all the possible variations/combinations of casts.
27f11d5646SRoman Lebedev // However, not all of them should result in the check.
28f11d5646SRoman Lebedev // So here, we *only* check which should and which should not result in checks.
29f11d5646SRoman Lebedev
convert_unsigned_int_to_unsigned_int(uint32_t x)30a0457c02SRoman Lebedev uint32_t convert_unsigned_int_to_unsigned_int(uint32_t x) {
31630fa0eeSRoman Lebedev #line 100
32630fa0eeSRoman Lebedev return x;
33630fa0eeSRoman Lebedev }
34630fa0eeSRoman Lebedev
convert_unsigned_char_to_unsigned_char(uint8_t x)35a0457c02SRoman Lebedev uint8_t convert_unsigned_char_to_unsigned_char(uint8_t x) {
36f11d5646SRoman Lebedev #line 200
37f11d5646SRoman Lebedev return x;
38f11d5646SRoman Lebedev }
39630fa0eeSRoman Lebedev
convert_signed_int_to_signed_int(int32_t x)40a0457c02SRoman Lebedev int32_t convert_signed_int_to_signed_int(int32_t x) {
41f11d5646SRoman Lebedev #line 300
42f11d5646SRoman Lebedev return x;
43f11d5646SRoman Lebedev }
44f11d5646SRoman Lebedev
convert_signed_char_to_signed_char(int8_t x)45a0457c02SRoman Lebedev int8_t convert_signed_char_to_signed_char(int8_t x) {
46f11d5646SRoman Lebedev #line 400
47f11d5646SRoman Lebedev return x;
48f11d5646SRoman Lebedev }
49f11d5646SRoman Lebedev
convert_unsigned_int_to_unsigned_char(uint32_t x)50a0457c02SRoman Lebedev uint8_t convert_unsigned_int_to_unsigned_char(uint32_t x) {
51f11d5646SRoman Lebedev #line 500
52f11d5646SRoman Lebedev return x;
53f11d5646SRoman Lebedev }
54f11d5646SRoman Lebedev
convert_unsigned_char_to_unsigned_int(uint8_t x)55a0457c02SRoman Lebedev uint32_t convert_unsigned_char_to_unsigned_int(uint8_t x) {
56f11d5646SRoman Lebedev #line 600
57f11d5646SRoman Lebedev return x;
58f11d5646SRoman Lebedev }
59f11d5646SRoman Lebedev
convert_unsigned_char_to_signed_int(uint8_t x)60a0457c02SRoman Lebedev int32_t convert_unsigned_char_to_signed_int(uint8_t x) {
61f11d5646SRoman Lebedev #line 700
62f11d5646SRoman Lebedev return x;
63f11d5646SRoman Lebedev }
64f11d5646SRoman Lebedev
convert_signed_char_to_signed_int(int8_t x)65a0457c02SRoman Lebedev int32_t convert_signed_char_to_signed_int(int8_t x) {
66f11d5646SRoman Lebedev #line 800
67f11d5646SRoman Lebedev return x;
68f11d5646SRoman Lebedev }
69f11d5646SRoman Lebedev
convert_unsigned_int_to_signed_int(uint32_t x)70a0457c02SRoman Lebedev int32_t convert_unsigned_int_to_signed_int(uint32_t x) {
71f11d5646SRoman Lebedev #line 900
72f11d5646SRoman Lebedev return x;
73f11d5646SRoman Lebedev }
74f11d5646SRoman Lebedev
convert_signed_int_to_unsigned_int(int32_t x)75a0457c02SRoman Lebedev uint32_t convert_signed_int_to_unsigned_int(int32_t x) {
76f11d5646SRoman Lebedev #line 1000
77f11d5646SRoman Lebedev return x;
78f11d5646SRoman Lebedev }
79f11d5646SRoman Lebedev
convert_signed_int_to_unsigned_char(int32_t x)80a0457c02SRoman Lebedev uint8_t convert_signed_int_to_unsigned_char(int32_t x) {
81f11d5646SRoman Lebedev #line 1100
82f11d5646SRoman Lebedev return x;
83f11d5646SRoman Lebedev }
84f11d5646SRoman Lebedev
convert_signed_char_to_unsigned_char(int8_t x)85a0457c02SRoman Lebedev uint8_t convert_signed_char_to_unsigned_char(int8_t x) {
86f11d5646SRoman Lebedev #line 1200
87f11d5646SRoman Lebedev return x;
88f11d5646SRoman Lebedev }
89f11d5646SRoman Lebedev
convert_unsigned_char_to_signed_char(uint8_t x)90a0457c02SRoman Lebedev int8_t convert_unsigned_char_to_signed_char(uint8_t x) {
91f11d5646SRoman Lebedev #line 1300
92f11d5646SRoman Lebedev return x;
93f11d5646SRoman Lebedev }
94f11d5646SRoman Lebedev
convert_signed_char_to_unsigned_int(int8_t x)95a0457c02SRoman Lebedev uint32_t convert_signed_char_to_unsigned_int(int8_t x) {
96f11d5646SRoman Lebedev #line 1400
97f11d5646SRoman Lebedev return x;
98f11d5646SRoman Lebedev }
99f11d5646SRoman Lebedev
convert_unsigned_int_to_signed_char(uint32_t x)100a0457c02SRoman Lebedev int8_t convert_unsigned_int_to_signed_char(uint32_t x) {
101f11d5646SRoman Lebedev #line 1500
102f11d5646SRoman Lebedev return x;
103f11d5646SRoman Lebedev }
104f11d5646SRoman Lebedev
convert_signed_int_to_signed_char(int32_t x)105a0457c02SRoman Lebedev int8_t convert_signed_int_to_signed_char(int32_t x) {
106f11d5646SRoman Lebedev #line 1600
107f11d5646SRoman Lebedev return x;
108f11d5646SRoman Lebedev }
109f11d5646SRoman Lebedev
110320e9af3SRoman Lebedev #line 10111 // !!!
111f11d5646SRoman Lebedev
main()112f11d5646SRoman Lebedev int main() {
113630fa0eeSRoman Lebedev // No bits set.
114f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_int(0);
115f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_char(0);
116f11d5646SRoman Lebedev convert_signed_int_to_signed_int(0);
117f11d5646SRoman Lebedev convert_signed_char_to_signed_char(0);
118f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_char(0);
119f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_int(0);
120f11d5646SRoman Lebedev convert_unsigned_char_to_signed_int(0);
121f11d5646SRoman Lebedev convert_signed_char_to_signed_int(0);
122f11d5646SRoman Lebedev convert_unsigned_int_to_signed_int(0);
123f11d5646SRoman Lebedev convert_signed_int_to_unsigned_int(0);
124f11d5646SRoman Lebedev convert_signed_int_to_unsigned_char(0);
125f11d5646SRoman Lebedev convert_signed_char_to_unsigned_char(0);
126f11d5646SRoman Lebedev convert_unsigned_char_to_signed_char(0);
127f11d5646SRoman Lebedev convert_signed_char_to_unsigned_int(0);
128f11d5646SRoman Lebedev convert_unsigned_int_to_signed_char(0);
129f11d5646SRoman Lebedev convert_signed_int_to_signed_char(0);
130630fa0eeSRoman Lebedev
131630fa0eeSRoman Lebedev // One lowest bit set.
132f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_int(1);
133f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_char(1);
134f11d5646SRoman Lebedev convert_signed_int_to_signed_int(1);
135f11d5646SRoman Lebedev convert_signed_char_to_signed_char(1);
136f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_char(1);
137f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_int(1);
138f11d5646SRoman Lebedev convert_unsigned_char_to_signed_int(1);
139f11d5646SRoman Lebedev convert_signed_char_to_signed_int(1);
140f11d5646SRoman Lebedev convert_unsigned_int_to_signed_int(1);
141f11d5646SRoman Lebedev convert_signed_int_to_unsigned_int(1);
142f11d5646SRoman Lebedev convert_signed_int_to_unsigned_char(1);
143f11d5646SRoman Lebedev convert_signed_char_to_unsigned_char(1);
144f11d5646SRoman Lebedev convert_unsigned_char_to_signed_char(1);
145f11d5646SRoman Lebedev convert_signed_char_to_unsigned_int(1);
146f11d5646SRoman Lebedev convert_unsigned_int_to_signed_char(1);
147f11d5646SRoman Lebedev convert_signed_int_to_signed_char(1);
148630fa0eeSRoman Lebedev
149630fa0eeSRoman Lebedev #if defined(V0)
150630fa0eeSRoman Lebedev // All source bits set.
151f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_int((uint32_t)UINT32_MAX);
152f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_char((uint8_t)UINT8_MAX);
153f11d5646SRoman Lebedev convert_signed_int_to_signed_int((int32_t)(uint32_t)UINT32_MAX);
154f11d5646SRoman Lebedev convert_signed_char_to_signed_char((int8_t)UINT8_MAX);
155f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_char((uint32_t)UINT32_MAX);
15637eefc07SKamil Rytarowski // CHECK-V0: {{.*}}integer-conversion.c:500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 4294967295 (32-bit, unsigned) to type '{{.*}}' (aka 'unsigned char') changed the value to 255 (8-bit, unsigned
157f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_int((uint8_t)UINT8_MAX);
158f11d5646SRoman Lebedev convert_unsigned_char_to_signed_int((uint8_t)UINT8_MAX);
159f11d5646SRoman Lebedev convert_signed_char_to_signed_int((int8_t)UINT8_MAX);
160f11d5646SRoman Lebedev convert_unsigned_int_to_signed_int((uint32_t)UINT32_MAX);
16137eefc07SKamil Rytarowski // CHECK-V0: {{.*}}integer-conversion.c:900:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 4294967295 (32-bit, unsigned) to type '{{.*}}' (aka 'int') changed the value to -1 (32-bit, signed)
162f11d5646SRoman Lebedev convert_signed_int_to_unsigned_int((int32_t)(uint32_t)UINT32_MAX);
16337eefc07SKamil Rytarowski // CHECK-V0: {{.*}}integer-conversion.c:1000:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -1 (32-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 4294967295 (32-bit, unsigned)
164f11d5646SRoman Lebedev convert_signed_int_to_unsigned_char((int32_t)(uint32_t)UINT32_MAX);
16537eefc07SKamil Rytarowski // CHECK-V0: {{.*}}integer-conversion.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)
166f11d5646SRoman Lebedev convert_signed_char_to_unsigned_char((int8_t)UINT8_MAX);
167*04ea772dSRainer Orth // CHECK-V0: {{.*}}integer-conversion.c:1200:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -1 (8-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 255 (8-bit, unsigned)
168f11d5646SRoman Lebedev convert_unsigned_char_to_signed_char((uint8_t)UINT8_MAX);
169*04ea772dSRainer Orth // CHECK-V0: {{.*}}integer-conversion.c:1300:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned char') of value 255 (8-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -1 (8-bit, signed)
170f11d5646SRoman Lebedev convert_signed_char_to_unsigned_int((int8_t)UINT8_MAX);
171*04ea772dSRainer Orth // CHECK-V0: {{.*}}integer-conversion.c:1400:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -1 (8-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 4294967295 (32-bit, unsigned)
172f11d5646SRoman Lebedev convert_unsigned_int_to_signed_char((uint32_t)UINT32_MAX);
173*04ea772dSRainer Orth // CHECK-V0: {{.*}}integer-conversion.c:1500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 4294967295 (32-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -1 (8-bit, signed)
174f11d5646SRoman Lebedev convert_signed_int_to_signed_char((int32_t)(uint32_t)UINT32_MAX);
175630fa0eeSRoman Lebedev #elif defined(V1)
176630fa0eeSRoman Lebedev // Source 'Sign' bit set.
177f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_int((uint32_t)INT32_MIN);
178f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_char((uint8_t)INT8_MIN);
179f11d5646SRoman Lebedev convert_signed_int_to_signed_int((int32_t)(uint32_t)INT32_MIN);
180f11d5646SRoman Lebedev convert_signed_char_to_signed_char((int8_t)INT8_MIN);
181f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_char((uint32_t)INT32_MIN);
18237eefc07SKamil Rytarowski // CHECK-V1: {{.*}}integer-conversion.c:500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483648 (32-bit, unsigned) to type '{{.*}}' (aka 'unsigned char') changed the value to 0 (8-bit, unsigned)
183f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_int((uint8_t)INT8_MIN);
184f11d5646SRoman Lebedev convert_unsigned_char_to_signed_int((uint8_t)INT8_MIN);
185f11d5646SRoman Lebedev convert_signed_char_to_signed_int((int8_t)INT8_MIN);
186f11d5646SRoman Lebedev convert_unsigned_int_to_signed_int((uint32_t)INT32_MIN);
18737eefc07SKamil Rytarowski // CHECK-V1: {{.*}}integer-conversion.c:900:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483648 (32-bit, unsigned) to type '{{.*}}' (aka 'int') changed the value to -2147483648 (32-bit, signed)
188f11d5646SRoman Lebedev convert_signed_int_to_unsigned_int((int32_t)(uint32_t)INT32_MIN);
18937eefc07SKamil Rytarowski // CHECK-V1: {{.*}}integer-conversion.c:1000:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -2147483648 (32-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 2147483648 (32-bit, unsigned)
190f11d5646SRoman Lebedev convert_signed_int_to_unsigned_char((int32_t)(uint32_t)INT32_MIN);
19137eefc07SKamil Rytarowski // CHECK-V1: {{.*}}integer-conversion.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)
192f11d5646SRoman Lebedev convert_signed_char_to_unsigned_char((int8_t)INT8_MIN);
193*04ea772dSRainer Orth // CHECK-V1: {{.*}}integer-conversion.c:1200:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -128 (8-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 128 (8-bit, unsigned)
194f11d5646SRoman Lebedev convert_unsigned_char_to_signed_char((uint8_t)INT8_MIN);
195*04ea772dSRainer Orth // CHECK-V1: {{.*}}integer-conversion.c:1300:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned char') of value 128 (8-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -128 (8-bit, signed)
196f11d5646SRoman Lebedev convert_signed_char_to_unsigned_int((int8_t)INT8_MIN);
197*04ea772dSRainer Orth // CHECK-V1: {{.*}}integer-conversion.c:1400:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -128 (8-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 4294967168 (32-bit, unsigned)
198f11d5646SRoman Lebedev convert_unsigned_int_to_signed_char((uint32_t)INT32_MIN);
199*04ea772dSRainer Orth // CHECK-V1: {{.*}}integer-conversion.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)
200f11d5646SRoman Lebedev convert_signed_int_to_signed_char((int32_t)(uint32_t)INT32_MIN);
201*04ea772dSRainer Orth // CHECK-V1: {{.*}}integer-conversion.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)
202630fa0eeSRoman Lebedev #elif defined(V2)
203630fa0eeSRoman Lebedev // All bits except the source 'Sign' bit are set.
204f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_int((uint32_t)INT32_MAX);
205f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_char((uint8_t)INT8_MAX);
206f11d5646SRoman Lebedev convert_signed_int_to_signed_int((int32_t)(uint32_t)INT32_MAX);
207f11d5646SRoman Lebedev convert_signed_char_to_signed_char((int8_t)INT8_MAX);
208f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_char((uint32_t)INT32_MAX);
20937eefc07SKamil Rytarowski // CHECK-V2: {{.*}}integer-conversion.c:500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483647 (32-bit, unsigned) to type '{{.*}}' (aka 'unsigned char') changed the value to 255 (8-bit, unsigned)
210f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_int((uint8_t)INT8_MAX);
211f11d5646SRoman Lebedev convert_unsigned_char_to_signed_int((uint8_t)INT8_MAX);
212f11d5646SRoman Lebedev convert_signed_char_to_signed_int((int8_t)INT8_MAX);
213f11d5646SRoman Lebedev convert_unsigned_int_to_signed_int((uint32_t)INT32_MAX);
214f11d5646SRoman Lebedev convert_signed_int_to_unsigned_int((int32_t)(uint32_t)INT32_MAX);
215f11d5646SRoman Lebedev convert_signed_int_to_unsigned_char((int32_t)(uint32_t)INT32_MAX);
21637eefc07SKamil Rytarowski // CHECK-V2: {{.*}}integer-conversion.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)
217f11d5646SRoman Lebedev convert_signed_char_to_unsigned_char((int8_t)INT8_MAX);
218f11d5646SRoman Lebedev convert_unsigned_char_to_signed_char((uint8_t)INT8_MAX);
219f11d5646SRoman Lebedev convert_signed_char_to_unsigned_int((int8_t)INT8_MAX);
220f11d5646SRoman Lebedev convert_unsigned_int_to_signed_char((uint32_t)INT32_MAX);
221*04ea772dSRainer Orth // CHECK-V2: {{.*}}integer-conversion.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)
222f11d5646SRoman Lebedev convert_signed_int_to_signed_char((int32_t)(uint32_t)INT32_MAX);
223*04ea772dSRainer Orth // CHECK-V2: {{.*}}integer-conversion.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)
224630fa0eeSRoman Lebedev #elif defined(V3)
225630fa0eeSRoman Lebedev // All destination bits set.
226f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_int((uint32_t)UINT8_MAX);
227f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_char((uint8_t)UINT8_MAX);
228f11d5646SRoman Lebedev convert_signed_int_to_signed_int((int32_t)(uint32_t)UINT8_MAX);
229f11d5646SRoman Lebedev convert_signed_char_to_signed_char((int8_t)UINT8_MAX);
230f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_char((uint32_t)UINT8_MAX);
231f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_int((uint8_t)UINT8_MAX);
232f11d5646SRoman Lebedev convert_unsigned_char_to_signed_int((uint8_t)UINT8_MAX);
233f11d5646SRoman Lebedev convert_signed_char_to_signed_int((int8_t)UINT8_MAX);
234f11d5646SRoman Lebedev convert_unsigned_int_to_signed_int((uint32_t)UINT8_MAX);
235f11d5646SRoman Lebedev convert_signed_int_to_unsigned_int((int32_t)(uint32_t)UINT8_MAX);
236f11d5646SRoman Lebedev convert_signed_int_to_unsigned_char((int32_t)(uint32_t)UINT8_MAX);
237f11d5646SRoman Lebedev convert_signed_char_to_unsigned_char((int8_t)UINT8_MAX);
238*04ea772dSRainer Orth // CHECK-V3: {{.*}}integer-conversion.c:1200:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -1 (8-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 255 (8-bit, unsigned)
239f11d5646SRoman Lebedev convert_unsigned_char_to_signed_char((uint8_t)UINT8_MAX);
240*04ea772dSRainer Orth // CHECK-V3: {{.*}}integer-conversion.c:1300:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned char') of value 255 (8-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -1 (8-bit, signed)
241f11d5646SRoman Lebedev convert_signed_char_to_unsigned_int((int8_t)UINT8_MAX);
242*04ea772dSRainer Orth // CHECK-V3: {{.*}}integer-conversion.c:1400:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -1 (8-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 4294967295 (32-bit, unsigned)
243f11d5646SRoman Lebedev convert_unsigned_int_to_signed_char((uint32_t)UINT8_MAX);
244*04ea772dSRainer Orth // CHECK-V3: {{.*}}integer-conversion.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)
245f11d5646SRoman Lebedev convert_signed_int_to_signed_char((int32_t)(uint32_t)UINT8_MAX);
246*04ea772dSRainer Orth // CHECK-V3: {{.*}}integer-conversion.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)
247630fa0eeSRoman Lebedev #elif defined(V4)
248630fa0eeSRoman Lebedev // Destination 'sign' bit set.
249f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_int((uint32_t)(uint8_t)INT8_MIN);
250f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_char((uint8_t)(uint8_t)INT8_MIN);
251f11d5646SRoman Lebedev convert_signed_int_to_signed_int((int32_t)(uint32_t)(uint8_t)INT8_MIN);
252f11d5646SRoman Lebedev convert_signed_char_to_signed_char((int8_t)(uint8_t)INT8_MIN);
253f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_char((uint32_t)(uint8_t)INT8_MIN);
254f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_int((uint8_t)(uint8_t)INT8_MIN);
255f11d5646SRoman Lebedev convert_unsigned_char_to_signed_int((uint8_t)(uint8_t)INT8_MIN);
256f11d5646SRoman Lebedev convert_signed_char_to_signed_int((int8_t)(uint8_t)INT8_MIN);
257f11d5646SRoman Lebedev convert_unsigned_int_to_signed_int((uint32_t)(uint8_t)INT8_MIN);
258f11d5646SRoman Lebedev convert_signed_int_to_unsigned_int((int32_t)(uint32_t)(uint8_t)INT8_MIN);
259f11d5646SRoman Lebedev convert_signed_int_to_unsigned_char((int32_t)(uint32_t)(uint8_t)INT8_MIN);
260f11d5646SRoman Lebedev convert_signed_char_to_unsigned_char((int8_t)(uint8_t)INT8_MIN);
261*04ea772dSRainer Orth // CHECK-V4: {{.*}}integer-conversion.c:1200:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -128 (8-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 128 (8-bit, unsigned)
262f11d5646SRoman Lebedev convert_unsigned_char_to_signed_char((uint8_t)(uint8_t)INT8_MIN);
263*04ea772dSRainer Orth // CHECK-V4: {{.*}}integer-conversion.c:1300:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned char') of value 128 (8-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -128 (8-bit, signed)
264f11d5646SRoman Lebedev convert_signed_char_to_unsigned_int((int8_t)(uint8_t)INT8_MIN);
265*04ea772dSRainer Orth // CHECK-V4: {{.*}}integer-conversion.c:1400:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -128 (8-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 4294967168 (32-bit, unsigned)
266f11d5646SRoman Lebedev convert_unsigned_int_to_signed_char((uint32_t)(uint8_t)INT8_MIN);
267*04ea772dSRainer Orth // CHECK-V4: {{.*}}integer-conversion.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)
268f11d5646SRoman Lebedev convert_signed_int_to_signed_char((int32_t)(uint32_t)(uint8_t)INT8_MIN);
269*04ea772dSRainer Orth // CHECK-V4: {{.*}}integer-conversion.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)
270630fa0eeSRoman Lebedev #elif defined(V5)
271630fa0eeSRoman Lebedev // All bits except the destination 'sign' bit are set.
272f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_int((~((uint32_t)(uint8_t)INT8_MIN)));
273f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_char((uint8_t)(uint8_t)INT8_MIN);
274f11d5646SRoman Lebedev convert_signed_int_to_signed_int((int32_t)(~((uint32_t)(uint8_t)INT8_MIN)));
275f11d5646SRoman Lebedev convert_signed_char_to_signed_char((int8_t)(uint8_t)INT8_MIN);
276f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_char((~((uint32_t)(uint8_t)INT8_MIN)));
27737eefc07SKamil Rytarowski // CHECK-V5: {{.*}}integer-conversion.c:500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 4294967167 (32-bit, unsigned) to type '{{.*}}' (aka 'unsigned char') changed the value to 127 (8-bit, unsigned)
278f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_int((uint8_t)(uint8_t)INT8_MIN);
279f11d5646SRoman Lebedev convert_unsigned_char_to_signed_int((uint8_t)(uint8_t)INT8_MIN);
280f11d5646SRoman Lebedev convert_signed_char_to_signed_int((int8_t)(uint8_t)INT8_MIN);
281f11d5646SRoman Lebedev convert_unsigned_int_to_signed_int((~((uint32_t)(uint8_t)INT8_MIN)));
28237eefc07SKamil Rytarowski // CHECK-V5: {{.*}}integer-conversion.c:900:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 4294967167 (32-bit, unsigned) to type '{{.*}}' (aka 'int') changed the value to -129 (32-bit, signed)
283f11d5646SRoman Lebedev convert_signed_int_to_unsigned_int((int32_t)(~((uint32_t)(uint8_t)INT8_MIN)));
28437eefc07SKamil Rytarowski // CHECK-V5: {{.*}}integer-conversion.c:1000:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -129 (32-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 4294967167 (32-bit, unsigned)
285f11d5646SRoman Lebedev convert_signed_int_to_unsigned_char((int32_t)(~((uint32_t)(uint8_t)INT8_MIN)));
28637eefc07SKamil Rytarowski // CHECK-V5: {{.*}}integer-conversion.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)
287f11d5646SRoman Lebedev convert_signed_char_to_unsigned_char((int8_t)(uint8_t)INT8_MIN);
288*04ea772dSRainer Orth // CHECK-V5: {{.*}}integer-conversion.c:1200:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -128 (8-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 128 (8-bit, unsigned)
289f11d5646SRoman Lebedev convert_unsigned_char_to_signed_char((uint8_t)(uint8_t)INT8_MIN);
290*04ea772dSRainer Orth // CHECK-V5: {{.*}}integer-conversion.c:1300:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned char') of value 128 (8-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -128 (8-bit, signed)
291f11d5646SRoman Lebedev convert_signed_char_to_unsigned_int((int8_t)(uint8_t)INT8_MIN);
292*04ea772dSRainer Orth // CHECK-V5: {{.*}}integer-conversion.c:1400:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -128 (8-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 4294967168 (32-bit, unsigned)
293f11d5646SRoman Lebedev convert_unsigned_int_to_signed_char((~((uint32_t)(uint8_t)INT8_MIN)));
294*04ea772dSRainer Orth // CHECK-V5: {{.*}}integer-conversion.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)
295f11d5646SRoman Lebedev convert_signed_int_to_signed_char((int32_t)(~((uint32_t)(uint8_t)INT8_MIN)));
296*04ea772dSRainer Orth // CHECK-V5: {{.*}}integer-conversion.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)
297630fa0eeSRoman Lebedev #elif defined(V6)
298630fa0eeSRoman Lebedev // Only the source and destination sign bits are set.
299f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_int((uint32_t)INT32_MIN);
300f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_char((uint8_t)INT8_MIN);
301f11d5646SRoman Lebedev convert_signed_int_to_signed_int((int32_t)INT32_MIN);
302f11d5646SRoman Lebedev convert_signed_char_to_signed_char((int8_t)INT8_MIN);
303f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_char(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN));
30437eefc07SKamil Rytarowski // CHECK-V6: {{.*}}integer-conversion.c:500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483776 (32-bit, unsigned) to type '{{.*}}' (aka 'unsigned char') changed the value to 128 (8-bit, unsigned)
305f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_int((uint8_t)INT8_MIN);
306f11d5646SRoman Lebedev convert_unsigned_char_to_signed_int((uint8_t)INT8_MIN);
307f11d5646SRoman Lebedev convert_signed_char_to_signed_int((int8_t)INT8_MIN);
308f11d5646SRoman Lebedev convert_unsigned_int_to_signed_int((uint32_t)INT32_MIN);
30937eefc07SKamil Rytarowski // CHECK-V6: {{.*}}integer-conversion.c:900:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483648 (32-bit, unsigned) to type '{{.*}}' (aka 'int') changed the value to -2147483648 (32-bit, signed)
310320e9af3SRoman Lebedev convert_signed_int_to_unsigned_int((int32_t)INT32_MIN);
31137eefc07SKamil Rytarowski // CHECK-V6: {{.*}}integer-conversion.c:1000:10: runtime error: implicit conversion from type '{{.*}}' (aka 'int') of value -2147483648 (32-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 2147483648 (32-bit, unsigned)
312f11d5646SRoman Lebedev convert_signed_int_to_unsigned_char((int32_t)(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
31337eefc07SKamil Rytarowski // CHECK-V6: {{.*}}integer-conversion.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)
314f11d5646SRoman Lebedev convert_signed_char_to_unsigned_char((int8_t)INT8_MIN);
315*04ea772dSRainer Orth // CHECK-V6: {{.*}}integer-conversion.c:1200:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -128 (8-bit, signed) to type '{{.*}}' (aka 'unsigned char') changed the value to 128 (8-bit, unsigned)
316f11d5646SRoman Lebedev convert_unsigned_char_to_signed_char((uint8_t)INT8_MIN);
317*04ea772dSRainer Orth // CHECK-V6: {{.*}}integer-conversion.c:1300:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned char') of value 128 (8-bit, unsigned) to type '{{.*}}' (aka '{{(signed )?}}char') changed the value to -128 (8-bit, signed)
318f11d5646SRoman Lebedev convert_signed_char_to_unsigned_int((int8_t)INT8_MIN);
319*04ea772dSRainer Orth // CHECK-V6: {{.*}}integer-conversion.c:1400:10: runtime error: implicit conversion from type '{{.*}}' (aka '{{(signed )?}}char') of value -128 (8-bit, signed) to type '{{.*}}' (aka 'unsigned int') changed the value to 4294967168 (32-bit, unsigned)
320f11d5646SRoman Lebedev convert_unsigned_int_to_signed_char((((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
321*04ea772dSRainer Orth // CHECK-V6: {{.*}}integer-conversion.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)
322f11d5646SRoman Lebedev convert_signed_int_to_signed_char((int32_t)(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
323*04ea772dSRainer Orth // CHECK-V6: {{.*}}integer-conversion.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)
324f11d5646SRoman Lebedev #elif defined(V7)
325f11d5646SRoman Lebedev // All bits except the source and destination sign bits are set.
326f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_int((uint32_t)INT32_MAX);
327f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_char((uint8_t)INT8_MAX);
328f11d5646SRoman Lebedev convert_signed_int_to_signed_int((int32_t)INT32_MAX);
329f11d5646SRoman Lebedev convert_signed_char_to_signed_char((int8_t)INT8_MAX);
330f11d5646SRoman Lebedev convert_unsigned_int_to_unsigned_char(~(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
33137eefc07SKamil Rytarowski // CHECK-V7: {{.*}}integer-conversion.c:500:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 2147483519 (32-bit, unsigned) to type '{{.*}}' (aka 'unsigned char') changed the value to 127 (8-bit, unsigned)
332f11d5646SRoman Lebedev convert_unsigned_char_to_unsigned_int((uint8_t)INT8_MAX);
333f11d5646SRoman Lebedev convert_unsigned_char_to_signed_int((uint8_t)INT8_MAX);
334f11d5646SRoman Lebedev convert_signed_char_to_signed_int((int8_t)INT8_MAX);
335f11d5646SRoman Lebedev convert_unsigned_int_to_signed_int((uint32_t)INT32_MAX);
336320e9af3SRoman Lebedev convert_signed_int_to_unsigned_int((int32_t)INT32_MAX);
337f11d5646SRoman Lebedev convert_signed_int_to_unsigned_char((int32_t)(~(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN))));
33837eefc07SKamil Rytarowski // CHECK-V7: {{.*}}integer-conversion.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)
339f11d5646SRoman Lebedev convert_signed_char_to_unsigned_char((int8_t)INT8_MAX);
340f11d5646SRoman Lebedev convert_unsigned_char_to_signed_char((uint8_t)INT8_MAX);
341f11d5646SRoman Lebedev convert_signed_char_to_unsigned_int((int8_t)INT8_MAX);
342f11d5646SRoman Lebedev convert_unsigned_int_to_signed_char(~(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
343*04ea772dSRainer Orth // CHECK-V7: {{.*}}integer-conversion.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)
344f11d5646SRoman Lebedev convert_signed_int_to_signed_char((int32_t)~(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
345*04ea772dSRainer Orth // CHECK-V7: {{.*}}integer-conversion.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)
346630fa0eeSRoman Lebedev #else
347630fa0eeSRoman Lebedev #error Some V* needs to be defined!
348630fa0eeSRoman Lebedev #endif
349630fa0eeSRoman Lebedev
350630fa0eeSRoman Lebedev return 0;
351630fa0eeSRoman Lebedev }
352