xref: /llvm-project/clang/test/CXX/class.derived/class.virtual/p2.cpp (revision 44b21749b9d60e7212bee632dd11e4df1b19dfd6)
1*44b21749SNathan Sidwell // RUN: %clang_cc1 -fsyntax-only -verify -Wno-inaccessible-base %s
24165bd67SDouglas Gregor struct A {
34165bd67SDouglas Gregor   virtual void f() = 0; // expected-note 2{{overridden virtual function}}
44165bd67SDouglas Gregor };
54165bd67SDouglas Gregor 
64165bd67SDouglas Gregor struct Aprime : virtual A {
74165bd67SDouglas Gregor   virtual void f();
84165bd67SDouglas Gregor };
94165bd67SDouglas Gregor 
104165bd67SDouglas Gregor struct B : Aprime {
114165bd67SDouglas Gregor   virtual void f(); // expected-note 3{{final overrider of 'A::f'}}
124165bd67SDouglas Gregor };
134165bd67SDouglas Gregor 
144165bd67SDouglas Gregor struct C : virtual A {
154165bd67SDouglas Gregor   virtual void f(); // expected-note{{final overrider of 'A::f'}}
164165bd67SDouglas Gregor };
174165bd67SDouglas Gregor 
184165bd67SDouglas Gregor struct D : B, C { }; // expected-error{{virtual function 'A::f' has more than one final overrider in 'D'}}
194165bd67SDouglas Gregor 
204165bd67SDouglas Gregor struct B2 : B { };
214165bd67SDouglas Gregor 
224165bd67SDouglas Gregor struct E : B, B2 { }; //expected-error{{virtual function 'A::f' has more than one final overrider in 'E'}}
234165bd67SDouglas Gregor 
244165bd67SDouglas Gregor struct F : B, B2 {
254165bd67SDouglas Gregor   virtual void f(); // okay
264165bd67SDouglas Gregor };
274165bd67SDouglas Gregor 
284165bd67SDouglas Gregor struct G : F { }; // okay
294165bd67SDouglas Gregor 
304165bd67SDouglas Gregor struct H : G, A { }; // okay
314165bd67SDouglas Gregor 
324165bd67SDouglas Gregor namespace MultipleSubobjects {
334165bd67SDouglas Gregor   struct A { virtual void f(); };
344165bd67SDouglas Gregor   struct B : A { virtual void f(); };
354165bd67SDouglas Gregor   struct C : A { virtual void f(); };
364165bd67SDouglas Gregor   struct D : B, C { }; // okay
374165bd67SDouglas Gregor }
38