blob: fb493d7c93ae235fe41e3ed2a44a94b7ee5b5bbd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
// 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 'p' is null}}
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')}}
}
|