summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/casts.c
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/Analysis/casts.c')
-rw-r--r--clang/test/Analysis/casts.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/test/Analysis/casts.c b/clang/test/Analysis/casts.c
index 24bba8a30a0..548b4223b6a 100644
--- a/clang/test/Analysis/casts.c
+++ b/clang/test/Analysis/casts.c
@@ -149,3 +149,25 @@ 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
+}
OpenPOWER on IntegriCloud