blob: 06090300af3b00abbba992d300c4fbff7b06f1c6 [file] [log] [blame]
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08001// RUN: %clangxx -DOP=n++ -fsanitize=signed-integer-overflow %s -o %t1 && %run %t1 2>&1 | FileCheck %s --check-prefix=PLUS
2// RUN: %clangxx -DOP=++n -fsanitize=signed-integer-overflow %s -o %t2 && %run %t2 2>&1 | FileCheck %s --check-prefix=PLUS
3// RUN: %clangxx -DOP=m-- -fsanitize=signed-integer-overflow %s -o %t3 && %run %t3 2>&1 | FileCheck %s --check-prefix=MINUS
4// RUN: %clangxx -DOP=--m -fsanitize=signed-integer-overflow %s -o %t4 && %run %t4 2>&1 | FileCheck %s --check-prefix=MINUS
Stephen Hines2d1fdb22014-05-28 23:58:16 -07005
6#include <stdint.h>
7
8int main() {
9 int n = 0x7ffffffd;
10 n++;
11 n++;
12 int m = -n - 1;
Stephen Hines2d1fdb22014-05-28 23:58:16 -070013 OP;
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -070014 // PLUS: incdec-overflow.cpp:[[@LINE-1]]:3: runtime error: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
15 // MINUS: incdec-overflow.cpp:[[@LINE-2]]:3: runtime error: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
Stephen Hines2d1fdb22014-05-28 23:58:16 -070016}