• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text -verify %s
2 
3 struct S {
4   int *x;
5   int y;
6 };
7 
8 S &getSomeReference();
test(S * p)9 void test(S *p) {
10   S &r = *p;   //expected-note {{Variable 'r' initialized here}}
11   if (p) return;
12                //expected-note@-1{{Taking false branch}}
13                //expected-note@-2{{Assuming pointer value is null}}
14                //expected-note@-3{{Assuming 'p' is null}}
15   r.y = 5; // expected-warning {{Access to field 'y' results in a dereference of a null pointer (loaded from variable 'r')}}
16            // expected-note@-1{{Access to field 'y' results in a dereference of a null pointer (loaded from variable 'r')}}
17 }
18