1*a68d90faSPeter Collingbourne // RUN: %clangxx -DOP=n++ -fsanitize=signed-integer-overflow %s -o %t1 && %run %t1 2>&1 | FileCheck %s --check-prefix=PLUS
2*a68d90faSPeter Collingbourne // RUN: %clangxx -DOP=++n -fsanitize=signed-integer-overflow %s -o %t2 && %run %t2 2>&1 | FileCheck %s --check-prefix=PLUS
3*a68d90faSPeter Collingbourne // RUN: %clangxx -DOP=m-- -fsanitize=signed-integer-overflow %s -o %t3 && %run %t3 2>&1 | FileCheck %s --check-prefix=MINUS
4*a68d90faSPeter Collingbourne // RUN: %clangxx -DOP=--m -fsanitize=signed-integer-overflow %s -o %t4 && %run %t4 2>&1 | FileCheck %s --check-prefix=MINUS
5ba869e79SAlexey Samsonov
6ba869e79SAlexey Samsonov #include <stdint.h>
7ba869e79SAlexey Samsonov
main()8ba869e79SAlexey Samsonov int main() {
9ba869e79SAlexey Samsonov int n = 0x7ffffffd;
10ba869e79SAlexey Samsonov n++;
11ba869e79SAlexey Samsonov n++;
12ba869e79SAlexey Samsonov int m = -n - 1;
13ba869e79SAlexey Samsonov OP;
148c80e742SAlexey Samsonov // PLUS: incdec-overflow.cpp:[[@LINE-1]]:3: runtime error: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
158c80e742SAlexey Samsonov // MINUS: incdec-overflow.cpp:[[@LINE-2]]:3: runtime error: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
16ba869e79SAlexey Samsonov }
17