gcc/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc

48 lines
1.5 KiB
C++
Raw Normal View History

// { dg-options "-std=gnu++0x" }
system_error: New file. 2007-08-23 Benjamin Kosnik <bkoz@redhat.com> * include/std/system_error: New file. * src/system_error.cc: New file. * src/Makefile.am (sources): Add. * src/Makefile.in: Regenerate. * include/Makefile.am (std_headers): Add system_error. * include/Makefile.in: Regenerate. * acinclude.m4 (GLIBCXX_CHECK_SYSTEM_ERROR): New. * configure.ac: Call it. * config.h.in: Regenerate. * include/bits/functional_hash.h: Add hash<error_code>. * include/std/ostream: Add inserters for error_code. * docs/doxygen/user.cfg.in: Add system_error. * config/abi/pre/gnu.ver(GLIBCXX_3.4.10): Add new symbols. * testsuite/19_diagnostics/error_code: New. * testsuite/19_diagnostics/error_code/cons: Same. * testsuite/19_diagnostics/error_code/cons/1.cc: Same. * testsuite/19_diagnostics/error_code/operators: Same. * testsuite/19_diagnostics/error_code/operators/bool.cc: Same. * testsuite/19_diagnostics/error_code/operators/bool_neg.cc: Same. * testsuite/19_diagnostics/error_code/operators/equal.cc: Same. * testsuite/19_diagnostics/error_code/operators/not_equal.cc: Same. * testsuite/19_diagnostics/error_category: Same. * testsuite/19_diagnostics/error_category/cons: Same. * testsuite/19_diagnostics/error_category/cons/copy_neg.cc: Same. * testsuite/19_diagnostics/error_category/cons/default.cc: Same. * testsuite/19_diagnostics/error_category/operators: Same. * testsuite/19_diagnostics/error_category/operators/equal.cc: Same. * testsuite/19_diagnostics/error_category/operators/not_equal.cc: Same. * testsuite/19_diagnostics/headers/system_error: Same. * testsuite/19_diagnostics/headers/system_error/ types_std_c++0x.cc: Same. * testsuite/19_diagnostics/headers/system_error/std_c++0x_neg.cc: Same. * testsuite/19_diagnostics/system_error: Same. * testsuite/19_diagnostics/system_error/ cons_virtual_derivation.cc: Same. * testsuite/19_diagnostics/system_error/cons-1.cc: Same. * testsuite/19_diagnostics/system_error/what-1.cc: Same. * testsuite/19_diagnostics/system_error/what-2.cc: Same. * testsuite/19_diagnostics/system_error/what-big.cc: Same. * testsuite/19_diagnostics/system_error/what-3.cc: Same. * testsuite/19_diagnostics/system_error/what-4.cc: Same. * testsuite/27_io/basic_ostream/inserters_other/wchar_t/ error_code.cc: Same. * testsuite/27_io/basic_ostream/inserters_other/char/ error_code.cc: Same. * testsuite/tr1/6_containers/hash/operators: New. * testsuite/tr1/6_containers/hash/operators/size_t.cc: Same. * testsuite/23_containers/hash: Move... * testsuite/20_util/hash: ... here. * testsuite/20_util/hash/operators: New. * testsuite/20_util/hash/operators/size_t.cc: New. * testsuite/20_util/function_objects/bad_function_call: Move... * testsuite/20_util/bad_function_call: ...here. From-SVN: r127744
2007-08-23 18:16:41 +02:00
// 2007-06-05 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
system_error: New file. 2007-08-23 Benjamin Kosnik <bkoz@redhat.com> * include/std/system_error: New file. * src/system_error.cc: New file. * src/Makefile.am (sources): Add. * src/Makefile.in: Regenerate. * include/Makefile.am (std_headers): Add system_error. * include/Makefile.in: Regenerate. * acinclude.m4 (GLIBCXX_CHECK_SYSTEM_ERROR): New. * configure.ac: Call it. * config.h.in: Regenerate. * include/bits/functional_hash.h: Add hash<error_code>. * include/std/ostream: Add inserters for error_code. * docs/doxygen/user.cfg.in: Add system_error. * config/abi/pre/gnu.ver(GLIBCXX_3.4.10): Add new symbols. * testsuite/19_diagnostics/error_code: New. * testsuite/19_diagnostics/error_code/cons: Same. * testsuite/19_diagnostics/error_code/cons/1.cc: Same. * testsuite/19_diagnostics/error_code/operators: Same. * testsuite/19_diagnostics/error_code/operators/bool.cc: Same. * testsuite/19_diagnostics/error_code/operators/bool_neg.cc: Same. * testsuite/19_diagnostics/error_code/operators/equal.cc: Same. * testsuite/19_diagnostics/error_code/operators/not_equal.cc: Same. * testsuite/19_diagnostics/error_category: Same. * testsuite/19_diagnostics/error_category/cons: Same. * testsuite/19_diagnostics/error_category/cons/copy_neg.cc: Same. * testsuite/19_diagnostics/error_category/cons/default.cc: Same. * testsuite/19_diagnostics/error_category/operators: Same. * testsuite/19_diagnostics/error_category/operators/equal.cc: Same. * testsuite/19_diagnostics/error_category/operators/not_equal.cc: Same. * testsuite/19_diagnostics/headers/system_error: Same. * testsuite/19_diagnostics/headers/system_error/ types_std_c++0x.cc: Same. * testsuite/19_diagnostics/headers/system_error/std_c++0x_neg.cc: Same. * testsuite/19_diagnostics/system_error: Same. * testsuite/19_diagnostics/system_error/ cons_virtual_derivation.cc: Same. * testsuite/19_diagnostics/system_error/cons-1.cc: Same. * testsuite/19_diagnostics/system_error/what-1.cc: Same. * testsuite/19_diagnostics/system_error/what-2.cc: Same. * testsuite/19_diagnostics/system_error/what-big.cc: Same. * testsuite/19_diagnostics/system_error/what-3.cc: Same. * testsuite/19_diagnostics/system_error/what-4.cc: Same. * testsuite/27_io/basic_ostream/inserters_other/wchar_t/ error_code.cc: Same. * testsuite/27_io/basic_ostream/inserters_other/char/ error_code.cc: Same. * testsuite/tr1/6_containers/hash/operators: New. * testsuite/tr1/6_containers/hash/operators/size_t.cc: Same. * testsuite/23_containers/hash: Move... * testsuite/20_util/hash: ... here. * testsuite/20_util/hash/operators: New. * testsuite/20_util/hash/operators/size_t.cc: New. * testsuite/20_util/function_objects/bad_function_call: Move... * testsuite/20_util/bad_function_call: ...here. From-SVN: r127744
2007-08-23 18:16:41 +02:00
#include <cstring>
#include <system_error>
#include <testsuite_hooks.h>
int main()
{
system_error: New file. 2007-08-23 Benjamin Kosnik <bkoz@redhat.com> * include/std/system_error: New file. * src/system_error.cc: New file. * src/Makefile.am (sources): Add. * src/Makefile.in: Regenerate. * include/Makefile.am (std_headers): Add system_error. * include/Makefile.in: Regenerate. * acinclude.m4 (GLIBCXX_CHECK_SYSTEM_ERROR): New. * configure.ac: Call it. * config.h.in: Regenerate. * include/bits/functional_hash.h: Add hash<error_code>. * include/std/ostream: Add inserters for error_code. * docs/doxygen/user.cfg.in: Add system_error. * config/abi/pre/gnu.ver(GLIBCXX_3.4.10): Add new symbols. * testsuite/19_diagnostics/error_code: New. * testsuite/19_diagnostics/error_code/cons: Same. * testsuite/19_diagnostics/error_code/cons/1.cc: Same. * testsuite/19_diagnostics/error_code/operators: Same. * testsuite/19_diagnostics/error_code/operators/bool.cc: Same. * testsuite/19_diagnostics/error_code/operators/bool_neg.cc: Same. * testsuite/19_diagnostics/error_code/operators/equal.cc: Same. * testsuite/19_diagnostics/error_code/operators/not_equal.cc: Same. * testsuite/19_diagnostics/error_category: Same. * testsuite/19_diagnostics/error_category/cons: Same. * testsuite/19_diagnostics/error_category/cons/copy_neg.cc: Same. * testsuite/19_diagnostics/error_category/cons/default.cc: Same. * testsuite/19_diagnostics/error_category/operators: Same. * testsuite/19_diagnostics/error_category/operators/equal.cc: Same. * testsuite/19_diagnostics/error_category/operators/not_equal.cc: Same. * testsuite/19_diagnostics/headers/system_error: Same. * testsuite/19_diagnostics/headers/system_error/ types_std_c++0x.cc: Same. * testsuite/19_diagnostics/headers/system_error/std_c++0x_neg.cc: Same. * testsuite/19_diagnostics/system_error: Same. * testsuite/19_diagnostics/system_error/ cons_virtual_derivation.cc: Same. * testsuite/19_diagnostics/system_error/cons-1.cc: Same. * testsuite/19_diagnostics/system_error/what-1.cc: Same. * testsuite/19_diagnostics/system_error/what-2.cc: Same. * testsuite/19_diagnostics/system_error/what-big.cc: Same. * testsuite/19_diagnostics/system_error/what-3.cc: Same. * testsuite/19_diagnostics/system_error/what-4.cc: Same. * testsuite/27_io/basic_ostream/inserters_other/wchar_t/ error_code.cc: Same. * testsuite/27_io/basic_ostream/inserters_other/char/ error_code.cc: Same. * testsuite/tr1/6_containers/hash/operators: New. * testsuite/tr1/6_containers/hash/operators/size_t.cc: Same. * testsuite/23_containers/hash: Move... * testsuite/20_util/hash: ... here. * testsuite/20_util/hash/operators: New. * testsuite/20_util/hash/operators/size_t.cc: New. * testsuite/20_util/function_objects/bad_function_call: Move... * testsuite/20_util/bad_function_call: ...here. From-SVN: r127744
2007-08-23 18:16:41 +02:00
bool test __attribute__((unused)) = true;
const std::string s("too late: boulangerie out of pain au raisin");
re PR libstdc++/39880 (Specialisation is_error_code_enum<errc> should not exist) 2009-04-25 Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/39880 PR libstdc++/39881 PR libstdc++/39882 * include/std/system_error (is_error_code_enum<errc>): Remove. (error_condition<>::error_condition(_ErrorCodeEnum,) error_condition<>::operator=(_ErrorCodeEnum)): Use make_error_condition. (error_code<>::error_code(_ErrorCodeEnum,), error_code<>::operator=(_ErrorCodeEnum)): Use make_error_code. * testsuite/19_diagnostics/system_error/39880.cc: New. * testsuite/19_diagnostics/error_condition/modifiers/39881.cc: Likewise. * testsuite/19_diagnostics/error_condition/cons/39881.cc: Likewise. * testsuite/19_diagnostics/error_code/modifiers/39882.cc: Likewise. * testsuite/19_diagnostics/error_code/cons/39882.cc: Likewise. * testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc: Adjust. * testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc: Likewise. * testsuite/19_diagnostics/error_code/cons/1.cc: Likewise. * testsuite/19_diagnostics/error_code/operators/bool.cc: Likewise. * testsuite/19_diagnostics/error_code/operators/equal.cc: Likewise. * testsuite/19_diagnostics/error_code/operators/not_equal.cc: Likewise. * testsuite/19_diagnostics/error_category/cons/copy_neg.cc: Likewise. * testsuite/19_diagnostics/system_error/cons-1.cc: Likewise. * testsuite/19_diagnostics/system_error/what-4.cc: Likewise. * testsuite/30_threads/unique_lock/locking/2.cc: Likewise. From-SVN: r146780
2009-04-25 21:00:52 +02:00
const std::error_code
e(std::make_error_code(std::errc::operation_not_supported));
system_error: New file. 2007-08-23 Benjamin Kosnik <bkoz@redhat.com> * include/std/system_error: New file. * src/system_error.cc: New file. * src/Makefile.am (sources): Add. * src/Makefile.in: Regenerate. * include/Makefile.am (std_headers): Add system_error. * include/Makefile.in: Regenerate. * acinclude.m4 (GLIBCXX_CHECK_SYSTEM_ERROR): New. * configure.ac: Call it. * config.h.in: Regenerate. * include/bits/functional_hash.h: Add hash<error_code>. * include/std/ostream: Add inserters for error_code. * docs/doxygen/user.cfg.in: Add system_error. * config/abi/pre/gnu.ver(GLIBCXX_3.4.10): Add new symbols. * testsuite/19_diagnostics/error_code: New. * testsuite/19_diagnostics/error_code/cons: Same. * testsuite/19_diagnostics/error_code/cons/1.cc: Same. * testsuite/19_diagnostics/error_code/operators: Same. * testsuite/19_diagnostics/error_code/operators/bool.cc: Same. * testsuite/19_diagnostics/error_code/operators/bool_neg.cc: Same. * testsuite/19_diagnostics/error_code/operators/equal.cc: Same. * testsuite/19_diagnostics/error_code/operators/not_equal.cc: Same. * testsuite/19_diagnostics/error_category: Same. * testsuite/19_diagnostics/error_category/cons: Same. * testsuite/19_diagnostics/error_category/cons/copy_neg.cc: Same. * testsuite/19_diagnostics/error_category/cons/default.cc: Same. * testsuite/19_diagnostics/error_category/operators: Same. * testsuite/19_diagnostics/error_category/operators/equal.cc: Same. * testsuite/19_diagnostics/error_category/operators/not_equal.cc: Same. * testsuite/19_diagnostics/headers/system_error: Same. * testsuite/19_diagnostics/headers/system_error/ types_std_c++0x.cc: Same. * testsuite/19_diagnostics/headers/system_error/std_c++0x_neg.cc: Same. * testsuite/19_diagnostics/system_error: Same. * testsuite/19_diagnostics/system_error/ cons_virtual_derivation.cc: Same. * testsuite/19_diagnostics/system_error/cons-1.cc: Same. * testsuite/19_diagnostics/system_error/what-1.cc: Same. * testsuite/19_diagnostics/system_error/what-2.cc: Same. * testsuite/19_diagnostics/system_error/what-big.cc: Same. * testsuite/19_diagnostics/system_error/what-3.cc: Same. * testsuite/19_diagnostics/system_error/what-4.cc: Same. * testsuite/27_io/basic_ostream/inserters_other/wchar_t/ error_code.cc: Same. * testsuite/27_io/basic_ostream/inserters_other/char/ error_code.cc: Same. * testsuite/tr1/6_containers/hash/operators: New. * testsuite/tr1/6_containers/hash/operators/size_t.cc: Same. * testsuite/23_containers/hash: Move... * testsuite/20_util/hash: ... here. * testsuite/20_util/hash/operators: New. * testsuite/20_util/hash/operators/size_t.cc: New. * testsuite/20_util/function_objects/bad_function_call: Move... * testsuite/20_util/bad_function_call: ...here. From-SVN: r127744
2007-08-23 18:16:41 +02:00
// 1
{
std::system_error err1(e, s);
system_error: New file. 2007-08-23 Benjamin Kosnik <bkoz@redhat.com> * include/std/system_error: New file. * src/system_error.cc: New file. * src/Makefile.am (sources): Add. * src/Makefile.in: Regenerate. * include/Makefile.am (std_headers): Add system_error. * include/Makefile.in: Regenerate. * acinclude.m4 (GLIBCXX_CHECK_SYSTEM_ERROR): New. * configure.ac: Call it. * config.h.in: Regenerate. * include/bits/functional_hash.h: Add hash<error_code>. * include/std/ostream: Add inserters for error_code. * docs/doxygen/user.cfg.in: Add system_error. * config/abi/pre/gnu.ver(GLIBCXX_3.4.10): Add new symbols. * testsuite/19_diagnostics/error_code: New. * testsuite/19_diagnostics/error_code/cons: Same. * testsuite/19_diagnostics/error_code/cons/1.cc: Same. * testsuite/19_diagnostics/error_code/operators: Same. * testsuite/19_diagnostics/error_code/operators/bool.cc: Same. * testsuite/19_diagnostics/error_code/operators/bool_neg.cc: Same. * testsuite/19_diagnostics/error_code/operators/equal.cc: Same. * testsuite/19_diagnostics/error_code/operators/not_equal.cc: Same. * testsuite/19_diagnostics/error_category: Same. * testsuite/19_diagnostics/error_category/cons: Same. * testsuite/19_diagnostics/error_category/cons/copy_neg.cc: Same. * testsuite/19_diagnostics/error_category/cons/default.cc: Same. * testsuite/19_diagnostics/error_category/operators: Same. * testsuite/19_diagnostics/error_category/operators/equal.cc: Same. * testsuite/19_diagnostics/error_category/operators/not_equal.cc: Same. * testsuite/19_diagnostics/headers/system_error: Same. * testsuite/19_diagnostics/headers/system_error/ types_std_c++0x.cc: Same. * testsuite/19_diagnostics/headers/system_error/std_c++0x_neg.cc: Same. * testsuite/19_diagnostics/system_error: Same. * testsuite/19_diagnostics/system_error/ cons_virtual_derivation.cc: Same. * testsuite/19_diagnostics/system_error/cons-1.cc: Same. * testsuite/19_diagnostics/system_error/what-1.cc: Same. * testsuite/19_diagnostics/system_error/what-2.cc: Same. * testsuite/19_diagnostics/system_error/what-big.cc: Same. * testsuite/19_diagnostics/system_error/what-3.cc: Same. * testsuite/19_diagnostics/system_error/what-4.cc: Same. * testsuite/27_io/basic_ostream/inserters_other/wchar_t/ error_code.cc: Same. * testsuite/27_io/basic_ostream/inserters_other/char/ error_code.cc: Same. * testsuite/tr1/6_containers/hash/operators: New. * testsuite/tr1/6_containers/hash/operators/size_t.cc: Same. * testsuite/23_containers/hash: Move... * testsuite/20_util/hash: ... here. * testsuite/20_util/hash/operators: New. * testsuite/20_util/hash/operators/size_t.cc: New. * testsuite/20_util/function_objects/bad_function_call: Move... * testsuite/20_util/bad_function_call: ...here. From-SVN: r127744
2007-08-23 18:16:41 +02:00
VERIFY( err1.code() == e );
VERIFY( std::strcmp(err1.runtime_error::what(), s.c_str()) == 0 );
}
// 2
{
std::system_error err2(95, std::system_category(), s);
VERIFY( err2.code() == std::error_code(95, std::system_category()) );
system_error: New file. 2007-08-23 Benjamin Kosnik <bkoz@redhat.com> * include/std/system_error: New file. * src/system_error.cc: New file. * src/Makefile.am (sources): Add. * src/Makefile.in: Regenerate. * include/Makefile.am (std_headers): Add system_error. * include/Makefile.in: Regenerate. * acinclude.m4 (GLIBCXX_CHECK_SYSTEM_ERROR): New. * configure.ac: Call it. * config.h.in: Regenerate. * include/bits/functional_hash.h: Add hash<error_code>. * include/std/ostream: Add inserters for error_code. * docs/doxygen/user.cfg.in: Add system_error. * config/abi/pre/gnu.ver(GLIBCXX_3.4.10): Add new symbols. * testsuite/19_diagnostics/error_code: New. * testsuite/19_diagnostics/error_code/cons: Same. * testsuite/19_diagnostics/error_code/cons/1.cc: Same. * testsuite/19_diagnostics/error_code/operators: Same. * testsuite/19_diagnostics/error_code/operators/bool.cc: Same. * testsuite/19_diagnostics/error_code/operators/bool_neg.cc: Same. * testsuite/19_diagnostics/error_code/operators/equal.cc: Same. * testsuite/19_diagnostics/error_code/operators/not_equal.cc: Same. * testsuite/19_diagnostics/error_category: Same. * testsuite/19_diagnostics/error_category/cons: Same. * testsuite/19_diagnostics/error_category/cons/copy_neg.cc: Same. * testsuite/19_diagnostics/error_category/cons/default.cc: Same. * testsuite/19_diagnostics/error_category/operators: Same. * testsuite/19_diagnostics/error_category/operators/equal.cc: Same. * testsuite/19_diagnostics/error_category/operators/not_equal.cc: Same. * testsuite/19_diagnostics/headers/system_error: Same. * testsuite/19_diagnostics/headers/system_error/ types_std_c++0x.cc: Same. * testsuite/19_diagnostics/headers/system_error/std_c++0x_neg.cc: Same. * testsuite/19_diagnostics/system_error: Same. * testsuite/19_diagnostics/system_error/ cons_virtual_derivation.cc: Same. * testsuite/19_diagnostics/system_error/cons-1.cc: Same. * testsuite/19_diagnostics/system_error/what-1.cc: Same. * testsuite/19_diagnostics/system_error/what-2.cc: Same. * testsuite/19_diagnostics/system_error/what-big.cc: Same. * testsuite/19_diagnostics/system_error/what-3.cc: Same. * testsuite/19_diagnostics/system_error/what-4.cc: Same. * testsuite/27_io/basic_ostream/inserters_other/wchar_t/ error_code.cc: Same. * testsuite/27_io/basic_ostream/inserters_other/char/ error_code.cc: Same. * testsuite/tr1/6_containers/hash/operators: New. * testsuite/tr1/6_containers/hash/operators/size_t.cc: Same. * testsuite/23_containers/hash: Move... * testsuite/20_util/hash: ... here. * testsuite/20_util/hash/operators: New. * testsuite/20_util/hash/operators/size_t.cc: New. * testsuite/20_util/function_objects/bad_function_call: Move... * testsuite/20_util/bad_function_call: ...here. From-SVN: r127744
2007-08-23 18:16:41 +02:00
VERIFY( std::strcmp(err2.runtime_error::what(), s.c_str()) == 0 );
}
return 0;
}