blob: a14bd6a776f515e9913254c36dc647adfabfbba1 [file] [log] [blame]
Peter Collingbourne49d29ed2013-10-20 21:29:32 +00001// RUN: %clangxx -DOP=n++ -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck --check-prefix=CHECK-INC %s
2// RUN: %clangxx -DOP=++n -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck --check-prefix=CHECK-INC %s
3// RUN: %clangxx -DOP=m-- -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck --check-prefix=CHECK-DEC %s
4// RUN: %clangxx -DOP=--m -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck --check-prefix=CHECK-DEC %s
Will Dietz80af6052012-11-27 15:01:43 +00005
6#include <stdint.h>
7
8int main() {
9 unsigned n = 0xfffffffd;
10 n++;
11 n++;
12 unsigned m = 0;
Will Dietz7cbd7e52012-12-02 18:43:33 +000013 // CHECK-INC: uincdec-overflow.cpp:15:3: runtime error: unsigned integer overflow: 4294967295 + 1 cannot be represented in type 'unsigned int'
14 // CHECK-DEC: uincdec-overflow.cpp:15:3: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned int'
Will Dietz80af6052012-11-27 15:01:43 +000015 OP;
16}