Clang Project

clang_source_code/test/Analysis/diagnostics/find_last_store.c
1// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -verify %s
2typedef struct { float b; } c;
3void *a();
4void *d() {
5  return a(); // expected-note{{Returning pointer}}
6}
7
8void no_find_last_store() {
9  c *e = d(); // expected-note{{Calling 'd'}}
10              // expected-note@-1{{Returning from 'd'}}
11              // expected-note@-2{{'e' initialized here}}
12
13  (void)(e || e->b); // expected-note{{Assuming 'e' is null}}
14      // expected-note@-1{{Left side of '||' is false}}
15      // expected-note@-2{{Access to field 'b' results in a dereference of a null pointer (loaded from variable 'e')}}
16      // expected-warning@-3{{Access to field 'b' results in a dereference of a null pointer (loaded from variable 'e')}}
17}
18