diff options
Diffstat (limited to 'clang/test/Analysis/diagnostics/no-store-func-path-notes.cpp')
-rw-r--r-- | clang/test/Analysis/diagnostics/no-store-func-path-notes.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/test/Analysis/diagnostics/no-store-func-path-notes.cpp b/clang/test/Analysis/diagnostics/no-store-func-path-notes.cpp index 3d7003ead2e..b869f81b6dd 100644 --- a/clang/test/Analysis/diagnostics/no-store-func-path-notes.cpp +++ b/clang/test/Analysis/diagnostics/no-store-func-path-notes.cpp @@ -333,3 +333,27 @@ int useMaybeInitializeIndirectlyWithPointer() { return z; // expected-warning{{Undefined or garbage value returned to caller}} // expected-note@-1{{Undefined or garbage value returned to caller}} } + +//////// + +struct HasFieldA { + int x; +}; + +struct HasFieldB { + int x; +}; + +void maybeInitializeHasField(HasFieldA *b) { + if (coin()) // expected-note{{Assuming the condition is false}} + // expected-note@-1{{Taking false branch}} + ((HasFieldB*)b)->x = 120; +} + +int forceElementRegionApperence() { + HasFieldA a; + maybeInitializeHasField(&a); // expected-note{{Calling 'maybeInitializeHasField'}} + // expected-note@-1{{Returning from 'maybeInitializeHasField'}} + return ((HasFieldB*)&a)->x; // expected-warning{{Undefined or garbage value returned to caller}} + // expected-note@-1{{Undefined or garbage value returned to caller}} +} |