Debian Codegraph @

gcc/testsuite/g++.dg/expr/static_cast8.C

raw
1 // PR c++/52321
2 struct A1; // { dg-message "note: class type 'A1' is incomplete" }
3 struct A2; // { dg-message "note: class type 'A2' is incomplete" }
4 struct B1; // { dg-message "note: class type 'B1' is incomplete" }
5 struct B2; // { dg-message "note: class type 'B2' is incomplete" }
6
7 struct C { };
8 extern C* c;
9
10 void pointers(C* c, A2* a2, B1* b1)
11 {
12 (void) static_cast<A1*>(c); // { dg-error "10:invalid 'static_cast'" }
13 (void) static_cast<C*>(a2); // { dg-error "10:invalid 'static_cast'" }
14 (void) static_cast<B2*>(b1); // { dg-error "10:invalid 'static_cast'" }
15 }
16
17 struct D1; // { dg-message "note: class type 'D1' is incomplete" }
18 struct D2; // { dg-message "note: class type 'D2' is incomplete" }
19 struct E1; // { dg-message "note: class type 'E1' is incomplete" }
20 struct E2; // { dg-message "note: class type 'E2' is incomplete" }
21
22 void references(C& c, D2& d2, E1& e1)
23 {
24 (void) static_cast<D1&>(c); // { dg-error "10:invalid 'static_cast'" }
25 (void) static_cast<C&>(d2); // { dg-error "10:invalid 'static_cast'" }
26 (void) static_cast<E2&>(e1); // { dg-error "10:invalid 'static_cast'" }
27 }