blob: ce3a5469c120110f0060aabdeb1affb4c79e7b5f [file] [log] [blame]
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08001// RUN: %clangxx -fsanitize=integer -g0 %s -o %t
2
3// Fails without any suppression.
4// RUN: %env_ubsan_opts=halt_on_error=1 not %run %t 2>&1 | FileCheck %s
5
6// RUN: echo "signed-integer-overflow:%t" > %t.wrong-supp
7// RUN: %env_ubsan_opts=halt_on_error=1:suppressions="%t.wrong-supp" not %run %t 2>&1 | FileCheck %s
8
9// RUN: echo "unsigned-integer-overflow:do_overflow" > %t.func-supp
10// RUN: %env_ubsan_opts=halt_on_error=1:suppressions="%t.func-supp" %run %t
11// RUN: echo "unsigned-integer-overflow:%t" > %t.module-supp
12// RUN: %env_ubsan_opts=halt_on_error=1:suppressions="%t.module-supp" %run %t
13
14// Note: file-level suppressions should work even without debug info.
15// RUN: echo "unsigned-integer-overflow:%s" > %t.file-supp
16// RUN: %env_ubsan_opts=halt_on_error=1:suppressions="%t.file-supp" %run %t
17
18// Suppressions don't work for unrecoverable kinds.
19// RUN: %clangxx -fsanitize=integer -fno-sanitize-recover=integer %s -o %t-norecover
20// RUN: %env_ubsan_opts=halt_on_error=1:suppressions="%t.module-supp" not %run %t-norecover 2>&1 | FileCheck %s
21
22#include <stdint.h>
23
24extern "C" void do_overflow() {
25 (void)(uint64_t(10000000000000000000ull) + uint64_t(9000000000000000000ull));
26 // CHECK: runtime error: unsigned integer overflow
27}
28
29int main() {
30 do_overflow();
31 return 0;
32}
33