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
This commit is contained in:
Paolo Carlini 2007-12-27 12:59:01 +00:00 committed by Paolo Carlini
parent ceac3d59ad
commit 83588991c1
18 changed files with 170 additions and 109 deletions

View file

@ -1,3 +1,32 @@
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>
* testsuite/25_algorithms/copy/34595.C: Rename to 34595.cc.

View file

@ -40,6 +40,8 @@
_GLIBCXX_BEGIN_NAMESPACE(std)
namespace posix_error
{
enum posix_errno
{
address_family_not_supported = EAFNOSUPPORT,
@ -159,6 +161,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
wrong_protocol_type = EPROTOTYPE,
no_posix_equivalent = 1L << 16
};
}
_GLIBCXX_END_NAMESPACE

View file

@ -65,7 +65,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
operator!=(const error_category& __other) const
{ return this != &__other; }
virtual posix_errno
virtual posix_error::posix_errno
posix(int __v) const = 0;
virtual const string&
@ -86,7 +86,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
error_code(int __v, const error_category& __cat) throw()
: _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) { }
void
@ -109,7 +109,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
const error_category&
category() const { return *_M_cat; }
posix_errno
posix_error::posix_errno
posix() const throw() { return this->category().posix(_M_value); }
// Safe bool idiom.

View file

@ -44,7 +44,7 @@ namespace
return category;
}
virtual std::posix_errno
virtual std::posix_error::posix_errno
posix(int __v) const
{
#ifdef _GLIBCXX_HAVE_SYS_NERR
@ -53,9 +53,9 @@ namespace
const int last_errorno = std::numeric_limits<int>::max();
#endif
if (__v > 0 && __v <= last_errorno)
return std::posix_errno(__v);
return std::posix_error::posix_errno(__v);
else
return std::no_posix_equivalent;
return std::posix_error::no_posix_equivalent;
}
};

View file

