1 // RUN: %clang -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECKS 2 // RUN: %clang -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECKU 3 4 int main() { 5 // CHECKS-NOT: runtime error 6 // CHECKU: negate-overflow.cpp:[[@LINE+2]]:3: runtime error: negation of 2147483648 cannot be represented in type 'unsigned int' 7 // CHECKU-NOT: cast to an unsigned 8 -unsigned(-0x7fffffff - 1); // ok 9 // 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 // CHECKU-NOT: runtime error 11 return -(-0x7fffffff - 1); 12 } 13