[analyzer] Check that a member expr is valid even when the result is an lvalue.
We want to catch cases like this early, so that we can produce better
diagnostics and path notes:
Point *p = 0;
int *px = &p->x; // should warn here
*px = 1;
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164441 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Analysis/fields.c b/test/Analysis/fields.c
index da0847a..a10d5a8 100644
--- a/test/Analysis/fields.c
+++ b/test/Analysis/fields.c
@@ -26,3 +26,10 @@
Point p;
(void)(p = getit()).x;
}
+
+
+void testNullAddress() {
+ Point *p = 0;
+ int *px = &p->x; // expected-warning{{Access to field 'x' results in a dereference of a null pointer (loaded from variable 'p')}}
+ *px = 1; // No warning because analysis stops at the previous line.
+}