]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/ios_base/failure/error_code.cc
1 // Copyright (C) 2020-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-do run { target c++11 } }
21 #include <testsuite_hooks.h>
26 std::error_code ec
, def_ec
;
27 #if _GLIBCXX_USE_CXX11_ABI
28 // For the new ABI code() should return the constructor argument.
29 ec
= std::make_error_code(std::errc::executable_format_error
);
30 def_ec
= std::io_errc::stream
;
32 // For the old ABI code() always returns a default-constructed error_code.
34 std::ios_base::failure
e1("string literal");
35 VERIFY( e1
.code() == def_ec
);
36 std::ios_base::failure
e2(std::string("std::string"));
37 VERIFY( e2
.code() == def_ec
);
38 std::ios_base::failure
e3("string literal", ec
);
39 VERIFY( e3
.code() == ec
);
40 std::ios_base::failure
e4(std::string("std::string"), ec
);
41 VERIFY( e4
.code() == ec
);