aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/casts.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/casts.c')
-rw-r--r--test/Analysis/casts.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/Analysis/casts.c b/test/Analysis/casts.c
index 24bba8a30a00..eccb67812a02 100644
--- a/test/Analysis/casts.c
+++ b/test/Analysis/casts.c
@@ -149,3 +149,29 @@ void multiDimensionalArrayPointerCasts() {
clang_analyzer_eval(*((char *)y1) == *((char *) y3)); // expected-warning{{TRUE}}
}
+
+void *getVoidPtr();
+
+void testCastVoidPtrToIntPtrThroughIntTypedAssignment() {
+ int *x;
+ (*((int *)(&x))) = (int)getVoidPtr();
+ *x = 1; // no-crash
+}
+
+void testCastUIntPtrToIntPtrThroughIntTypedAssignment() {
+ unsigned u;
+ int *x;
+ (*((int *)(&x))) = (int)&u;
+ *x = 1;
+ clang_analyzer_eval(u == 1); // expected-warning{{TRUE}}
+}
+
+void testCastVoidPtrToIntPtrThroughUIntTypedAssignment() {
+ int *x;
+ (*((int *)(&x))) = (int)(unsigned *)getVoidPtr();
+ *x = 1; // no-crash
+}
+
+void testLocNonLocSymbolAssume(int a, int *b) {
+ if ((int)b < a) {} // no-crash
+}