]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/18_support/nested_exception/rethrow_if_nested.cc
dfdcdab70b2d1c95ca0c3122d7c981d36851ac9c
1 // { dg-do run { target c++11 } }
3 // Copyright (C) 2009-2020 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
21 #include <testsuite_hooks.h>
23 struct derived
: std::nested_exception
{ };
25 struct base
{ virtual ~base() noexcept
; };
26 inline base::~base() noexcept
= default;
28 struct derived2
: base
, std::nested_exception
{ };
43 std::rethrow_if_nested(d
);
65 std::rethrow_if_nested(b
);
90 std::rethrow_if_nested(b
);
106 // LWG 2484 requires that these cases are well-formed, but don't rethrow.
108 std::rethrow_if_nested(1);
110 struct S
{ } nonpolymorphic
;
111 std::rethrow_if_nested(nonpolymorphic
);
113 struct derived3
: derived
, derived2
{ };
114 derived3 ambiguous_base
;
115 std::rethrow_if_nested(ambiguous_base
);
117 struct derived4
: private std::nested_exception
{ };
118 derived4 private_base
;
119 std::rethrow_if_nested(private_base
);