1 | // RUN: %check_clang_tidy %s fuchsia-virtual-inheritance %t |
2 | |
3 | class A { |
4 | public: |
5 | A(int value) : val(value) {} |
6 | |
7 | int do_A() { return val; } |
8 | |
9 | private: |
10 | int val; |
11 | }; |
12 | |
13 | class B : public virtual A { |
14 | // CHECK-MESSAGES: [[@LINE-1]]:1: warning: direct virtual inheritance is disallowed [fuchsia-virtual-inheritance] |
15 | // CHECK-NEXT: class B : public virtual A { |
16 | public: |
17 | B() : A(0) {} |
18 | int do_B() { return 1 + do_A(); } |
19 | }; |
20 | |
21 | class C : public virtual A { |
22 | // CHECK-MESSAGES: [[@LINE-1]]:1: warning: direct virtual inheritance is disallowed [fuchsia-virtual-inheritance] |
23 | // CHECK-NEXT: class C : public virtual A { |
24 | public: |
25 | C() : A(0) {} |
26 | int do_C() { return 2 + do_A(); } |
27 | }; |
28 | |
29 | class D : public B, public C { |
30 | public: |
31 | D(int value) : A(value), B(), C() {} |
32 | |
33 | int do_D() { return do_A() + do_B() + do_C(); } |
34 | }; |
35 | |
36 | int main() { |
37 | A *a = new A(0); |
38 | B *b = new B(); |
39 | C *c = new C(); |
40 | D *d = new D(0); |
41 | return 0; |
42 | } |
43 | |