| 1 |
// { dg-do compile } |
| 2 |
|
| 3 |
class A {}; |
| 4 |
class B : public A {}; |
| 5 |
|
| 6 |
template<const A* a> class C {}; |
| 7 |
template<const B* b> class D {}; |
| 8 |
template<B* b> class E {}; |
| 9 |
|
| 10 |
template<const B* b> void f(D<b> &, C<static_cast<const A*>(b)> &) {} // { dg-error "" "" { target { ! c++20 } } } |
| 11 |
template<const B* b> void g(D<b> &, E<const_cast<B*>(b)> &) {} // { dg-error "" "" { target { ! c++11 } } } |
| 12 |
|
| 13 |
B b; |
| 14 |
|
| 15 |
int main() |
| 16 |
{ |
| 17 |
C<static_cast<const A*>(&b)> c; // { dg-error "" "" { target c++17_down } } |
| 18 |
D<&b> d; |
| 19 |
E<const_cast<B*>(&b)> e; // { dg-error "" "" { target { ! c++11 } } } |
| 20 |
f(d, c); // { dg-error "" "" { target { c++11 && { ! c++20 } } } } |
| 21 |
g(d, e); |
| 22 |
} |