1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t -- -- -std=c++98
struct PositiveFieldBeforeConstructor {
int F;
PositiveFieldBeforeConstructor() /* some comment */ {}
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F
// CHECK-FIXES: PositiveFieldBeforeConstructor() : F() /* some comment */ {}
};
struct PositiveFieldAfterConstructor {
PositiveFieldAfterConstructor() {}
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F, G, H
// CHECK-FIXES: PositiveFieldAfterConstructor() : F(), G(), H() {}
int F;
bool G /* with comment */;
int *H;
PositiveFieldBeforeConstructor IgnoredField;
};
struct PositiveSeparateDefinition {
PositiveSeparateDefinition();
int F;
};
PositiveSeparateDefinition::PositiveSeparateDefinition() {}
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these built-in/pointer fields: F
// CHECK-FIXES: PositiveSeparateDefinition::PositiveSeparateDefinition() : F() {}
struct PositiveMixedFieldOrder {
PositiveMixedFieldOrder() : /* some comment */ J(0), L(0), M(0) {}
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: I, K, N
// CHECK-FIXES: PositiveMixedFieldOrder() : I(), /* some comment */ J(0), K(), L(0), M(0), N() {}
int I;
int J;
int K;
int L;
int M;
int N;
};
struct PositiveAfterBaseInitializer : public PositiveMixedFieldOrder {
PositiveAfterBaseInitializer() : PositiveMixedFieldOrder() {}
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F
// CHECK-FIXES: PositiveAfterBaseInitializer() : PositiveMixedFieldOrder(), F() {}
int F;
};
struct NegativeFieldInitialized {
int F;
NegativeFieldInitialized() : F() {}
};
struct NegativeFieldInitializedInDefinition {
int F;
NegativeFieldInitializedInDefinition();
};
NegativeFieldInitializedInDefinition::NegativeFieldInitializedInDefinition() : F() {}
struct NegativeInitializedInBody {
NegativeInitializedInBody() { I = 0; }
int I;
};
|