Xamarin Public Jenkins (auto-signing) 468663ddbb Imported Upstream version 6.10.0.49
Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
2020-01-16 16:38:04 +00:00

43 lines
909 B
C++

// RUN: %check_clang_tidy %s fuchsia-virtual-inheritance %t
class A {
public:
A(int value) : val(value) {}
int do_A() { return val; }
private:
int val;
};
class B : public virtual A {
// CHECK-MESSAGES: [[@LINE-1]]:1: warning: direct virtual inheritance is disallowed [fuchsia-virtual-inheritance]
// CHECK-NEXT: class B : public virtual A {
public:
B() : A(0) {}
int do_B() { return 1 + do_A(); }
};
class C : public virtual A {
// CHECK-MESSAGES: [[@LINE-1]]:1: warning: direct virtual inheritance is disallowed [fuchsia-virtual-inheritance]
// CHECK-NEXT: class C : public virtual A {
public:
C() : A(0) {}
int do_C() { return 2 + do_A(); }
};
class D : public B, public C {
public:
D(int value) : A(value), B(), C() {}
int do_D() { return do_A() + do_B() + do_C(); }
};
int main() {
A *a = new A(0);
B *b = new B();
C *c = new C();
D *d = new D(0);
return 0;
}