| 1 |
// PR 3719 |
| 2 |
// Test that an unexpected handler can rethrow to categorize. |
| 3 |
// { dg-do run { target c++14_down } } |
| 4 |
|
| 5 |
#include <exception> |
| 6 |
|
| 7 |
extern "C" void abort (); |
| 8 |
|
| 9 |
struct One { }; |
| 10 |
struct Two { }; |
| 11 |
|
| 12 |
static void |
| 13 |
handle_unexpected () |
| 14 |
{ |
| 15 |
try |
| 16 |
{ |
| 17 |
throw; |
| 18 |
} |
| 19 |
catch (One &) |
| 20 |
{ |
| 21 |
throw Two (); |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
static void |
| 26 |
doit () throw (Two) // { dg-warning "deprecated" "" { target { c++11 } } } |
| 27 |
{ |
| 28 |
throw One (); |
| 29 |
} |
| 30 |
|
| 31 |
int main () |
| 32 |
{ |
| 33 |
std::set_unexpected (handle_unexpected); // { dg-warning "deprecated" "" { target { c++11 } } } |
| 34 |
|
| 35 |
try |
| 36 |
{ |
| 37 |
doit (); |
| 38 |
} |
| 39 |
catch (Two &) |
| 40 |
{ |
| 41 |
} |
| 42 |
catch (...) |
| 43 |
{ |
| 44 |
abort (); |
| 45 |
} |
| 46 |
} |