diff options
Diffstat (limited to 'test/Analysis/ptr-arith.cpp')
-rw-r--r-- | test/Analysis/ptr-arith.cpp | 19 |
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; +} |