1 | // RUN: %clangxx -fsanitize=signed-integer-overflow -w %s -O3 -o %t |
2 | // RUN: %run %t 2>&1 | FileCheck %s --check-prefix=RECOVER |
3 | |
4 | // RUN: %clangxx -fsanitize=signed-integer-overflow -fno-sanitize-recover=signed-integer-overflow -w %s -O3 -o %t.abort |
5 | // RUN: not %run %t.abort 2>&1 | FileCheck %s --check-prefix=ABORT |
6 | |
7 | #include <limits.h> |
8 | #include <stdlib.h> |
9 | |
10 | int main() { |
11 | // ABORT: abs.cpp:[[#@LINE+3]]:17: runtime error: negation of -[[#]] cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself |
12 | // RECOVER: abs.cpp:[[#@LINE+2]]:17: runtime error: negation of -[[#]] cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself |
13 | // RECOVER: abs.cpp:[[#@LINE+2]]:7: runtime error: negation of -[[#]] cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself |
14 | __builtin_abs(INT_MIN); |
15 | abs(INT_MIN); |
16 | |
17 | // RECOVER: abs.cpp:[[#@LINE+2]]:18: runtime error: negation of -[[#]] cannot be represented in type 'long'; cast to an unsigned type to negate this value to itself |
18 | // RECOVER: abs.cpp:[[#@LINE+2]]:8: runtime error: negation of -[[#]] cannot be represented in type 'long'; cast to an unsigned type to negate this value to itself |
19 | __builtin_labs(LONG_MIN); |
20 | labs(LONG_MIN); |
21 | |
22 | // RECOVER: abs.cpp:[[#@LINE+2]]:19: runtime error: negation of -[[#]] cannot be represented in type 'long long'; cast to an unsigned type to negate this value to itself |
23 | // RECOVER: abs.cpp:[[#@LINE+2]]:9: runtime error: negation of -[[#]] cannot be represented in type 'long long'; cast to an unsigned type to negate this value to itself |
24 | __builtin_llabs(LLONG_MIN); |
25 | llabs(LLONG_MIN); |
26 | |
27 | return 0; |
28 | } |
29 | |