2012-09-06 07:41:54 +08:00
|
|
|
// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text -verify %s
|
|
|
|
|
|
|
|
struct S {
|
|
|
|
int *x;
|
|
|
|
int y;
|
|
|
|
};
|
|
|
|
|
|
|
|
S &getSomeReference();
|
|
|
|
void test(S *p) {
|
|
|
|
S &r = *p; //expected-note {{Variable 'r' initialized here}}
|
|
|
|
if (p) return;
|
|
|
|
//expected-note@-1{{Taking false branch}}
|
|
|
|
//expected-note@-2{{Assuming pointer value is null}}
|
2012-09-07 14:51:37 +08:00
|
|
|
//expected-note@-3{{Assuming 'p' is null}}
|
2012-09-06 07:41:54 +08:00
|
|
|
r.y = 5; // expected-warning {{Access to field 'y' results in a dereference of a null pointer (loaded from variable 'r')}}
|
|
|
|
// expected-note@-1{{Access to field 'y' results in a dereference of a null pointer (loaded from variable 'r')}}
|
|
|
|
}
|