@ -27,9 +27,9 @@ namespace __gnu_test
{
struct test_category : public std::error_category
{
virtual std::posix_errno
virtual std::posix_error::posix_errno
posix(int __v) const
{ return std::posix_errno(__v); }
{ return std::posix_error::posix_errno(__v); }
virtual const std::string&
name() const

View file

@ -26,9 +26,9 @@ namespace __gnu_test
{
struct test_category : public std::error_category
{
virtual std::posix_errno
virtual std::posix_error::posix_errno
posix(int __v) const
{ return std::posix_errno(__v); }
{ return std::posix_error::posix_errno(__v); }
virtual const std::string&
name() const

View file

@ -26,9 +26,9 @@ namespace __gnu_test
{
struct test_category : public std::error_category
{
virtual std::posix_errno
virtual std::posix_error::posix_errno
posix(int __v) const
{ return std::posix_errno(__v); }
{ return std::posix_error::posix_errno(__v); }
virtual const std::string&
name() const

View file

@ -26,9 +26,9 @@ namespace __gnu_test
{
struct test_category : public std::error_category
{
virtual std::posix_errno
virtual std::posix_error::posix_errno
posix(int __v) const
{ return std::posix_errno(__v); }
{ return std::posix_error::posix_errno(__v); }
virtual const std::string&
name() const

View file

@ -26,9 +26,9 @@ namespace __gnu_test
{
struct test_category : public std::error_category
{
virtual std::posix_errno
virtual std::posix_error::posix_errno
posix(int __v) const
{ return std::posix_errno(__v); }
{ return std::posix_error::posix_errno(__v); }
virtual const std::string&
name() const
@ -55,8 +55,8 @@ int main()
VERIFY( e2.category() == cat );
// 3
std::error_code e3(std::operation_not_supported);
VERIFY( e3.value() == int(std::operation_not_supported) );
std::error_code e3(std::posix_error::operation_not_supported);
VERIFY( e3.value() == int(std::posix_error::operation_not_supported) );
VERIFY( e3.category() == std::system_category );
return 0;

View file

@ -35,7 +35,7 @@ int main()
}
// 2
std::error_code e2(std::operation_not_supported);
std::error_code e2(std::posix_error::operation_not_supported);
if (e2)
{
VERIFY( true );

View file

@ -26,9 +26,9 @@ namespace __gnu_test
{
struct test_category : public std::error_category
{
virtual std::posix_errno
virtual std::posix_error::posix_errno
posix(int __v) const
{ return std::posix_errno(__v); }
{ return std::posix_error::posix_errno(__v); }
virtual const std::string&
name() const
@ -45,7 +45,7 @@ int main()
bool test __attribute__((unused)) = true;
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 == e2) );

View file

@ -26,9 +26,9 @@ namespace __gnu_test
{
struct test_category : public std::error_category
{
virtual std::posix_errno
virtual std::posix_error::posix_errno
posix(int __v) const
{ return std::posix_errno(__v); }
{ return std::posix_error::posix_errno(__v); }
virtual const std::string&
name() const
@ -45,7 +45,7 @@ int main()
bool test __attribute__((unused)) = true;
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 != e2 );

View file

@ -0,0 +1,29 @@
// { 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");
}

View file

@ -28,127 +28,127 @@ namespace gnu
using std::error_category;
using std::system_category;
using std::posix_errno;
using std::address_family_not_supported;
using std::address_in_use;
using std::address_not_available;
using std::already_connected;
using std::argument_list_too_long;
using std::argument_out_of_domain;
using std:: bad_address;
using std::bad_file_descriptor;
using std::posix_error::posix_errno;
using std::posix_error::address_family_not_supported;
using std::posix_error::address_in_use;
using std::posix_error::address_not_available;
using std::posix_error::already_connected;
using std::posix_error::argument_list_too_long;
using std::posix_error::argument_out_of_domain;
using std::posix_error::bad_address;
using std::posix_error::bad_file_descriptor;
#ifdef _GLIBCXX_HAVE_EBADMSG
using std::bad_message;
using std::posix_error::bad_message;
#endif
using std::broken_pipe;
using std::connection_aborted;
using std::connection_already_in_progress;
using std::connection_refused;
using std::connection_reset;
using std::cross_device_link;
using std::destination_address_required;
using std::device_or_resource_busy;
using std::directory_not_empty;
using std::executable_format_error;
using std::file_exists;
using std::file_too_large;
using std::filename_too_long;
using std::function_not_supported;
using std::host_unreachable;
using std::identifier_removed;
using std::illegal_byte_sequence;
using std::inappropriate_io_control_operation;
using std::interrupted;
using std::invalid_argument;
using std::invalid_seek;
using std::io_error;
using std::is_a_directory;
using std::message_size;
using std::network_down;
using std::network_reset;
using std::network_unreachable;
using std::no_buffer_space;
using std::no_child_process;
using std::posix_error::broken_pipe;
using std::posix_error::connection_aborted;
using std::posix_error::connection_already_in_progress;
using std::posix_error::connection_refused;
using std::posix_error::connection_reset;
using std::posix_error::cross_device_link;
using std::posix_error::destination_address_required;
using std::posix_error::device_or_resource_busy;
using std::posix_error::directory_not_empty;
using std::posix_error::executable_format_error;
using std::posix_error::file_exists;
using std::posix_error::file_too_large;
using std::posix_error::filename_too_long;
using std::posix_error::function_not_supported;
using std::posix_error::host_unreachable;
using std::posix_error::identifier_removed;
using std::posix_error::illegal_byte_sequence;
using std::posix_error::inappropriate_io_control_operation;
using std::posix_error::interrupted;
using std::posix_error::invalid_argument;
using std::posix_error::invalid_seek;
using std::posix_error::io_error;
using std::posix_error::is_a_directory;
using std::posix_error::message_size;
using std::posix_error::network_down;
using std::posix_error::network_reset;
using std::posix_error::network_unreachable;
using std::posix_error::no_buffer_space;
using std::posix_error::no_child_process;
#ifdef _GLIBCXX_HAVE_ENOLINK
using std::no_link;
using std::posix_error::no_link;
#endif
using std::no_lock_available;
using std::posix_error::no_lock_available;
#ifdef _GLIBCXX_HAVE_ENODATA
using std::no_message_available;
using std::posix_error::no_message_available;
#endif
using std::no_message;
using std::no_posix_equivalent;
using std::no_protocol_option;
using std::no_space_on_device;
using std::posix_error::no_message;
using std::posix_error::no_posix_equivalent;
using std::posix_error::no_protocol_option;
using std::posix_error::no_space_on_device;
#ifdef _GLIBCXX_HAVE_ENOSR
using std::no_stream_resources;
using std::posix_error::no_stream_resources;
#endif
using std::no_such_device_or_address;
using std::no_such_device;
using std::no_such_file_or_directory;
using std::no_such_process;
using std::not_a_directory;
using std::not_a_socket;
using std::posix_error::no_such_device_or_address;
using std::posix_error::no_such_device;
using std::posix_error::no_such_file_or_directory;
using std::posix_error::no_such_process;
using std::posix_error::not_a_directory;
using std::posix_error::not_a_socket;
#ifdef _GLIBCXX_HAVE_ENOSTR
using std::not_a_stream;
using std::posix_error::not_a_stream;
#endif
using std::not_connected;
using std::not_enough_memory;
using std::not_supported;
using std::posix_error::not_connected;
using std::posix_error::not_enough_memory;
using std::posix_error::not_supported;
#ifdef _GLIBCXX_HAVE_ECANCELED
using std::operation_canceled;
using std::posix_error::operation_canceled;
#endif
using std::operation_in_progress;
using std::operation_not_permitted;
using std::operation_not_supported;
using std::operation_would_block;
using std::posix_error::operation_in_progress;
using std::posix_error::operation_not_permitted;
using std::posix_error::operation_not_supported;
using std::posix_error::operation_would_block;
#ifdef _GLIBCXX_HAVE_EOWNERDEAD
using std::owner_dead;
using std::posix_error::owner_dead;
#endif
using std::permission_denied;
using std::posix_error::permission_denied;
#ifdef _GLIBCXX_HAVE_EPROTO
using std::protocol_error;
using std::posix_error::protocol_error;
#endif
using std::protocol_not_supported;
using std::read_only_file_system;
using std::resource_deadlock_would_occur;
using std::resource_unavailable_try_again;
using std::result_out_of_range;
using std::posix_error::protocol_not_supported;
using std::posix_error::read_only_file_system;
using std::posix_error::resource_deadlock_would_occur;
using std::posix_error::resource_unavailable_try_again;
using std::posix_error::result_out_of_range;
#ifdef _GLIBCXX_HAVE_ENOTRECOVERABLE
using std::state_not_recoverable;
using std::posix_error::state_not_recoverable;
#endif
#ifdef _GLIBCXX_HAVE_ETIME
using std::stream_timeout;
using std::posix_error::stream_timeout;
#endif
using std::text_file_busy;
using std::timed_out;
using std::too_many_files_open_in_system;
using std::too_many_files_open;
using std::too_many_links;
using std::too_many_synbolic_link_levels;
using std::posix_error::text_file_busy;
using std::posix_error::timed_out;
using std::posix_error::too_many_files_open_in_system;
using std::posix_error::too_many_files_open;
using std::posix_error::too_many_links;
using std::posix_error::too_many_synbolic_link_levels;
#ifdef _GLIBCXX_HAVE_EOVERFLOW
using std::value_too_large;
using std::posix_error::value_too_large;
#endif
using std::wrong_protocol_type;
using std::posix_error::wrong_protocol_type;
}

View file

@ -27,7 +27,7 @@ int main()
{
bool test __attribute__((unused)) = true;
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
{

View file

@ -32,7 +32,7 @@ void test01()
bool test __attribute__((unused)) = true;
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 s2(obj.what());
VERIFY( s1 == s2 );

View file

@ -32,7 +32,7 @@ void test()
char buf[64];
error_code e1;
error_code e2(bad_address);
error_code e2(posix_error::bad_address);
string s, s1, s2;
{

View file

@ -33,7 +33,7 @@ void test()
wchar_t buf[64];
error_code e1;
error_code e2(bad_address);
error_code e2(posix_error::bad_address);
wstring s, s1, s2;
{