gcc/testsuite/g++.dg/cpp2a/constexpr-virtual20.C
raw| 1 | // Test for constexpr call through vbase thunk. |
| 2 | // { dg-do compile { target c++20 } } |
| 3 | |
| 4 | class Rep { |
| 5 | public: |
| 6 | constexpr virtual int foo() { return 1; } |
| 7 | }; |
| 8 | |
| 9 | class VBase { |
| 10 | public: |
| 11 | constexpr virtual int foo() { return 2; } |
| 12 | }; |
| 13 | |
| 14 | class Main : public Rep, virtual public VBase { |
| 15 | public: |
| 16 | constexpr virtual int foo() { return 5; } |
| 17 | }; |
| 18 | |
| 19 | int main() { |
| 20 | Main m; |
| 21 | static_assert(static_cast<VBase*>(&m)->foo() == 5); // { dg-error "" } |
| 22 | } |