1 | // RUN: %clang -fsanitize=implicit-integer-sign-change -fno-sanitize-recover=implicit-integer-sign-change -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,ERROR |
2 | // RUN: %clang -fsanitize=implicit-integer-sign-change -fno-sanitize-recover=implicit-integer-sign-change -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,ERROR |
3 | // RUN: %clang -fsanitize=implicit-integer-sign-change -fno-sanitize-recover=implicit-integer-sign-change -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,ERROR |
4 | // RUN: %clang -fsanitize=implicit-integer-sign-change -fno-sanitize-recover=implicit-integer-sign-change -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,ERROR |
5 | |
6 | // RUN: rm -f %tmp |
7 | // RUN: echo "[implicit-integer-sign-change]" >> %tmp |
8 | // RUN: echo "fun:implicitSignChange" >> %tmp |
9 | // RUN: %clang -fsanitize=implicit-integer-sign-change -fno-sanitize-recover=implicit-integer-sign-change -fsanitize-ignorelist=%tmp -O0 %s -o %t && %run %t 2>&1 | FileCheck %s |
10 | // RUN: %clang -fsanitize=implicit-integer-sign-change -fno-sanitize-recover=implicit-integer-sign-change -fsanitize-ignorelist=%tmp -O1 %s -o %t && %run %t 2>&1 | FileCheck %s |
11 | // RUN: %clang -fsanitize=implicit-integer-sign-change -fno-sanitize-recover=implicit-integer-sign-change -fsanitize-ignorelist=%tmp -O2 %s -o %t && %run %t 2>&1 | FileCheck %s |
12 | // RUN: %clang -fsanitize=implicit-integer-sign-change -fno-sanitize-recover=implicit-integer-sign-change -fsanitize-ignorelist=%tmp -O3 %s -o %t && %run %t 2>&1 | FileCheck %s |
13 | |
14 | #include <stdint.h> |
15 | #include <stdio.h> |
16 | |
17 | int32_t implicitSignChange(uint32_t argc) { |
18 | fprintf(stderr, format: "TEST\n" ); |
19 | // CHECK-NOT: runtime error |
20 | // CHECK-LABEL: TEST |
21 | return argc; // BOOM |
22 | // ERROR: {{.*}}integer-sign-change-ignorelist.c:[[@LINE-1]]: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) |
23 | // CHECK-NOT: runtime error |
24 | } |
25 | |
26 | int main(int argc, char **argv) { |
27 | return !implicitSignChange(argc: ~0U); |
28 | } |
29 | |