Commit 83588991 by Paolo Carlini Committed by Paolo Carlini

re PR libstdc++/34538 ([DR 697] combination of sstream, invalid_argument and…

re PR libstdc++/34538 ([DR 697] combination of sstream, invalid_argument and -std=c++0x breaks valid code)

2007-12-27  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/34538
	* config/os/generic/error_constants.h (enum posix_errno): Move
	inside namespace posix_error.
	* include/std/system_error (error_category::posix,
	error_code::error_code(posix_errno), error_code::posix): Adjust.
	* src/system_error.cc (gnu_error_category::posix): Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc:
	Adjust.
	* testsuite/27_io/basic_ostream/inserters_other/char/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/error_category/cons/default.cc: Likewise.
	* testsuite/19_diagnostics/error_category/operators/equal.cc:
	Likewise.
	* testsuite/19_diagnostics/error_category/operators/not_equal.cc:
	Likewise.
	* testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc:
	Likewise.
	* testsuite/19_diagnostics/system_error/cons-1.cc: Likewise.
	* testsuite/19_diagnostics/system_error/what-4.cc: Likewise.
	* testsuite/19_diagnostics/headers/system_error/34538.cc: New.

From-SVN: r131200
parent ceac3d59
2007-12-27 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/34538
* config/os/generic/error_constants.h (enum posix_errno): Move
inside namespace posix_error.
* include/std/system_error (error_category::posix,
error_code::error_code(posix_errno), error_code::posix): Adjust.
* src/system_error.cc (gnu_error_category::posix): Likewise.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc:
Adjust.
* testsuite/27_io/basic_ostream/inserters_other/char/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/error_category/cons/default.cc: Likewise.
* testsuite/19_diagnostics/error_category/operators/equal.cc:
Likewise.
* testsuite/19_diagnostics/error_category/operators/not_equal.cc:
Likewise.
* testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc:
Likewise.
* testsuite/19_diagnostics/system_error/cons-1.cc: Likewise.
* testsuite/19_diagnostics/system_error/what-4.cc: Likewise.
* testsuite/19_diagnostics/headers/system_error/34538.cc: New.
2007-12-26 Paolo Carlini <pcarlini@suse.de> 2007-12-26 Paolo Carlini <pcarlini@suse.de>
* testsuite/25_algorithms/copy/34595.C: Rename to 34595.cc. * testsuite/25_algorithms/copy/34595.C: Rename to 34595.cc.
......
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
_GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_BEGIN_NAMESPACE(std)
namespace posix_error
{
enum posix_errno enum posix_errno
{ {
address_family_not_supported = EAFNOSUPPORT, address_family_not_supported = EAFNOSUPPORT,
...@@ -159,6 +161,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -159,6 +161,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
wrong_protocol_type = EPROTOTYPE, wrong_protocol_type = EPROTOTYPE,
no_posix_equivalent = 1L << 16 no_posix_equivalent = 1L << 16
}; };
}
_GLIBCXX_END_NAMESPACE _GLIBCXX_END_NAMESPACE
......
...@@ -65,7 +65,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -65,7 +65,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
operator!=(const error_category& __other) const operator!=(const error_category& __other) const
{ return this != &__other; } { return this != &__other; }
virtual posix_errno virtual posix_error::posix_errno
posix(int __v) const = 0; posix(int __v) const = 0;
virtual const string& virtual const string&
...@@ -86,7 +86,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -86,7 +86,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
error_code(int __v, const error_category& __cat) throw() error_code(int __v, const error_category& __cat) throw()
: _M_value(__v), _M_cat(&__cat) { } : _M_value(__v), _M_cat(&__cat) { }
error_code(posix_errno __v) error_code(posix_error::posix_errno __v)
: _M_value(__v), _M_cat(&system_category) { } : _M_value(__v), _M_cat(&system_category) { }
void void
...@@ -109,7 +109,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -109,7 +109,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
const error_category& const error_category&
category() const { return *_M_cat; } category() const { return *_M_cat; }
posix_errno posix_error::posix_errno
posix() const throw() { return this->category().posix(_M_value); } posix() const throw() { return this->category().posix(_M_value); }
// Safe bool idiom. // Safe bool idiom.
......
...@@ -44,7 +44,7 @@ namespace ...@@ -44,7 +44,7 @@ namespace
return category; return category;
} }
virtual std::posix_errno virtual std::posix_error::posix_errno
posix(int __v) const posix(int __v) const
{ {
#ifdef _GLIBCXX_HAVE_SYS_NERR #ifdef _GLIBCXX_HAVE_SYS_NERR
...@@ -53,9 +53,9 @@ namespace ...@@ -53,9 +53,9 @@ namespace
const int last_errorno = std::numeric_limits<int>::max(); const int last_errorno = std::numeric_limits<int>::max();
#endif #endif
if (__v > 0 && __v <= last_errorno) if (__v > 0 && __v <= last_errorno)
return std::posix_errno(__v); return std::posix_error::posix_errno(__v);
else else
return std::no_posix_equivalent; return std::posix_error::no_posix_equivalent;
} }
}; };
......
...@@ -27,9 +27,9 @@ namespace __gnu_test ...@@ -27,9 +27,9 @@ namespace __gnu_test
{ {
struct test_category : public std::error_category struct test_category : public std::error_category
{ {
virtual std::posix_errno virtual std::posix_error::posix_errno
posix(int __v) const posix(int __v) const
{ return std::posix_errno(__v); } { return std::posix_error::posix_errno(__v); }
virtual const std::string& virtual const std::string&
name() const name() const
......
...@@ -26,9 +26,9 @@ namespace __gnu_test ...@@ -26,9 +26,9 @@ namespace __gnu_test
{ {
struct test_category : public std::error_category struct test_category : public std::error_category
{ {
virtual std::posix_errno virtual std::posix_error::posix_errno
posix(int __v) const posix(int __v) const
{ return std::posix_errno(__v); } { return std::posix_error::posix_errno(__v); }
virtual const std::string& virtual const std::string&
name() const name() const
......
...@@ -26,9 +26,9 @@ namespace __gnu_test ...@@ -26,9 +26,9 @@ namespace __gnu_test
{ {
struct test_category : public std::error_category struct test_category : public std::error_category
{ {
virtual std::posix_errno virtual std::posix_error::posix_errno
posix(int __v) const posix(int __v) const
{ return std::posix_errno(__v); } { return std::posix_error::posix_errno(__v); }
virtual const std::string& virtual const std::string&
name() const name() const
......
...@@ -26,9 +26,9 @@ namespace __gnu_test ...@@ -26,9 +26,9 @@ namespace __gnu_test
{ {
struct test_category : public std::error_category struct test_category : public std::error_category
{ {
virtual std::posix_errno virtual std::posix_error::posix_errno
posix(int __v) const posix(int __v) const
{ return std::posix_errno(__v); } { return std::posix_error::posix_errno(__v); }
virtual const std::string& virtual const std::string&
name() const name() const
......
...@@ -26,9 +26,9 @@ namespace __gnu_test ...@@ -26,9 +26,9 @@ namespace __gnu_test
{ {
struct test_category : public std::error_category struct test_category : public std::error_category
{ {
virtual std::posix_errno virtual std::posix_error::posix_errno
posix(int __v) const posix(int __v) const
{ return std::posix_errno(__v); } { return std::posix_error::posix_errno(__v); }
virtual const std::string& virtual const std::string&
name() const name() const
...@@ -55,8 +55,8 @@ int main() ...@@ -55,8 +55,8 @@ int main()
VERIFY( e2.category() == cat ); VERIFY( e2.category() == cat );
// 3 // 3
std::error_code e3(std::operation_not_supported); std::error_code e3(std::posix_error::operation_not_supported);
VERIFY( e3.value() == int(std::operation_not_supported) ); VERIFY( e3.value() == int(std::posix_error::operation_not_supported) );
VERIFY( e3.category() == std::system_category ); VERIFY( e3.category() == std::system_category );
return 0; return 0;
......
...@@ -35,7 +35,7 @@ int main() ...@@ -35,7 +35,7 @@ int main()
} }
// 2 // 2
std::error_code e2(std::operation_not_supported); std::error_code e2(std::posix_error::operation_not_supported);
if (e2) if (e2)
{ {
VERIFY( true ); VERIFY( true );
......
...@@ -26,9 +26,9 @@ namespace __gnu_test ...@@ -26,9 +26,9 @@ namespace __gnu_test
{ {
struct test_category : public std::error_category struct test_category : public std::error_category
{ {
virtual std::posix_errno virtual std::posix_error::posix_errno
posix(int __v) const posix(int __v) const
{ return std::posix_errno(__v); } { return std::posix_error::posix_errno(__v); }
virtual const std::string& virtual const std::string&
name() const name() const
...@@ -45,7 +45,7 @@ int main() ...@@ -45,7 +45,7 @@ int main()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::error_code e1; std::error_code e1;
std::error_code e2(std::operation_not_supported); std::error_code e2(std::posix_error::operation_not_supported);
VERIFY( e1 == e1 ); VERIFY( e1 == e1 );
VERIFY( !(e1 == e2) ); VERIFY( !(e1 == e2) );
......
...@@ -26,9 +26,9 @@ namespace __gnu_test ...@@ -26,9 +26,9 @@ namespace __gnu_test
{ {
struct test_category : public std::error_category struct test_category : public std::error_category
{ {
virtual std::posix_errno virtual std::posix_error::posix_errno
posix(int __v) const posix(int __v) const
{ return std::posix_errno(__v); } { return std::posix_error::posix_errno(__v); }
virtual const std::string& virtual const std::string&
name() const name() const
...@@ -45,7 +45,7 @@ int main() ...@@ -45,7 +45,7 @@ int main()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::error_code e1; std::error_code e1;
std::error_code e2(std::operation_not_supported); std::error_code e2(std::posix_error::operation_not_supported);
VERIFY( !(e1 != e1) ); VERIFY( !(e1 != e1) );
VERIFY( e1 != e2 ); VERIFY( e1 != e2 );
......
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
#include <stdexcept>
#include <system_error>
// libstdc++/34538
int main()
{
throw std::invalid_argument("foo");
}
...@@ -28,127 +28,127 @@ namespace gnu ...@@ -28,127 +28,127 @@ namespace gnu
using std::error_category; using std::error_category;
using std::system_category; using std::system_category;
using std::posix_errno; using std::posix_error::posix_errno;
using std::address_family_not_supported; using std::posix_error::address_family_not_supported;
using std::address_in_use; using std::posix_error::address_in_use;
using std::address_not_available; using std::posix_error::address_not_available;
using std::already_connected; using std::posix_error::already_connected;
using std::argument_list_too_long; using std::posix_error::argument_list_too_long;
using std::argument_out_of_domain; using std::posix_error::argument_out_of_domain;
using std:: bad_address; using std::posix_error::bad_address;
using std::bad_file_descriptor; using std::posix_error::bad_file_descriptor;
#ifdef _GLIBCXX_HAVE_EBADMSG #ifdef _GLIBCXX_HAVE_EBADMSG
using std::bad_message; using std::posix_error::bad_message;
#endif #endif
using std::broken_pipe; using std::posix_error::broken_pipe;
using std::connection_aborted; using std::posix_error::connection_aborted;
using std::connection_already_in_progress; using std::posix_error::connection_already_in_progress;
using std::connection_refused; using std::posix_error::connection_refused;
using std::connection_reset; using std::posix_error::connection_reset;
using std::cross_device_link; using std::posix_error::cross_device_link;
using std::destination_address_required; using std::posix_error::destination_address_required;
using std::device_or_resource_busy; using std::posix_error::device_or_resource_busy;
using std::directory_not_empty; using std::posix_error::directory_not_empty;
using std::executable_format_error; using std::posix_error::executable_format_error;
using std::file_exists; using std::posix_error::file_exists;
using std::file_too_large; using std::posix_error::file_too_large;
using std::filename_too_long; using std::posix_error::filename_too_long;
using std::function_not_supported; using std::posix_error::function_not_supported;
using std::host_unreachable; using std::posix_error::host_unreachable;
using std::identifier_removed; using std::posix_error::identifier_removed;
using std::illegal_byte_sequence; using std::posix_error::illegal_byte_sequence;
using std::inappropriate_io_control_operation; using std::posix_error::inappropriate_io_control_operation;
using std::interrupted; using std::posix_error::interrupted;
using std::invalid_argument; using std::posix_error::invalid_argument;
using std::invalid_seek; using std::posix_error::invalid_seek;
using std::io_error; using std::posix_error::io_error;
using std::is_a_directory; using std::posix_error::is_a_directory;
using std::message_size; using std::posix_error::message_size;
using std::network_down; using std::posix_error::network_down;
using std::network_reset; using std::posix_error::network_reset;
using std::network_unreachable; using std::posix_error::network_unreachable;
using std::no_buffer_space; using std::posix_error::no_buffer_space;
using std::no_child_process; using std::posix_error::no_child_process;
#ifdef _GLIBCXX_HAVE_ENOLINK #ifdef _GLIBCXX_HAVE_ENOLINK
using std::no_link; using std::posix_error::no_link;
#endif #endif
using std::no_lock_available; using std::posix_error::no_lock_available;
#ifdef _GLIBCXX_HAVE_ENODATA #ifdef _GLIBCXX_HAVE_ENODATA
using std::no_message_available; using std::posix_error::no_message_available;
#endif #endif
using std::no_message; using std::posix_error::no_message;
using std::no_posix_equivalent; using std::posix_error::no_posix_equivalent;
using std::no_protocol_option; using std::posix_error::no_protocol_option;
using std::no_space_on_device; using std::posix_error::no_space_on_device;
#ifdef _GLIBCXX_HAVE_ENOSR #ifdef _GLIBCXX_HAVE_ENOSR
using std::no_stream_resources; using std::posix_error::no_stream_resources;
#endif #endif
using std::no_such_device_or_address; using std::posix_error::no_such_device_or_address;
using std::no_such_device; using std::posix_error::no_such_device;
using std::no_such_file_or_directory; using std::posix_error::no_such_file_or_directory;
using std::no_such_process; using std::posix_error::no_such_process;
using std::not_a_directory; using std::posix_error::not_a_directory;
using std::not_a_socket; using std::posix_error::not_a_socket;
#ifdef _GLIBCXX_HAVE_ENOSTR #ifdef _GLIBCXX_HAVE_ENOSTR
using std::not_a_stream; using std::posix_error::not_a_stream;
#endif #endif
using std::not_connected; using std::posix_error::not_connected;
using std::not_enough_memory; using std::posix_error::not_enough_memory;
using std::not_supported; using std::posix_error::not_supported;
#ifdef _GLIBCXX_HAVE_ECANCELED #ifdef _GLIBCXX_HAVE_ECANCELED
using std::operation_canceled; using std::posix_error::operation_canceled;
#endif #endif
using std::operation_in_progress; using std::posix_error::operation_in_progress;
using std::operation_not_permitted; using std::posix_error::operation_not_permitted;
using std::operation_not_supported; using std::posix_error::operation_not_supported;
using std::operation_would_block; using std::posix_error::operation_would_block;
#ifdef _GLIBCXX_HAVE_EOWNERDEAD #ifdef _GLIBCXX_HAVE_EOWNERDEAD
using std::owner_dead; using std::posix_error::owner_dead;
#endif #endif
using std::permission_denied; using std::posix_error::permission_denied;
#ifdef _GLIBCXX_HAVE_EPROTO #ifdef _GLIBCXX_HAVE_EPROTO
using std::protocol_error; using std::posix_error::protocol_error;
#endif #endif
using std::protocol_not_supported; using std::posix_error::protocol_not_supported;
using std::read_only_file_system; using std::posix_error::read_only_file_system;
using std::resource_deadlock_would_occur; using std::posix_error::resource_deadlock_would_occur;
using std::resource_unavailable_try_again; using std::posix_error::resource_unavailable_try_again;
using std::result_out_of_range; using std::posix_error::result_out_of_range;
#ifdef _GLIBCXX_HAVE_ENOTRECOVERABLE #ifdef _GLIBCXX_HAVE_ENOTRECOVERABLE
using std::state_not_recoverable; using std::posix_error::state_not_recoverable;
#endif #endif
#ifdef _GLIBCXX_HAVE_ETIME #ifdef _GLIBCXX_HAVE_ETIME
using std::stream_timeout; using std::posix_error::stream_timeout;
#endif #endif
using std::text_file_busy; using std::posix_error::text_file_busy;
using std::timed_out; using std::posix_error::timed_out;
using std::too_many_files_open_in_system; using std::posix_error::too_many_files_open_in_system;
using std::too_many_files_open; using std::posix_error::too_many_files_open;
using std::too_many_links; using std::posix_error::too_many_links;
using std::too_many_synbolic_link_levels; using std::posix_error::too_many_synbolic_link_levels;
#ifdef _GLIBCXX_HAVE_EOVERFLOW #ifdef _GLIBCXX_HAVE_EOVERFLOW
using std::value_too_large; using std::posix_error::value_too_large;
#endif #endif
using std::wrong_protocol_type; using std::posix_error::wrong_protocol_type;
} }
...@@ -27,7 +27,7 @@ int main() ...@@ -27,7 +27,7 @@ int main()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
const std::string s("too late: boulangerie out of pain au raisin"); const std::string s("too late: boulangerie out of pain au raisin");
const std::error_code e(std::operation_not_supported); const std::error_code e(std::posix_error::operation_not_supported);
// 1 // 1
{ {
......
...@@ -32,7 +32,7 @@ void test01() ...@@ -32,7 +32,7 @@ void test01()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::string s("after nine thirty, this request cannot be met"); std::string s("after nine thirty, this request cannot be met");
std::system_error obj = std::system_error(s, std::invalid_argument); std::system_error obj = std::system_error(s, std::posix_error::invalid_argument);
std::string s1(obj.what()); std::string s1(obj.what());
std::string s2(obj.what()); std::string s2(obj.what());
VERIFY( s1 == s2 ); VERIFY( s1 == s2 );
......
...@@ -32,7 +32,7 @@ void test() ...@@ -32,7 +32,7 @@ void test()
char buf[64]; char buf[64];
error_code e1; error_code e1;
error_code e2(bad_address); error_code e2(posix_error::bad_address);
string s, s1, s2; string s, s1, s2;
{ {
......
...@@ -33,7 +33,7 @@ void test() ...@@ -33,7 +33,7 @@ void test()
wchar_t buf[64]; wchar_t buf[64];
error_code e1; error_code e1;
error_code e2(bad_address); error_code e2(posix_error::bad_address);
wstring s, s1, s2; wstring s, s1, s2;
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment