1 // RUN: %clangxx -fsanitize=integer -g0 %s -o %t
2
3 // Suppression by symbol name (unsigned-integer-overflow:do_overflow below)
4 // requires the compiler-rt runtime to be able to symbolize stack addresses.
5 // REQUIRES: can-symbolize
6
7 // Fails without any suppression.
8 // RUN: %env_ubsan_opts=halt_on_error=1 not %run %t 2>&1 | FileCheck %s
9
10 // RUN: echo "signed-integer-overflow:%t" > %t.wrong-supp
11 // RUN: %env_ubsan_opts=halt_on_error=1:suppressions='"%t.wrong-supp"' not %run %t 2>&1 | FileCheck %s
12
13 // RUN: echo "unsigned-integer-overflow:do_overflow" > %t.func-supp
14 // RUN: %env_ubsan_opts=halt_on_error=1:suppressions='"%t.func-supp"' %run %t
15 // RUN: echo "unsigned-integer-overflow:%t" > %t.module-supp
16 // RUN: %env_ubsan_opts=halt_on_error=1:suppressions='"%t.module-supp"' %run %t
17
18 // Note: file-level suppressions should work even without debug info.
19 // RUN: echo "unsigned-integer-overflow:%s" > %t.file-supp
20 // RUN: %env_ubsan_opts=halt_on_error=1:suppressions='"%t.file-supp"' %run %t
21
22 // Suppressions don't work for unrecoverable kinds.
23 // RUN: %clangxx -fsanitize=integer -fno-sanitize-recover=integer %s -o %t-norecover
24 // RUN: %env_ubsan_opts=halt_on_error=1:suppressions='"%t.module-supp"' not %run %t-norecover 2>&1 | FileCheck %s
25
26 #include <stdint.h>
27
do_overflow()28 extern "C" void do_overflow() {
29 (void)(uint64_t(10000000000000000000ull) + uint64_t(9000000000000000000ull));
30 // CHECK: runtime error: unsigned integer overflow
31 }
32
main()33 int main() {
34 do_overflow();
35 return 0;
36 }
37