virtualintf();// expected-note{{overridden virtual function is here}}
};
classB:A{
virtualvoidf();// expected-error{{virtual function 'f' has a different return type ('void') than the function it overrides (which has return type 'int')}}
virtualb*f();// expected-error{{return type of virtual function 'f' is not covariant with the return type of the function it overrides ('T2::b *' is not derived from 'T2::a *')}}
virtuala*g();// expected-error{{return type of virtual function 'g' is not covariant with the return type of the function it overrides ('T5::a *' has different qualifiers than 'T5::a *const')}}
virtualconsta*g();// expected-error{{return type of virtual function 'g' is not covariant with the return type of the function it overrides (class type 'const T6::a *' is more qualified than class type 'T6::a *'}}
b*f();// expected-error {{return type of virtual function 'f' is not covariant with the return type of the function it overrides ('T8::b' is incomplete)}}
// Defer checking for covariance if either return type is dependent.
namespacetype_dependent_covariance{
structB{};
template<intN>structTD:publicB{};
template<>structTD<1>{};
template<intN>structTB{};
structD:publicTB<0>{};
template<intN>structX{
virtualB*f1();// expected-note{{overridden virtual function is here}}
virtualTB<N>*f2();// expected-note{{overridden virtual function is here}}
};
template<intN,intM>structX1:X<N>{
virtualTD<M>*f1();// expected-error{{return type of virtual function 'f1' is not covariant with the return type of the function it overrides ('TD<1> *'}}
virtualD*f2();// expected-error{{return type of virtual function 'f2' is not covariant with the return type of the function it overrides ('type_dependent_covariance::D *' is not derived from 'TB<1> *')}}
virtualB&&f();// expected-error {{virtual function 'f' has a different return type ('T11::B &&') than the function it overrides (which has return type 'T11::A &')}}
virtualB&f();// expected-error {{virtual function 'f' has a different return type ('T12::B &') than the function it overrides (which has return type 'T12::A &&')}}