diff options
Diffstat (limited to 'test/Analysis/diagnostics/no-store-func-path-notes.c')
-rw-r--r-- | test/Analysis/diagnostics/no-store-func-path-notes.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/Analysis/diagnostics/no-store-func-path-notes.c b/test/Analysis/diagnostics/no-store-func-path-notes.c index a444ab60261bf..2050f6217ca16 100644 --- a/test/Analysis/diagnostics/no-store-func-path-notes.c +++ b/test/Analysis/diagnostics/no-store-func-path-notes.c @@ -224,3 +224,23 @@ int useindirectingstruct() { return s.x; // expected-warning{{Undefined or garbage value returned to caller}} // expected-note@-1{{Undefined or garbage value returned to caller}} } + +typedef struct { + int *x; +} D; + +void initializeMaybeInStruct(D* pD) { + if (coin()) // expected-note{{Assuming the condition is false}} + // expected-note@-1{{Taking false branch}} + *pD->x = 120; +} // expected-note{{Returning without writing to 'pD->x'}} + +int useInitializeMaybeInStruct() { + int z; // expected-note{{'z' declared without an initial value}} + D d; + d.x = &z; + initializeMaybeInStruct(&d); // expected-note{{Calling 'initializeMaybeInStruct'}} + // expected-note@-1{{Returning from 'initializeMaybeInStruct'}} + return z; // expected-warning{{Undefined or garbage value returned to caller}} + // expected-note@-1{{Undefined or garbage value returned to caller}} +} |