Peter Collingbourne | 49d29ed | 2013-10-20 21:29:32 +0000 | [diff] [blame^] | 1 | // RUN: %clangxx -DOP=n++ -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s |
| 2 | // RUN: %clangxx -DOP=++n -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s |
| 3 | // RUN: %clangxx -DOP=m-- -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s |
| 4 | // RUN: %clangxx -DOP=--m -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s |
Richard Smith | 6ebe451 | 2012-10-09 19:34:32 +0000 | [diff] [blame] | 5 | |
| 6 | #include <stdint.h> |
| 7 | |
| 8 | int main() { |
| 9 | int n = 0x7ffffffd; |
| 10 | n++; |
| 11 | n++; |
| 12 | int m = -n - 1; |
Will Dietz | 7cbd7e5 | 2012-12-02 18:43:33 +0000 | [diff] [blame] | 13 | // CHECK: incdec-overflow.cpp:15:3: runtime error: signed integer overflow: [[MINUS:-?]]214748364 |
Richard Smith | 6ebe451 | 2012-10-09 19:34:32 +0000 | [diff] [blame] | 14 | // CHECK: + [[MINUS]]1 cannot be represented in type 'int' |
| 15 | OP; |
| 16 | } |