diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/eh/unexpected1.C')
-rw-r--r-- | gcc/testsuite/g++.dg/eh/unexpected1.C | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/eh/unexpected1.C b/gcc/testsuite/g++.dg/eh/unexpected1.C new file mode 100644 index 000000000..e5982ffac --- /dev/null +++ b/gcc/testsuite/g++.dg/eh/unexpected1.C @@ -0,0 +1,46 @@ +// PR 3719 +// Test that an unexpected handler can rethrow to categorize. +// { dg-do run } + +#include <exception> + +extern "C" void abort (); + +struct One { }; +struct Two { }; + +static void +handle_unexpected () +{ + try + { + throw; + } + catch (One &) + { + throw Two (); + } +} + +static void +doit () throw (Two) +{ + throw One (); +} + +int main () +{ + std::set_unexpected (handle_unexpected); + + try + { + doit (); + } + catch (Two &) + { + } + catch (...) + { + abort (); + } +} |