blob: 904250a76c793a342fdaaced4e34d1f28471b686 [file] [log] [blame]
Peter Collingbourne49d29ed2013-10-20 21:29:32 +00001// 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 Smith6ebe4512012-10-09 19:34:32 +00005
6#include <stdint.h>
7
8int main() {
9 int n = 0x7ffffffd;
10 n++;
11 n++;
12 int m = -n - 1;
Will Dietz7cbd7e52012-12-02 18:43:33 +000013 // CHECK: incdec-overflow.cpp:15:3: runtime error: signed integer overflow: [[MINUS:-?]]214748364
Richard Smith6ebe4512012-10-09 19:34:32 +000014 // CHECK: + [[MINUS]]1 cannot be represented in type 'int'
15 OP;
16}