1// RUN: %check_clang_tidy %s fuchsia-virtual-inheritance %t
2
3class A {
4public:
5 A(int value) : val(value) {}
6
7 int do_A() { return val; }
8
9private:
10 int val;
11};
12
13class 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 {
16public:
17 B() : A(0) {}
18 int do_B() { return 1 + do_A(); }
19};
20
21class 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 {
24public:
25 C() : A(0) {}
26 int do_C() { return 2 + do_A(); }
27};
28
29class D : public B, public C {
30public:
31 D(int value) : A(value), B(), C() {}
32
33 int do_D() { return do_A() + do_B() + do_C(); }
34};
35
36int 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

source code of clang-tools-extra/test/clang-tidy/checkers/fuchsia/virtual-inheritance.cpp