blob: 628291eb4b95a08a3d33c6dd965813b3d4376b3b [file] [log] [blame]
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08001// RUN: %clangxx -fsanitize=signed-integer-overflow %s -o %t1 && %run %t1 2>&1 | FileCheck %s --check-prefix=CHECKS
2// RUN: %clangxx -fsanitize=unsigned-integer-overflow %s -o %t2 && %run %t2 2>&1 | FileCheck %s --check-prefix=CHECKU
Stephen Hines2d1fdb22014-05-28 23:58:16 -07003
4int 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}