static analyzer: Handle casts from arrays to integers. This fixes PR 3297.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62130 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Analysis/null-deref-ps.c b/test/Analysis/null-deref-ps.c
index 028eaab..e0dddc8 100644
--- a/test/Analysis/null-deref-ps.c
+++ b/test/Analysis/null-deref-ps.c
@@ -52,6 +52,27 @@
return *q; // expected-warning{{Dereference of null pointer.}}
}
+int f4_b() {
+ short array[2];
+ uintptr_t x = array; // expected-warning{{incompatible pointer to integer conversion initializing}}
+ short *p = x; // expected-warning{{incompatible integer to pointer conversion initializing}}
+
+ // The following branch should be infeasible.
+ if (!(p = &array[0])) {
+ p = 0;
+ *p = 1; // no-warning
+ }
+
+ if (p) {
+ *p = 5; // no-warning
+ p = 0;
+ }
+ else return;
+
+ *p += 10; // expected-warning{{Dereference of null pointer}}
+}
+
+
int f5() {
char *s = "hello world";