1a68d90faSPeter Collingbourne // RUN: %clangxx -fsanitize=signed-integer-overflow %s -o %t1 && %run %t1 2>&1 | FileCheck %s --check-prefix=CHECKS
2a68d90faSPeter Collingbourne // RUN: %clangxx -fsanitize=unsigned-integer-overflow %s -o %t2 && %run %t2 2>&1 | FileCheck %s --check-prefix=CHECKU
3*038771a2SMax Moroz // RUN: %clangxx -fsanitize=unsigned-integer-overflow %s -o %t2 && %env_ubsan_opts=silence_unsigned_overflow=1 %run %t2 2>&1 | FileCheck %s --check-prefix=CHECKU-SILENT --allow-empty
4ba869e79SAlexey Samsonov
main()5ba869e79SAlexey Samsonov int main() {
6ba869e79SAlexey Samsonov // CHECKS-NOT: runtime error
7*038771a2SMax Moroz // CHECKU: negate-overflow.cpp:[[@LINE+3]]:3: runtime error: negation of 2147483648 cannot be represented in type 'unsigned int'
8ba869e79SAlexey Samsonov // CHECKU-NOT: cast to an unsigned
9*038771a2SMax Moroz // CHECKU-SILENT-NOT: runtime error
10ba869e79SAlexey Samsonov -unsigned(-0x7fffffff - 1); // ok
110eec1f0bSHans Wennborg // CHECKS: negate-overflow.cpp:[[@LINE+2]]:3: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
12ba869e79SAlexey Samsonov // CHECKU-NOT: runtime error
130eec1f0bSHans Wennborg -(-0x7fffffff - 1);
140eec1f0bSHans Wennborg
150eec1f0bSHans Wennborg return 0;
16ba869e79SAlexey Samsonov }
17