This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ensure that we pick the right final overrider during construction.
structA {
virtualconstexprcharf() const { return'A'; }
char a = f();
};
structNoOverrideA : A {};
structB : NonZeroOffset, NoOverrideA {
virtualconstexprcharf() const { return'B'; }
char b = f();
};
structNoOverrideB : B {};
structC : NonZeroOffset, A {
virtualconstexprcharf() const { return'C'; }
A *pba;
char c = ((A*)this)->f();
char ba = pba->f();
constexprC(A *pba) : pba(pba) {}
};
structD : NonZeroOffset, NoOverrideB, C { // expected-warning {{inaccessible}}
virtualconstexprcharf() const { return'D'; }
char d = f();
constexprD() : C((B*)this) {}
};
constexpr D d;
static_assert(((B&)d).a == 'A');
static_assert(((C&)d).a == 'A');
static_assert(d.b == 'B');
static_assert(d.c == 'C');
// During the construction of C, the dynamic type of B's A is B.
static_assert(d.ba == 'B');
static_assert(d.d == 'D');
static_assert(d.f() == 'D');
constexprconst A &a = (B&)d;
constexprconst B &b = d;
static_assert(a.f() == 'D');
static_assert(b.f() == 'D');
// FIXME: It is unclear whether this should be permitted.
D d_not_constexpr;
static_assert(d_not_constexpr.f() == 'D'); // expected-error {{constant expression}} expected-note {{virtual function called on object 'd_not_constexpr' whose dynamic type is not constant}}
// Check that we apply a proper adjustment for a covariant return type.
structCovariant1 {
D d;
virtualconst A *f() const;
};
template<typename T>
structCovariant2 : Covariant1 {
virtualconst T *f() const;
};
template<typename T>
structCovariant3 : Covariant2<T> {
constexprvirtualconst D *f() const { return &this->d; }
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters