| 1 | // { dg-do run } |
| 2 | |
| 3 | #include <exception> |
| 4 | #if __cplusplus < 201103L |
| 5 | // std::make_exception_ptr is defined for C++98 as a GNU extension |
| 6 | # include <bits/exception_ptr.h> |
| 7 | #endif |
| 8 | |
| 9 | #include <testsuite_hooks.h> |
| 10 | |
| 11 | struct B |
| 12 | { |
| 13 | virtual bool derived() const { return false; } |
| 14 | }; |
| 15 | |
| 16 | struct D : B |
| 17 | { |
| 18 | virtual bool derived() const { return true; } |
| 19 | }; |
| 20 | |
| 21 | int main() |
| 22 | { |
| 23 | D d; |
| 24 | std::exception_ptr p = std::make_exception_ptr<B&>(d); // PR libstdc++/103630 |
| 25 | #if __cpp_exceptions |
| 26 | try |
| 27 | { |
| 28 | std::rethrow_exception(p); |
| 29 | } |
| 30 | catch (const D& d) |
| 31 | { |
| 32 | VERIFY(d.derived()); // PR libstdc++/103630 |
| 33 | } |
| 34 | catch (const B& b) |
| 35 | { |
| 36 | VERIFY(!b.derived()); |
| 37 | } |
| 38 | #endif |
| 39 | } |