blob: f5a4d7ae8564b535bb96fbcfef201722d3969665 [file] [log] [blame]
Kristof Umann85e0ff72019-04-19 23:33:50 +00001// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.UninitializedObject -std=c++11 -fblocks -verify %s
George Karpenkovcf40ba82018-08-09 19:03:12 +00002
3typedef void (^myBlock) ();
4
5struct StructWithBlock {
6 int a;
Kristof Umannf0dd1012018-09-14 08:58:21 +00007 myBlock z; // expected-note{{uninitialized field 'this->z'}}
George Karpenkovcf40ba82018-08-09 19:03:12 +00008
9 StructWithBlock() : a(0), z(^{}) {}
10
11 // Miss initialization of field `z`.
12 StructWithBlock(int pA) : a(pA) {} // expected-warning{{1 uninitialized field at the end of the constructor call}}
13
14};
15
16void warnOnUninitializedBlock() {
17 StructWithBlock a(10);
18}
19
20void noWarningWhenInitialized() {
21 StructWithBlock a;
22}
George Karpenkove3b1d962018-08-13 23:32:15 +000023
24struct StructWithId {
25 int a;
26 id z; // expected-note{{uninitialized pointer 'this->z'}}
27 StructWithId() : a(0) {} // expected-warning{{1 uninitialized field at the end of the constructor call}}
28};
29
30void warnOnUninitializedId() {
31 StructWithId s;
32}