summaryrefslogtreecommitdiff
path: root/test/Analysis/ptr-arith.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-12-18 20:11:37 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-12-18 20:11:37 +0000
commit461a67fa15370a9ec88f8f8a240bf7c123bb2029 (patch)
tree6942083d7d56bba40ec790a453ca58ad3baf6832 /test/Analysis/ptr-arith.cpp
parent75c3240472ba6ac2669ee72ca67eb72d4e2851fc (diff)
Diffstat (limited to 'test/Analysis/ptr-arith.cpp')
-rw-r--r--test/Analysis/ptr-arith.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/Analysis/ptr-arith.cpp b/test/Analysis/ptr-arith.cpp
index e1860f4268e0..1eec83c643e1 100644
--- a/test/Analysis/ptr-arith.cpp
+++ b/test/Analysis/ptr-arith.cpp
@@ -98,3 +98,22 @@ void checkMultiDimansionalArray() {
int a[5][5];
*(*(a+1)+2) = 2;
}
+
+unsigned ptrSubtractionNoCrash(char *Begin, char *End) {
+ auto N = End - Begin;
+ if (Begin)
+ return 0;
+ return N;
+}
+
+// Bug 34309
+bool ptrAsIntegerSubtractionNoCrash(__UINTPTR_TYPE__ x, char *p) {
+ __UINTPTR_TYPE__ y = (__UINTPTR_TYPE__)p - 1;
+ return y == x;
+}
+
+// Bug 34374
+bool integerAsPtrSubtractionNoCrash(char *p, __UINTPTR_TYPE__ m) {
+ auto n = p - reinterpret_cast<char*>((__UINTPTR_TYPE__)1);
+ return n == m;
+}