]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/ios_base/failure/dual_abi.cc
d198fc4333817ef1003a6b32c6a8f8d654101c0c
1 // Copyright (C) 2018-2021 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-options "-D_GLIBCXX_USE_CXX11_ABI=0" }
19 // { dg-do run { target c++11 } }
22 #include <system_error>
23 #include <testsuite_hooks.h>
29 bool caught_ios_failure
= false;
30 bool rethrown
= false;
31 bool caught_system_error
= false;
34 f
.exceptions(ios::failbit
| ios::badbit
| ios::eofbit
);
38 catch (const ios::failure
&) // catch as old ABI type
40 caught_ios_failure
= true;
41 #if _GLIBCXX_USE_DUAL_ABI || _GLIBCXX_USE_CXX11_ABI == 1
43 throw; // re-throw, to catch as new ABI type
47 catch (const std::system_error
& e
)
49 caught_system_error
= true;
52 VERIFY( caught_ios_failure
);
54 VERIFY( caught_system_error
);
61 const std::exception
* p
= nullptr;
62 bool caught_ios_failure
= false;
63 bool caught_exception
= false;
66 f
.exceptions(ios::failbit
| ios::badbit
| ios::eofbit
);
70 catch (const std::exception
& e1
)
72 caught_exception
= true;
77 catch (const ios::failure
& e2
)
79 caught_ios_failure
= true;
80 #if _GLIBCXX_USE_DUAL_ABI
81 // If the Dual ABI is active the library throws the new type,
82 // so e1 was an object of that new type and so &e1 != &e2.
85 // Otherwise there's only one type of ios::failure, so &e1 == &e2.
90 VERIFY( caught_exception
);
91 VERIFY( caught_ios_failure
);