diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-09-22 01:24:33 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-09-22 01:24:33 +0000 |
commit | 04dcb7235f279306376be64a525311c322f90c7e (patch) | |
tree | 0a671a0ec947489358f820e61950d798f7e5cd81 /clang/test/Analysis/fields.c | |
parent | d2718b1fedd724d734c01570e45d694964737879 (diff) | |
download | bcm5719-llvm-04dcb7235f279306376be64a525311c322f90c7e.tar.gz bcm5719-llvm-04dcb7235f279306376be64a525311c322f90c7e.zip |
[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;
llvm-svn: 164441
Diffstat (limited to 'clang/test/Analysis/fields.c')
-rw-r--r-- | clang/test/Analysis/fields.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/test/Analysis/fields.c b/clang/test/Analysis/fields.c index da0847a5607..a10d5a80601 100644 --- a/clang/test/Analysis/fields.c +++ b/clang/test/Analysis/fields.c @@ -26,3 +26,10 @@ void test() { 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. +} |