1320e9af3SRoman Lebedev // RUN: %clang   -x c   -fsanitize=implicit-integer-arithmetic-value-change %s -DV0 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V0
2320e9af3SRoman Lebedev // RUN: %clang   -x c   -fsanitize=implicit-integer-arithmetic-value-change %s -DV1 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V1
3320e9af3SRoman Lebedev // RUN: %clang   -x c   -fsanitize=implicit-integer-arithmetic-value-change %s -DV2 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V2
4320e9af3SRoman Lebedev // RUN: %clang   -x c   -fsanitize=implicit-integer-arithmetic-value-change %s -DV3 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V3
5320e9af3SRoman Lebedev // RUN: %clang   -x c   -fsanitize=implicit-integer-arithmetic-value-change %s -DV4 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V4
6320e9af3SRoman Lebedev // RUN: %clang   -x c   -fsanitize=implicit-integer-arithmetic-value-change %s -DV5 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V5
7320e9af3SRoman Lebedev // RUN: %clang   -x c   -fsanitize=implicit-integer-arithmetic-value-change %s -DV6 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V6
8320e9af3SRoman Lebedev // RUN: %clang   -x c   -fsanitize=implicit-integer-arithmetic-value-change %s -DV7 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V7
9320e9af3SRoman Lebedev 
10320e9af3SRoman Lebedev // RUN: %clang   -x c++ -fsanitize=implicit-integer-arithmetic-value-change %s -DV0 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V0
11320e9af3SRoman Lebedev // RUN: %clang   -x c++ -fsanitize=implicit-integer-arithmetic-value-change %s -DV1 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V1
12320e9af3SRoman Lebedev // RUN: %clang   -x c++ -fsanitize=implicit-integer-arithmetic-value-change %s -DV2 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V2
13320e9af3SRoman Lebedev // RUN: %clang   -x c++ -fsanitize=implicit-integer-arithmetic-value-change %s -DV3 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V3
14320e9af3SRoman Lebedev // RUN: %clang   -x c++ -fsanitize=implicit-integer-arithmetic-value-change %s -DV4 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V4
15320e9af3SRoman Lebedev // RUN: %clang   -x c++ -fsanitize=implicit-integer-arithmetic-value-change %s -DV5 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V5
16320e9af3SRoman Lebedev // RUN: %clang   -x c++ -fsanitize=implicit-integer-arithmetic-value-change %s -DV6 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V6
17320e9af3SRoman Lebedev // RUN: %clang   -x c++ -fsanitize=implicit-integer-arithmetic-value-change %s -DV7 -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK-V7
18320e9af3SRoman Lebedev 
19320e9af3SRoman Lebedev #include <stdint.h>
20320e9af3SRoman Lebedev 
21320e9af3SRoman Lebedev // Test plan:
22320e9af3SRoman Lebedev //  * Two types - int and char
23320e9af3SRoman Lebedev //  * Two signs - signed and unsigned
24320e9af3SRoman Lebedev //  * Square that - we have input and output types.
25320e9af3SRoman Lebedev // Thus, there are total of (2*2)^2 == 16 tests.
26320e9af3SRoman Lebedev // These are all the possible variations/combinations of casts.
27320e9af3SRoman Lebedev // However, not all of them should result in the check.
28320e9af3SRoman Lebedev // So here, we *only* check which should and which should not result in checks.
29320e9af3SRoman Lebedev 
convert_unsigned_int_to_unsigned_int(uint32_t x)30a0457c02SRoman Lebedev uint32_t convert_unsigned_int_to_unsigned_int(uint32_t x) {
31320e9af3SRoman Lebedev #line 100
32320e9af3SRoman Lebedev   return x;
33320e9af3SRoman Lebedev }
34320e9af3SRoman Lebedev 
convert_unsigned_char_to_unsigned_char(uint8_t x)35a0457c02SRoman Lebedev uint8_t convert_unsigned_char_to_unsigned_char(uint8_t x) {
36320e9af3SRoman Lebedev #line 200
37320e9af3SRoman Lebedev   return x;
38320e9af3SRoman Lebedev }
39320e9af3SRoman Lebedev 
convert_signed_int_to_signed_int(int32_t x)40a0457c02SRoman Lebedev int32_t convert_signed_int_to_signed_int(int32_t x) {
41320e9af3SRoman Lebedev #line 300
42320e9af3SRoman Lebedev   return x;
43320e9af3SRoman Lebedev }
44320e9af3SRoman Lebedev 
convert_signed_char_to_signed_char(int8_t x)45a0457c02SRoman Lebedev int8_t convert_signed_char_to_signed_char(int8_t x) {
46320e9af3SRoman Lebedev #line 400
47320e9af3SRoman Lebedev   return x;
48320e9af3SRoman Lebedev }
49320e9af3SRoman Lebedev 
convert_unsigned_int_to_unsigned_char(uint32_t x)50a0457c02SRoman Lebedev uint8_t convert_unsigned_int_to_unsigned_char(uint32_t x) {
51320e9af3SRoman Lebedev #line 500
52320e9af3SRoman Lebedev   return x;
53320e9af3SRoman Lebedev }
54320e9af3SRoman Lebedev 
convert_unsigned_char_to_unsigned_int(uint8_t x)55a0457c02SRoman Lebedev uint32_t convert_unsigned_char_to_unsigned_int(uint8_t x) {
56320e9af3SRoman Lebedev #line 600
57320e9af3SRoman Lebedev   return x;
58320e9af3SRoman Lebedev }
59320e9af3SRoman Lebedev 
convert_unsigned_char_to_signed_int(uint8_t x)60a0457c02SRoman Lebedev int32_t convert_unsigned_char_to_signed_int(uint8_t x) {
61320e9af3SRoman Lebedev #line 700
62320e9af3SRoman Lebedev   return x;
63320e9af3SRoman Lebedev }
64320e9af3SRoman Lebedev 
convert_signed_char_to_signed_int(int8_t x)65a0457c02SRoman Lebedev int32_t convert_signed_char_to_signed_int(int8_t x) {
66320e9af3SRoman Lebedev #line 800
67320e9af3SRoman Lebedev   return x;
68320e9af3SRoman Lebedev }
69320e9af3SRoman Lebedev 
convert_unsigned_int_to_signed_int(uint32_t x)70a0457c02SRoman Lebedev int32_t convert_unsigned_int_to_signed_int(uint32_t x) {
71320e9af3SRoman Lebedev #line 900
72320e9af3SRoman Lebedev   return x;
73320e9af3SRoman Lebedev }
74320e9af3SRoman Lebedev 
convert_signed_int_to_unsigned_int(int32_t x)75a0457c02SRoman Lebedev uint32_t convert_signed_int_to_unsigned_int(int32_t x) {
76320e9af3SRoman Lebedev #line 1000
77320e9af3SRoman Lebedev   return x;
78320e9af3SRoman Lebedev }
79320e9af3SRoman Lebedev 
convert_signed_int_to_unsigned_char(int32_t x)80a0457c02SRoman Lebedev uint8_t convert_signed_int_to_unsigned_char(int32_t x) {
81320e9af3SRoman Lebedev #line 1100
82320e9af3SRoman Lebedev   return x;
83320e9af3SRoman Lebedev }
84320e9af3SRoman Lebedev 
convert_signed_char_to_unsigned_char(int8_t x)85a0457c02SRoman Lebedev uint8_t convert_signed_char_to_unsigned_char(int8_t x) {
86320e9af3SRoman Lebedev #line 1200
87320e9af3SRoman Lebedev   return x;
88320e9af3SRoman Lebedev }
89320e9af3SRoman Lebedev 
convert_unsigned_char_to_signed_char(uint8_t x)90a0457c02SRoman Lebedev int8_t convert_unsigned_char_to_signed_char(uint8_t x) {
91320e9af3SRoman Lebedev #line 1300
92320e9af3SRoman Lebedev   return x;
93320e9af3SRoman Lebedev }
94320e9af3SRoman Lebedev 
convert_signed_char_to_unsigned_int(int8_t x)95a0457c02SRoman Lebedev uint32_t convert_signed_char_to_unsigned_int(int8_t x) {
96320e9af3SRoman Lebedev #line 1400
97320e9af3SRoman Lebedev   return x;
98320e9af3SRoman Lebedev }
99320e9af3SRoman Lebedev 
convert_unsigned_int_to_signed_char(uint32_t x)100a0457c02SRoman Lebedev int8_t convert_unsigned_int_to_signed_char(uint32_t x) {
101320e9af3SRoman Lebedev #line 1500
102320e9af3SRoman Lebedev   return x;
103320e9af3SRoman Lebedev }
104320e9af3SRoman Lebedev 
convert_signed_int_to_signed_char(int32_t x)105a0457c02SRoman Lebedev int8_t convert_signed_int_to_signed_char(int32_t x) {
106320e9af3SRoman Lebedev #line 1600
107320e9af3SRoman Lebedev   return x;
108320e9af3SRoman Lebedev }
109320e9af3SRoman Lebedev 
110320e9af3SRoman Lebedev #line 10111 // !!!
111320e9af3SRoman Lebedev 
main()112320e9af3SRoman Lebedev int main() {
113320e9af3SRoman Lebedev   // No bits set.
114320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_int(0);
115320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_char(0);
116320e9af3SRoman Lebedev   convert_signed_int_to_signed_int(0);
117320e9af3SRoman Lebedev   convert_signed_char_to_signed_char(0);
118320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_char(0);
119320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_int(0);
120320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_int(0);
121320e9af3SRoman Lebedev   convert_signed_char_to_signed_int(0);
122320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_int(0);
123320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_int(0);
124320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_char(0);
125320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_char(0);
126320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_char(0);
127320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_int(0);
128320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_char(0);
129320e9af3SRoman Lebedev   convert_signed_int_to_signed_char(0);
130320e9af3SRoman Lebedev 
131320e9af3SRoman Lebedev   // One lowest bit set.
132320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_int(1);
133320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_char(1);
134320e9af3SRoman Lebedev   convert_signed_int_to_signed_int(1);
135320e9af3SRoman Lebedev   convert_signed_char_to_signed_char(1);
136320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_char(1);
137320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_int(1);
138320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_int(1);
139320e9af3SRoman Lebedev   convert_signed_char_to_signed_int(1);
140320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_int(1);
141320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_int(1);
142320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_char(1);
143320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_char(1);
144320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_char(1);
145320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_int(1);
146320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_char(1);
147320e9af3SRoman Lebedev   convert_signed_int_to_signed_char(1);
148320e9af3SRoman Lebedev 
149320e9af3SRoman Lebedev #if defined(V0)
150320e9af3SRoman Lebedev   // All source bits set.
151320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_int((uint32_t)UINT32_MAX);
152320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_char((uint8_t)UINT8_MAX);
153320e9af3SRoman Lebedev   convert_signed_int_to_signed_int((int32_t)(uint32_t)UINT32_MAX);
154320e9af3SRoman Lebedev   convert_signed_char_to_signed_char((int8_t)UINT8_MAX);
155320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_char((uint32_t)UINT32_MAX);
156320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_int((uint8_t)UINT8_MAX);
157320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_int((uint8_t)UINT8_MAX);
158320e9af3SRoman Lebedev   convert_signed_char_to_signed_int((int8_t)UINT8_MAX);
159320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_int((uint32_t)UINT32_MAX);
16037eefc07SKamil Rytarowski // CHECK-V0: {{.*}}integer-arithmetic-value-change.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)
161320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_int((int32_t)(uint32_t)UINT32_MAX);
16237eefc07SKamil Rytarowski // CHECK-V0: {{.*}}integer-arithmetic-value-change.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)
163320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_char((int32_t)(uint32_t)UINT32_MAX);
16437eefc07SKamil Rytarowski // CHECK-V0: {{.*}}integer-arithmetic-value-change.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)
165320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_char((int8_t)UINT8_MAX);
166*04ea772dSRainer Orth // CHECK-V0: {{.*}}integer-arithmetic-value-change.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)
167320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_char((uint8_t)UINT8_MAX);
168*04ea772dSRainer Orth // CHECK-V0: {{.*}}integer-arithmetic-value-change.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)
169320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_int((int8_t)UINT8_MAX);
170*04ea772dSRainer Orth // CHECK-V0: {{.*}}integer-arithmetic-value-change.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)
171320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_char((uint32_t)UINT32_MAX);
172*04ea772dSRainer Orth // CHECK-V0: {{.*}}integer-arithmetic-value-change.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)
173320e9af3SRoman Lebedev   convert_signed_int_to_signed_char((int32_t)(uint32_t)UINT32_MAX);
174320e9af3SRoman Lebedev #elif defined(V1)
175320e9af3SRoman Lebedev    // Source 'Sign' bit set.
176320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_int((uint32_t)INT32_MIN);
177320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_char((uint8_t)INT8_MIN);
178320e9af3SRoman Lebedev   convert_signed_int_to_signed_int((int32_t)(uint32_t)INT32_MIN);
179320e9af3SRoman Lebedev   convert_signed_char_to_signed_char((int8_t)INT8_MIN);
180320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_char((uint32_t)INT32_MIN);
181320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_int((uint8_t)INT8_MIN);
182320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_int((uint8_t)INT8_MIN);
183320e9af3SRoman Lebedev   convert_signed_char_to_signed_int((int8_t)INT8_MIN);
184320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_int((uint32_t)INT32_MIN);
18537eefc07SKamil Rytarowski // CHECK-V1: {{.*}}integer-arithmetic-value-change.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)
186320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_int((int32_t)(uint32_t)INT32_MIN);
18737eefc07SKamil Rytarowski // CHECK-V1: {{.*}}integer-arithmetic-value-change.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)
188320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_char((int32_t)(uint32_t)INT32_MIN);
18937eefc07SKamil Rytarowski // CHECK-V1: {{.*}}integer-arithmetic-value-change.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)
190320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_char((int8_t)INT8_MIN);
191*04ea772dSRainer Orth // CHECK-V1: {{.*}}integer-arithmetic-value-change.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)
192320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_char((uint8_t)INT8_MIN);
193*04ea772dSRainer Orth // CHECK-V1: {{.*}}integer-arithmetic-value-change.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)
194320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_int((int8_t)INT8_MIN);
195*04ea772dSRainer Orth // CHECK-V1: {{.*}}integer-arithmetic-value-change.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)
196320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_char((uint32_t)INT32_MIN);
197*04ea772dSRainer Orth // CHECK-V1: {{.*}}integer-arithmetic-value-change.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)
198320e9af3SRoman Lebedev   convert_signed_int_to_signed_char((int32_t)(uint32_t)INT32_MIN);
199*04ea772dSRainer Orth // CHECK-V1: {{.*}}integer-arithmetic-value-change.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)
200320e9af3SRoman Lebedev #elif defined(V2)
201320e9af3SRoman Lebedev   // All bits except the source 'Sign' bit are set.
202320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_int((uint32_t)INT32_MAX);
203320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_char((uint8_t)INT8_MAX);
204320e9af3SRoman Lebedev   convert_signed_int_to_signed_int((int32_t)(uint32_t)INT32_MAX);
205320e9af3SRoman Lebedev   convert_signed_char_to_signed_char((int8_t)INT8_MAX);
206320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_char((uint32_t)INT32_MAX);
207320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_int((uint8_t)INT8_MAX);
208320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_int((uint8_t)INT8_MAX);
209320e9af3SRoman Lebedev   convert_signed_char_to_signed_int((int8_t)INT8_MAX);
210320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_int((uint32_t)INT32_MAX);
211320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_int((int32_t)(uint32_t)INT32_MAX);
212320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_char((int32_t)(uint32_t)INT32_MAX);
21337eefc07SKamil Rytarowski // CHECK-V2: {{.*}}integer-arithmetic-value-change.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)
214320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_char((int8_t)INT8_MAX);
215320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_char((uint8_t)INT8_MAX);
216320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_int((int8_t)INT8_MAX);
217320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_char((uint32_t)INT32_MAX);
218*04ea772dSRainer Orth // CHECK-V2: {{.*}}integer-arithmetic-value-change.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)
219320e9af3SRoman Lebedev   convert_signed_int_to_signed_char((int32_t)(uint32_t)INT32_MAX);
220*04ea772dSRainer Orth // CHECK-V2: {{.*}}integer-arithmetic-value-change.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)
221320e9af3SRoman Lebedev #elif defined(V3)
222320e9af3SRoman Lebedev   // All destination bits set.
223320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_int((uint32_t)UINT8_MAX);
224320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_char((uint8_t)UINT8_MAX);
225320e9af3SRoman Lebedev   convert_signed_int_to_signed_int((int32_t)(uint32_t)UINT8_MAX);
226320e9af3SRoman Lebedev   convert_signed_char_to_signed_char((int8_t)UINT8_MAX);
227320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_char((uint32_t)UINT8_MAX);
228320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_int((uint8_t)UINT8_MAX);
229320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_int((uint8_t)UINT8_MAX);
230320e9af3SRoman Lebedev   convert_signed_char_to_signed_int((int8_t)UINT8_MAX);
231320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_int((uint32_t)UINT8_MAX);
232320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_int((int32_t)(uint32_t)UINT8_MAX);
233320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_char((int32_t)(uint32_t)UINT8_MAX);
234320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_char((int8_t)UINT8_MAX);
235*04ea772dSRainer Orth // CHECK-V3: {{.*}}integer-arithmetic-value-change.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)
236320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_char((uint8_t)UINT8_MAX);
237*04ea772dSRainer Orth // CHECK-V3: {{.*}}integer-arithmetic-value-change.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)
238320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_int((int8_t)UINT8_MAX);
239*04ea772dSRainer Orth // CHECK-V3: {{.*}}integer-arithmetic-value-change.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)
240320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_char((uint32_t)UINT8_MAX);
241*04ea772dSRainer Orth // CHECK-V3: {{.*}}integer-arithmetic-value-change.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)
242320e9af3SRoman Lebedev   convert_signed_int_to_signed_char((int32_t)(uint32_t)UINT8_MAX);
243*04ea772dSRainer Orth // CHECK-V3: {{.*}}integer-arithmetic-value-change.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)
244320e9af3SRoman Lebedev #elif defined(V4)
245320e9af3SRoman Lebedev   // Destination 'sign' bit set.
246320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_int((uint32_t)(uint8_t)INT8_MIN);
247320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_char((uint8_t)(uint8_t)INT8_MIN);
248320e9af3SRoman Lebedev   convert_signed_int_to_signed_int((int32_t)(uint32_t)(uint8_t)INT8_MIN);
249320e9af3SRoman Lebedev   convert_signed_char_to_signed_char((int8_t)(uint8_t)INT8_MIN);
250320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_char((uint32_t)(uint8_t)INT8_MIN);
251320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_int((uint8_t)(uint8_t)INT8_MIN);
252320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_int((uint8_t)(uint8_t)INT8_MIN);
253320e9af3SRoman Lebedev   convert_signed_char_to_signed_int((int8_t)(uint8_t)INT8_MIN);
254320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_int((uint32_t)(uint8_t)INT8_MIN);
255320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_int((int32_t)(uint32_t)(uint8_t)INT8_MIN);
256320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_char((int32_t)(uint32_t)(uint8_t)INT8_MIN);
257320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_char((int8_t)(uint8_t)INT8_MIN);
258*04ea772dSRainer Orth // CHECK-V4: {{.*}}integer-arithmetic-value-change.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)
259320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_char((uint8_t)(uint8_t)INT8_MIN);
260*04ea772dSRainer Orth // CHECK-V4: {{.*}}integer-arithmetic-value-change.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)
261320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_int((int8_t)(uint8_t)INT8_MIN);
262*04ea772dSRainer Orth // CHECK-V4: {{.*}}integer-arithmetic-value-change.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)
263320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_char((uint32_t)(uint8_t)INT8_MIN);
264*04ea772dSRainer Orth // CHECK-V4: {{.*}}integer-arithmetic-value-change.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)
265320e9af3SRoman Lebedev   convert_signed_int_to_signed_char((int32_t)(uint32_t)(uint8_t)INT8_MIN);
266*04ea772dSRainer Orth // CHECK-V4: {{.*}}integer-arithmetic-value-change.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)
267320e9af3SRoman Lebedev #elif defined(V5)
268320e9af3SRoman Lebedev   // All bits except the destination 'sign' bit are set.
269320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_int((~((uint32_t)(uint8_t)INT8_MIN)));
270320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_char((uint8_t)(uint8_t)INT8_MIN);
271320e9af3SRoman Lebedev   convert_signed_int_to_signed_int((int32_t)(~((uint32_t)(uint8_t)INT8_MIN)));
272320e9af3SRoman Lebedev   convert_signed_char_to_signed_char((int8_t)(uint8_t)INT8_MIN);
273320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_char((~((uint32_t)(uint8_t)INT8_MIN)));
274320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_int((uint8_t)(uint8_t)INT8_MIN);
275320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_int((uint8_t)(uint8_t)INT8_MIN);
276320e9af3SRoman Lebedev   convert_signed_char_to_signed_int((int8_t)(uint8_t)INT8_MIN);
277320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_int((~((uint32_t)(uint8_t)INT8_MIN)));
27837eefc07SKamil Rytarowski // CHECK-V5: {{.*}}integer-arithmetic-value-change.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)
279320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_int((int32_t)(~((uint32_t)(uint8_t)INT8_MIN)));
28037eefc07SKamil Rytarowski // CHECK-V5: {{.*}}integer-arithmetic-value-change.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)
281320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_char((int32_t)(~((uint32_t)(uint8_t)INT8_MIN)));
28237eefc07SKamil Rytarowski // CHECK-V5: {{.*}}integer-arithmetic-value-change.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)
283320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_char((int8_t)(uint8_t)INT8_MIN);
284*04ea772dSRainer Orth // CHECK-V5: {{.*}}integer-arithmetic-value-change.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)
285320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_char((uint8_t)(uint8_t)INT8_MIN);
286*04ea772dSRainer Orth // CHECK-V5: {{.*}}integer-arithmetic-value-change.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)
287320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_int((int8_t)(uint8_t)INT8_MIN);
288*04ea772dSRainer Orth // CHECK-V5: {{.*}}integer-arithmetic-value-change.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)
289320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_char((~((uint32_t)(uint8_t)INT8_MIN)));
290*04ea772dSRainer Orth // CHECK-V5: {{.*}}integer-arithmetic-value-change.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)
291320e9af3SRoman Lebedev   convert_signed_int_to_signed_char((int32_t)(~((uint32_t)(uint8_t)INT8_MIN)));
292*04ea772dSRainer Orth // CHECK-V5: {{.*}}integer-arithmetic-value-change.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)
293320e9af3SRoman Lebedev #elif defined(V6)
294320e9af3SRoman Lebedev   // Only the source and destination sign bits are set.
295320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_int((uint32_t)INT32_MIN);
296320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_char((uint8_t)INT8_MIN);
297320e9af3SRoman Lebedev   convert_signed_int_to_signed_int((int32_t)INT32_MIN);
298320e9af3SRoman Lebedev   convert_signed_char_to_signed_char((int8_t)INT8_MIN);
299320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_char(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN));
300320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_int((uint8_t)INT8_MIN);
301320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_int((uint8_t)INT8_MIN);
302320e9af3SRoman Lebedev   convert_signed_char_to_signed_int((int8_t)INT8_MIN);
303320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_int((uint32_t)INT32_MIN);
30437eefc07SKamil Rytarowski // CHECK-V6: {{.*}}integer-arithmetic-value-change.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)
305320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_int((int32_t)INT32_MIN);
30637eefc07SKamil Rytarowski // CHECK-V6: {{.*}}integer-arithmetic-value-change.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)
307320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_char((int32_t)(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
30837eefc07SKamil Rytarowski // CHECK-V6: {{.*}}integer-arithmetic-value-change.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)
309320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_char((int8_t)INT8_MIN);
310*04ea772dSRainer Orth // CHECK-V6: {{.*}}integer-arithmetic-value-change.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)
311320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_char((uint8_t)INT8_MIN);
312*04ea772dSRainer Orth // CHECK-V6: {{.*}}integer-arithmetic-value-change.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)
313320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_int((int8_t)INT8_MIN);
314*04ea772dSRainer Orth // CHECK-V6: {{.*}}integer-arithmetic-value-change.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)
315320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_char((((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
316*04ea772dSRainer Orth // CHECK-V6: {{.*}}integer-arithmetic-value-change.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)
317320e9af3SRoman Lebedev   convert_signed_int_to_signed_char((int32_t)(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
318*04ea772dSRainer Orth // CHECK-V6: {{.*}}integer-arithmetic-value-change.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)
319320e9af3SRoman Lebedev #elif defined(V7)
320320e9af3SRoman Lebedev   // All bits except the source and destination sign bits are set.
321320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_int((uint32_t)INT32_MAX);
322320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_char((uint8_t)INT8_MAX);
323320e9af3SRoman Lebedev   convert_signed_int_to_signed_int((int32_t)INT32_MAX);
324320e9af3SRoman Lebedev   convert_signed_char_to_signed_char((int8_t)INT8_MAX);
325320e9af3SRoman Lebedev   convert_unsigned_int_to_unsigned_char(~(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
326320e9af3SRoman Lebedev   convert_unsigned_char_to_unsigned_int((uint8_t)INT8_MAX);
327320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_int((uint8_t)INT8_MAX);
328320e9af3SRoman Lebedev   convert_signed_char_to_signed_int((int8_t)INT8_MAX);
329320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_int((uint32_t)INT32_MAX);
330320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_int((int32_t)INT32_MAX);
331320e9af3SRoman Lebedev   convert_signed_int_to_unsigned_char((int32_t)(~(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN))));
33237eefc07SKamil Rytarowski // CHECK-V7: {{.*}}integer-arithmetic-value-change.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)
333320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_char((int8_t)INT8_MAX);
334320e9af3SRoman Lebedev   convert_unsigned_char_to_signed_char((uint8_t)INT8_MAX);
335320e9af3SRoman Lebedev   convert_signed_char_to_unsigned_int((int8_t)INT8_MAX);
336320e9af3SRoman Lebedev   convert_unsigned_int_to_signed_char(~(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
337*04ea772dSRainer Orth // CHECK-V7: {{.*}}integer-arithmetic-value-change.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)
338320e9af3SRoman Lebedev   convert_signed_int_to_signed_char((int32_t)~(((uint32_t)INT32_MIN) | ((uint32_t)(uint8_t)INT8_MIN)));
339*04ea772dSRainer Orth // CHECK-V7: {{.*}}integer-arithmetic-value-change.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)
340320e9af3SRoman Lebedev #else
341320e9af3SRoman Lebedev #error Some V* needs to be defined!
342320e9af3SRoman Lebedev #endif
343320e9af3SRoman Lebedev 
344320e9af3SRoman Lebedev   return 0;
345320e9af3SRoman Lebedev }
346