1// RUN: %clang -fsanitize=implicit-integer-sign-change %s -o %t && %run %t 2>&1 | FileCheck %s
2// RUN: %clang -fsanitize=implicit-integer-sign-change -fno-sanitize-recover=all %s -o %t && not --crash %run %t 2>&1 | FileCheck %s
3// RUN: %clang -fsanitize=implicit-integer-sign-change -fno-sanitize-recover=all -DOVERRIDE=1 %s -o %t && not --crash %run %t 2>&1 | FileCheck %s --check-prefixes=FATAL
4
5#include <stdint.h>
6#include <stdio.h>
7#include <stdlib.h>
8
9static int Result;
10
11void __ubsan_report_error(const char *kind, uintptr_t caller) {
12 fprintf(stderr, format: "CUSTOM_CALLBACK: %s\n", kind);
13}
14
15#if OVERRIDE
16void __ubsan_report_error_fatal(const char *kind, uintptr_t caller) {
17 fprintf(stderr, "FATAL_CALLBACK: %s\n", kind);
18}
19#endif
20
21int main(int argc, const char **argv) {
22 int32_t t0 = (~((uint32_t)0));
23 // CHECK: CUSTOM_CALLBACK: implicit-conversion
24 // FATAL: FATAL_CALLBACK: implicit-conversion
25}
26

Provided by KDAB

Privacy Policy
Update your C++ knowledge – Modern C++11/14/17 Training
Find out more

source code of compiler-rt/test/ubsan_minimal/TestCases/override-callback.c