| 1 |
// PR c++/50043 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-options "-Wno-terminate" } |
| 4 |
|
| 5 |
struct True1 {}; |
| 6 |
struct True2 { ~True2(); }; |
| 7 |
struct True3 { ~True3(){ throw 0; } }; |
| 8 |
struct False { ~False() noexcept(false); }; |
| 9 |
|
| 10 |
template <typename Base> |
| 11 |
struct A : Base |
| 12 |
{ |
| 13 |
}; |
| 14 |
|
| 15 |
template <typename Member> |
| 16 |
struct B |
| 17 |
{ |
| 18 |
Member mem; |
| 19 |
}; |
| 20 |
|
| 21 |
template <typename Base, typename Member> |
| 22 |
struct C : Base |
| 23 |
{ |
| 24 |
Member mem; |
| 25 |
}; |
| 26 |
|
| 27 |
#define SA(X) static_assert(X, #X) |
| 28 |
|
| 29 |
SA( noexcept(True1())); |
| 30 |
SA( noexcept(True2())); |
| 31 |
SA( noexcept(True3())); |
| 32 |
SA(!noexcept(False())); |
| 33 |
|
| 34 |
SA( noexcept(A<True1>())); |
| 35 |
SA( noexcept(A<True2>())); |
| 36 |
SA( noexcept(A<True3>())); |
| 37 |
SA(!noexcept(A<False>())); |
| 38 |
|
| 39 |
SA( noexcept(B<True1>())); |
| 40 |
SA( noexcept(B<True2>())); |
| 41 |
SA( noexcept(B<True3>())); |
| 42 |
SA(!noexcept(B<False>())); |
| 43 |
|
| 44 |
SA( noexcept(C<True1, True2>())); |
| 45 |
SA( noexcept(C<True1, True3>())); |
| 46 |
SA( noexcept(C<True2, True3>())); |
| 47 |
SA( noexcept(C<True2, True1>())); |
| 48 |
SA( noexcept(C<True3, True1>())); |
| 49 |
SA( noexcept(C<True3, True2>())); |
| 50 |
SA(!noexcept(C<False, True1>())); |
| 51 |
SA(!noexcept(C<False, True2>())); |
| 52 |
SA(!noexcept(C<False, True3>())); |
| 53 |
SA(!noexcept(C<True1, False>())); |
| 54 |
SA(!noexcept(C<True2, False>())); |
| 55 |
SA(!noexcept(C<True3, False>())); |