diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:04:05 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:04:05 +0000 | 
| commit | 676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63 (patch) | |
| tree | 02a1ac369cb734d0abfa5000dd86e5b7797e6a74 /test/Analysis/objcpp-uninitialized-object.mm | |
| parent | c7e70c433efc6953dc3888b9fbf9f3512d7da2b0 (diff) | |
Diffstat (limited to 'test/Analysis/objcpp-uninitialized-object.mm')
| -rw-r--r-- | test/Analysis/objcpp-uninitialized-object.mm | 32 | 
1 files changed, 32 insertions, 0 deletions
| diff --git a/test/Analysis/objcpp-uninitialized-object.mm b/test/Analysis/objcpp-uninitialized-object.mm new file mode 100644 index 000000000000..8ea4b56998fc --- /dev/null +++ b/test/Analysis/objcpp-uninitialized-object.mm @@ -0,0 +1,32 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -std=c++11 -fblocks -verify %s + +typedef void (^myBlock) (); + +struct StructWithBlock { +  int a; +  myBlock z; // expected-note{{uninitialized field 'this->z'}} + +  StructWithBlock() : a(0), z(^{}) {} + +  // Miss initialization of field `z`. +  StructWithBlock(int pA) : a(pA) {} // expected-warning{{1 uninitialized field at the end of the constructor call}} + +}; + +void warnOnUninitializedBlock() { +  StructWithBlock a(10); +} + +void noWarningWhenInitialized() { +  StructWithBlock a; +} + +struct StructWithId { +  int a; +  id z; // expected-note{{uninitialized pointer 'this->z'}} +  StructWithId() : a(0) {} // expected-warning{{1 uninitialized field at the end of the constructor call}} +}; + +void warnOnUninitializedId() { +  StructWithId s; +} | 
