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