145
|
1 // PR c++/88128 - DR 330: Qual convs and pointers to arrays of pointers.
|
|
2 // { dg-do compile { target c++17 } }
|
|
3
|
|
4 using P = int *(*)[3];
|
|
5 using Q = const int *const (*)[3];
|
|
6 using Qi = const int *[3];
|
|
7 using Q2 = Qi const *;
|
|
8 using R = const int *const (*)[4];
|
|
9 using S = const int *const (*)[];
|
|
10 using T = const int *(*)[];
|
|
11
|
|
12 void
|
|
13 f (P p, Q q, Q2 q2, R r, S s, T t)
|
|
14 {
|
|
15 q = p;
|
|
16 q2 = p;
|
|
17 r = p; // { dg-error "cannot convert" }
|
|
18 t = p; // { dg-error "cannot convert" }
|
|
19 s = t;
|
|
20 t = s; // { dg-error "invalid conversion" }
|
|
21
|
|
22 // Test const_cast.
|
|
23 const_cast<P>(q);
|
|
24 const_cast<P>(q2);
|
|
25 const_cast<Q>(p);
|
|
26 const_cast<Q2>(p);
|
|
27 const_cast<S>(p); // { dg-error "3:invalid .const_cast." }
|
|
28 const_cast<P>(s); // { dg-error "3:invalid .const_cast." }
|
|
29 const_cast<S>(q); // { dg-error "3:invalid .const_cast." }
|
|
30 const_cast<S>(q2); // { dg-error "3:invalid .const_cast." }
|
|
31 const_cast<Q>(s); // { dg-error "3:invalid .const_cast." }
|
|
32 const_cast<Q2>(s); // { dg-error "3:invalid .const_cast." }
|
|
33 const_cast<T>(s);
|
|
34 const_cast<S>(t);
|
|
35 const_cast<T>(q); // { dg-error "3:invalid .const_cast." }
|
|
36 const_cast<Q>(t); // { dg-error "3:invalid .const_cast." }
|
|
37
|
|
38 // Test reinterpret_cast.
|
|
39 reinterpret_cast<P>(q); // { dg-error "3:.reinterpret_cast. \[^\n\r]* casts away qualifiers" }
|
|
40 reinterpret_cast<P>(q2); // { dg-error "3:.reinterpret_cast. \[^\n\r]* casts away qualifiers" }
|
|
41 reinterpret_cast<Q>(p);
|
|
42 reinterpret_cast<Q2>(p);
|
|
43 reinterpret_cast<S>(p);
|
|
44 reinterpret_cast<P>(s); // { dg-error "3:.reinterpret_cast. \[^\n\r]* casts away qualifiers" }
|
|
45 reinterpret_cast<S>(q);
|
|
46 reinterpret_cast<S>(q2);
|
|
47 reinterpret_cast<Q>(s);
|
|
48 reinterpret_cast<Q2>(s);
|
|
49 reinterpret_cast<T>(s); // { dg-error "3:.reinterpret_cast. \[^\n\r]* casts away qualifiers" }
|
|
50 reinterpret_cast<S>(t);
|
|
51 reinterpret_cast<T>(q); // { dg-error "3:.reinterpret_cast. \[^\n\r]* casts away qualifiers" }
|
|
52 reinterpret_cast<Q>(t);
|
|
53 }
|