1*7c3d14c8STreehugger Robot // RUN: %clangxx -fsanitize=signed-integer-overflow %s -o %t1 && %run %t1 2>&1 | FileCheck %s --check-prefix=CHECKS
2*7c3d14c8STreehugger Robot // RUN: %clangxx -fsanitize=unsigned-integer-overflow %s -o %t2 && %run %t2 2>&1 | FileCheck %s --check-prefix=CHECKU
3*7c3d14c8STreehugger Robot
main()4*7c3d14c8STreehugger Robot int main() {
5*7c3d14c8STreehugger Robot // CHECKS-NOT: runtime error
6*7c3d14c8STreehugger Robot // CHECKU: negate-overflow.cpp:[[@LINE+2]]:3: runtime error: negation of 2147483648 cannot be represented in type 'unsigned int'
7*7c3d14c8STreehugger Robot // CHECKU-NOT: cast to an unsigned
8*7c3d14c8STreehugger Robot -unsigned(-0x7fffffff - 1); // ok
9*7c3d14c8STreehugger Robot // CHECKS: negate-overflow.cpp:[[@LINE+2]]:10: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
10*7c3d14c8STreehugger Robot // CHECKU-NOT: runtime error
11*7c3d14c8STreehugger Robot return -(-0x7fffffff - 1);
12*7c3d14c8STreehugger Robot }
13