Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic5.C @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 // PR c++/88337 - Implement P1327R1: Allow dynamic_cast/typeid in constexpr. | |
2 // { dg-do compile { target c++2a } } | |
3 | |
4 // Multiple levels. | |
5 | |
6 struct A { virtual void a(); }; | |
7 struct B : A { virtual void b(); }; | |
8 struct C : B { virtual void c(); }; | |
9 struct D : C { virtual void d(); }; | |
10 struct E : D { virtual void e(); }; | |
11 struct F : E { virtual void f(); }; | |
12 | |
13 constexpr F f; | |
14 | |
15 // F->C->A->B == F->C->B | |
16 static_assert (&dynamic_cast<B&>((A&)(C&)f) == &(B&)(C&)f); | |
17 // F->A->E == F->E | |
18 static_assert (&dynamic_cast<E&>((A&)f) == &(E&)f); | |
19 // F->E->D->C->B->A->C == F->C | |
20 static_assert (&dynamic_cast<C&>((A&)(B&)(C&)(D&)(E&)f) == &(C&)f); | |
21 // F->B->F == F | |
22 static_assert (&dynamic_cast<F&>((B&)f) == &f); |