summaryrefslogtreecommitdiffstats
path: root/lib/ubsan/lit_tests/Integer/incdec-overflow.cpp
diff options
context:
space:
mode:
authorandrew <andrew@FreeBSD.org>2013-01-18 20:06:45 +0000
committerandrew <andrew@FreeBSD.org>2013-01-18 20:06:45 +0000
commit254a83b703ce3576b1aea35fdd5308aaf1d05f4b (patch)
treeb946f82269be87d83f086167c762c362e734c5bb /lib/ubsan/lit_tests/Integer/incdec-overflow.cpp
parentcfeab007a554034f0b3ab4a677cf9dd2696c12f9 (diff)
downloadFreeBSD-src-254a83b703ce3576b1aea35fdd5308aaf1d05f4b.zip
FreeBSD-src-254a83b703ce3576b1aea35fdd5308aaf1d05f4b.tar.gz
Import compiler-rt r172839.
Diffstat (limited to 'lib/ubsan/lit_tests/Integer/incdec-overflow.cpp')
-rw-r--r--lib/ubsan/lit_tests/Integer/incdec-overflow.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/ubsan/lit_tests/Integer/incdec-overflow.cpp b/lib/ubsan/lit_tests/Integer/incdec-overflow.cpp
new file mode 100644
index 0000000..48b68b6
--- /dev/null
+++ b/lib/ubsan/lit_tests/Integer/incdec-overflow.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang -DOP=n++ -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s
+// RUN: %clang -DOP=++n -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s
+// RUN: %clang -DOP=m-- -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s
+// RUN: %clang -DOP=--m -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s
+
+#include <stdint.h>
+
+int main() {
+ int n = 0x7ffffffd;
+ n++;
+ n++;
+ int m = -n - 1;
+ // CHECK: incdec-overflow.cpp:15:3: runtime error: signed integer overflow: [[MINUS:-?]]214748364
+ // CHECK: + [[MINUS]]1 cannot be represented in type 'int'
+ OP;
+}
OpenPOWER on IntegriCloud