From 68b3014cd3a1018a95ea5dec579fb7db067f35ba Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 9 Oct 2012 19:34:32 +0000 Subject: Add a runtime diagnostics library for Clang's -fcatch-undefined-behavior. llvm-svn: 165533 --- .../lib/ubsan/lit_tests/Integer/incdec-overflow.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 compiler-rt/lib/ubsan/lit_tests/Integer/incdec-overflow.cpp (limited to 'compiler-rt/lib/ubsan/lit_tests/Integer/incdec-overflow.cpp') diff --git a/compiler-rt/lib/ubsan/lit_tests/Integer/incdec-overflow.cpp b/compiler-rt/lib/ubsan/lit_tests/Integer/incdec-overflow.cpp new file mode 100644 index 00000000000..8c8800b5b71 --- /dev/null +++ b/compiler-rt/lib/ubsan/lit_tests/Integer/incdec-overflow.cpp @@ -0,0 +1,16 @@ +// RUN: %clang -DOP=n++ -fcatch-undefined-behavior %s -o %t && %t 2>&1 | FileCheck %s +// RUN: %clang -DOP=++n -fcatch-undefined-behavior %s -o %t && %t 2>&1 | FileCheck %s +// RUN: %clang -DOP=m-- -fcatch-undefined-behavior %s -o %t && %t 2>&1 | FileCheck %s +// RUN: %clang -DOP=--m -fcatch-undefined-behavior %s -o %t && %t 2>&1 | FileCheck %s + +#include + +int main() { + int n = 0x7ffffffd; + n++; + n++; + int m = -n - 1; + // CHECK: incdec-overflow.cpp:15:3: fatal error: signed integer overflow: [[MINUS:-?]]214748364 + // CHECK: + [[MINUS]]1 cannot be represented in type 'int' + OP; +} -- cgit v1.2.3