summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/nullptr.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-09-22 01:24:33 +0000
committerJordan Rose <jordan_rose@apple.com>2012-09-22 01:24:33 +0000
commit04dcb7235f279306376be64a525311c322f90c7e (patch)
tree0a671a0ec947489358f820e61950d798f7e5cd81 /clang/test/Analysis/nullptr.cpp
parentd2718b1fedd724d734c01570e45d694964737879 (diff)
downloadbcm5719-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/nullptr.cpp')
-rw-r--r--clang/test/Analysis/nullptr.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/test/Analysis/nullptr.cpp b/clang/test/Analysis/nullptr.cpp
index 050c3f8dc56..80ef5fbf6d0 100644
--- a/clang/test/Analysis/nullptr.cpp
+++ b/clang/test/Analysis/nullptr.cpp
@@ -23,10 +23,11 @@ void foo3(void) {
};
char *np = nullptr;
// casting a nullptr to anything should be caught eventually
- int *ip = &(((struct foo *)np)->f);
- *ip = 0; // expected-warning{{Dereference of null pointer}}
- // should be error here too, but analysis gets stopped
-// *np = 0;
+ int *ip = &(((struct foo *)np)->f); // expected-warning{{Access to field 'f' results in a dereference of a null pointer (loaded from variable 'np')}}
+
+ // Analysis stops at the first problem case, so we won't actually warn here.
+ *ip = 0;
+ *np = 0;
}
// nullptr is implemented as a zero integer value, so should be able to compare
OpenPOWER on IntegriCloud