| 1 |
// PR c++/57645 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
struct Thrower |
| 5 |
{ |
| 6 |
~Thrower() noexcept(false) { throw 1; } |
| 7 |
}; |
| 8 |
|
| 9 |
struct ExplicitA |
| 10 |
{ |
| 11 |
~ExplicitA() {} |
| 12 |
|
| 13 |
Thrower t; |
| 14 |
}; |
| 15 |
|
| 16 |
struct ExplicitB |
| 17 |
{ |
| 18 |
~ExplicitB(); |
| 19 |
|
| 20 |
Thrower t; |
| 21 |
}; |
| 22 |
|
| 23 |
ExplicitB::~ExplicitB() {} |
| 24 |
|
| 25 |
struct ExplicitC |
| 26 |
{ |
| 27 |
~ExplicitC() = default; |
| 28 |
|
| 29 |
Thrower t; |
| 30 |
}; |
| 31 |
|
| 32 |
struct ExplicitD |
| 33 |
{ |
| 34 |
~ExplicitD(); |
| 35 |
|
| 36 |
Thrower t; |
| 37 |
}; |
| 38 |
|
| 39 |
ExplicitD::~ExplicitD() = default; |
| 40 |
|
| 41 |
struct NoThrower |
| 42 |
{ |
| 43 |
~NoThrower() noexcept(true) {} |
| 44 |
}; |
| 45 |
|
| 46 |
struct ExplicitE |
| 47 |
{ |
| 48 |
~ExplicitE() {} |
| 49 |
|
| 50 |
NoThrower t; |
| 51 |
}; |
| 52 |
|
| 53 |
struct ExplicitF |
| 54 |
{ |
| 55 |
~ExplicitF(); |
| 56 |
|
| 57 |
NoThrower t; |
| 58 |
}; |
| 59 |
|
| 60 |
ExplicitF::~ExplicitF() {} |
| 61 |
|
| 62 |
struct ExplicitG |
| 63 |
{ |
| 64 |
~ExplicitG() = default; |
| 65 |
|
| 66 |
NoThrower t; |
| 67 |
}; |
| 68 |
|
| 69 |
struct ExplicitH |
| 70 |
{ |
| 71 |
~ExplicitH(); |
| 72 |
|
| 73 |
NoThrower t; |
| 74 |
}; |
| 75 |
|
| 76 |
ExplicitH::~ExplicitH() = default; |
| 77 |
|
| 78 |
#define SA(X) static_assert(X, #X) |
| 79 |
|
| 80 |
SA( !noexcept(ExplicitA()) ); |
| 81 |
SA( !noexcept(ExplicitB()) ); |
| 82 |
SA( !noexcept(ExplicitC()) ); |
| 83 |
SA( !noexcept(ExplicitD()) ); |
| 84 |
SA( noexcept(ExplicitE()) ); |
| 85 |
SA( noexcept(ExplicitF()) ); |
| 86 |
SA( noexcept(ExplicitG()) ); |
| 87 |
SA( noexcept(ExplicitH()) ); |