-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathtest.cpp
More file actions
73 lines (57 loc) · 1.88 KB
/
test.cpp
File metadata and controls
73 lines (57 loc) · 1.88 KB
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
68
69
70
71
72
73
class Base {};
class Derived : public Base {
public:
Derived() {} // NON_COMPLIANT - does not call Base()
Derived(int i) : Base() {} // COMPLIANT
Derived(int i, int j); // IGNORED - not defined, so we don't know
};
class Derived1 : public Base {
public:
Derived1() = default; // COMPLIANT - `default` does not have explicit
// initializers
};
class VirtualBase {};
class Derived2 : virtual public VirtualBase {};
class Derived3 : virtual public VirtualBase {};
class Derived4 : public Derived2, public Derived3 {
public:
Derived4() {} // NON_COMPLIANT - does not call Derived2(), Derived3() or
// VirtualBase()
Derived4(int i) // NON_COMPLIANT - does not call VirtualBase()
: Derived2(), Derived3() {}
Derived4(int i, int j) // COMPLIANT - calls VirtualBase()
: Derived2(), Derived3(), VirtualBase() {}
};
class NonTrivialBase {
public:
NonTrivialBase() = default;
NonTrivialBase(int i){};
NonTrivialBase(int i, int j){};
};
class Derived5 : public NonTrivialBase {
public:
Derived5() {} // NON_COMPLIANT - does not call NonTrivialBase()
Derived5(int i) : NonTrivialBase(i) {} // COMPLIANT
Derived5(int i, int j) : NonTrivialBase(i, j) {} // COMPLIANT
};
class MultipleInheritenceBase {};
class Child1 : public MultipleInheritenceBase {};
class Child2 : public MultipleInheritenceBase {};
class GrandChild : public Child1, public Child2 {
// no need to initialize MultipleInheritenceBase
GrandChild() : Child1(), Child2() {} // COMPLIANT
};
class Base2 {};
class Derived6 : public Base2 {
public:
Derived6() : b() {} // NON_COMPLIANT
private:
Base2 b;
};
class Base3 {};
class Derived7 final : public Base3 {
public:
Derived7() = delete; // COMPLIANT
Derived7(const Derived7 &) = delete; // COMPLIANT
Derived7(Derived7 &&) = delete; // COMPLIANT
};