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