2019-04-20 07:33:50 +08:00
|
|
|
// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.UninitializedObject -std=c++11 -fblocks -verify %s
|
2018-08-10 03:03:12 +08:00
|
|
|
|
|
|
|
typedef void (^myBlock) ();
|
|
|
|
|
|
|
|
struct StructWithBlock {
|
|
|
|
int a;
|
2018-09-14 16:58:21 +08:00
|
|
|
myBlock z; // expected-note{{uninitialized field 'this->z'}}
|
2018-08-10 03:03:12 +08:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2018-08-14 07:32:15 +08:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|