mirror of git://gcc.gnu.org/git/gcc.git
system_error (system_error::system_error(error_code), [...]): Fix for what() to return the NBTS recommended in the Note in 19.5.6.2/14.
2010-09-16 Paolo Carlini <paolo.carlini@oracle.com> * include/std/system_error (system_error::system_error(error_code), system_error(error_code, const string&), system_error(int, const error_category&), system_error(int, const error_category&, const string&)): Fix for what() to return the NBTS recommended in the Note in 19.5.6.2/14. * testsuite/19_diagnostics/system_error/cons-1.cc: Adjust. * testsuite/19_diagnostics/system_error/what-1.cc: Likewise. * testsuite/19_diagnostics/system_error/what-2.cc: Likewise. * testsuite/19_diagnostics/system_error/what-big.cc: Likewise. * testsuite/19_diagnostics/system_error/what-3.cc: Likewise. * testsuite/19_diagnostics/system_error/what-4.cc: Tidy includes. From-SVN: r164339
This commit is contained in:
parent
7d58b9e77a
commit
b5fbd147fe
|
@ -1,3 +1,18 @@
|
||||||
|
2010-09-16 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
|
* include/std/system_error (system_error::system_error(error_code),
|
||||||
|
system_error(error_code, const string&), system_error(int, const
|
||||||
|
error_category&), system_error(int, const error_category&,
|
||||||
|
const string&)): Fix for what() to return the NBTS recommended in
|
||||||
|
the Note in 19.5.6.2/14.
|
||||||
|
* testsuite/19_diagnostics/system_error/cons-1.cc: Adjust.
|
||||||
|
* testsuite/19_diagnostics/system_error/what-1.cc: Likewise.
|
||||||
|
* testsuite/19_diagnostics/system_error/what-2.cc: Likewise.
|
||||||
|
* testsuite/19_diagnostics/system_error/what-big.cc: Likewise.
|
||||||
|
* testsuite/19_diagnostics/system_error/what-3.cc: Likewise.
|
||||||
|
|
||||||
|
* testsuite/19_diagnostics/system_error/what-4.cc: Tidy includes.
|
||||||
|
|
||||||
2010-09-16 Paolo Carlini <paolo.carlini@oracle.com>
|
2010-09-16 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
* include/std/complex (complex<float>::operator=(float),
|
* include/std/complex (complex<float>::operator=(float),
|
||||||
|
|
|
@ -311,26 +311,29 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
system_error(error_code __ec = error_code())
|
system_error(error_code __ec = error_code())
|
||||||
: runtime_error(""), _M_code(__ec) { }
|
: runtime_error(__ec.message()), _M_code(__ec) { }
|
||||||
|
|
||||||
system_error(error_code __ec, const string& __what)
|
system_error(error_code __ec, const string& __what)
|
||||||
: runtime_error(__what), _M_code(__ec) { }
|
: runtime_error(__what + ": " + __ec.message()), _M_code(__ec) { }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: Add const char* ctors to all exceptions.
|
* TODO: Add const char* ctors to all exceptions.
|
||||||
*
|
*
|
||||||
* system_error(error_code __ec, const char* __what)
|
* system_error(error_code __ec, const char* __what)
|
||||||
* : runtime_error(__what), _M_code(__ec) { }
|
* : runtime_error(__what + (": " + __ec.message())), _M_code(__ec) { }
|
||||||
*
|
*
|
||||||
* system_error(int __v, const error_category& __ecat, const char* __what)
|
* system_error(int __v, const error_category& __ecat, const char* __what)
|
||||||
* : runtime_error(__what), _M_code(error_code(__v, __ecat)) { }
|
* : runtime_error(__what + (": " + __ec.message())),
|
||||||
|
* _M_code(error_code(__v, __ecat)) { }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
system_error(int __v, const error_category& __ecat)
|
system_error(int __v, const error_category& __ecat)
|
||||||
: runtime_error(""), _M_code(error_code(__v, __ecat)) { }
|
: runtime_error(error_code(__v, __ecat).message()),
|
||||||
|
_M_code(__v, __ecat) { }
|
||||||
|
|
||||||
system_error(int __v, const error_category& __ecat, const string& __what)
|
system_error(int __v, const error_category& __ecat, const string& __what)
|
||||||
: runtime_error(__what), _M_code(error_code(__v, __ecat)) { }
|
: runtime_error(__what + ": " + error_code(__v, __ecat).message()),
|
||||||
|
_M_code(__v, __ecat) { }
|
||||||
|
|
||||||
virtual ~system_error() throw();
|
virtual ~system_error() throw();
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// { dg-options "-std=gnu++0x" }
|
// { dg-options "-std=gnu++0x" }
|
||||||
// 2007-06-05 Benjamin Kosnik <bkoz@redhat.com>
|
// 2007-06-05 Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
|
// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
|
||||||
//
|
//
|
||||||
// This file is part of the GNU ISO C++ Library. This library is free
|
// 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
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
// with this library; see the file COPYING3. If not see
|
// with this library; see the file COPYING3. If not see
|
||||||
// <http://www.gnu.org/licenses/>.
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <cstring>
|
#include <string>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
@ -33,14 +33,14 @@ int main()
|
||||||
{
|
{
|
||||||
std::system_error err1(e, s);
|
std::system_error err1(e, s);
|
||||||
VERIFY( err1.code() == e );
|
VERIFY( err1.code() == e );
|
||||||
VERIFY( std::strcmp(err1.runtime_error::what(), s.c_str()) == 0 );
|
VERIFY( std::string(err1.what()).find(s) != std::string::npos );
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2
|
// 2
|
||||||
{
|
{
|
||||||
std::system_error err2(95, std::system_category(), s);
|
std::system_error err2(95, std::system_category(), s);
|
||||||
VERIFY( err2.code() == std::error_code(95, std::system_category()) );
|
VERIFY( err2.code() == std::error_code(95, std::system_category()) );
|
||||||
VERIFY( std::strcmp(err2.runtime_error::what(), s.c_str()) == 0 );
|
VERIFY( std::string((err2.what(), s)).find(s) != std::string::npos );
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// { dg-options "-std=gnu++0x" }
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
|
||||||
// Copyright (C) 2007, 2008, 2009
|
// Copyright (C) 2007, 2008, 2009, 2010
|
||||||
// Free Software Foundation, Inc.
|
// Free Software Foundation, Inc.
|
||||||
//
|
//
|
||||||
// This file is part of the GNU ISO C++ Library. This library is free
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
#include <cstring>
|
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -39,8 +38,8 @@ void test01()
|
||||||
// 2
|
// 2
|
||||||
system_error obj2(error_code(), s);
|
system_error obj2(error_code(), s);
|
||||||
|
|
||||||
VERIFY( strcmp(obj1.what(), s.data()) == 0 );
|
VERIFY( string(obj1.what()).find(s.data()) != string::npos );
|
||||||
VERIFY( strcmp(obj2.what(), s.data()) == 0 );
|
VERIFY( string(obj2.what()).find(s.data()) != string::npos );
|
||||||
}
|
}
|
||||||
|
|
||||||
void test02()
|
void test02()
|
||||||
|
@ -49,7 +48,7 @@ void test02()
|
||||||
string s("lack of sunlight error");
|
string s("lack of sunlight error");
|
||||||
system_error x(error_code(), s);
|
system_error x(error_code(), s);
|
||||||
|
|
||||||
VERIFY( strcmp(x.what(), s.data()) == 0 );
|
VERIFY( string(x.what()).find(s.data()) != string::npos );
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// { dg-options "-std=gnu++0x" }
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
|
||||||
// Copyright (C) 2007, 2008, 2009
|
// Copyright (C) 2007, 2008, 2009, 2010
|
||||||
// Free Software Foundation, Inc.
|
// Free Software Foundation, Inc.
|
||||||
//
|
//
|
||||||
// This file is part of the GNU ISO C++ Library. This library is free
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
#include <cstring>
|
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
// libstdc++/2089
|
// libstdc++/2089
|
||||||
|
@ -38,7 +37,7 @@ void test03()
|
||||||
try
|
try
|
||||||
{ throw fuzzy_logic(); }
|
{ throw fuzzy_logic(); }
|
||||||
catch(const fuzzy_logic& obj)
|
catch(const fuzzy_logic& obj)
|
||||||
{ VERIFY( std::strcmp("whoa", obj.what()) == 0 ); }
|
{ VERIFY( std::string(obj.what()).find("whoa") != std::string::npos ); }
|
||||||
catch(...)
|
catch(...)
|
||||||
{ VERIFY( false ); }
|
{ VERIFY( false ); }
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
#include <cstring>
|
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
// test copy ctors, assignment operators, and persistence of member string data
|
// test copy ctors, assignment operators, and persistence of member string data
|
||||||
|
@ -52,7 +51,7 @@ void test04()
|
||||||
obj1 = obj2;
|
obj1 = obj2;
|
||||||
}
|
}
|
||||||
allocate_on_stack();
|
allocate_on_stack();
|
||||||
VERIFY( std::strcmp(strlit1, obj1.what()) == 0 );
|
VERIFY( std::string(obj1.what()).find(strlit1) != std::string::npos );
|
||||||
|
|
||||||
// block 02
|
// block 02
|
||||||
{
|
{
|
||||||
|
@ -61,7 +60,7 @@ void test04()
|
||||||
obj1 = obj3;
|
obj1 = obj3;
|
||||||
}
|
}
|
||||||
allocate_on_stack();
|
allocate_on_stack();
|
||||||
VERIFY( std::strcmp(strlit2, obj1.what()) == 0 );
|
VERIFY( std::string(obj1.what()).find(strlit2) != std::string::npos );
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// { dg-options "-std=gnu++0x" }
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
|
||||||
// Copyright (C) 2007, 2008, 2009
|
// Copyright (C) 2007, 2008, 2009, 2010
|
||||||
// Free Software Foundation, Inc.
|
// Free Software Foundation, Inc.
|
||||||
//
|
//
|
||||||
// This file is part of the GNU ISO C++ Library. This library is free
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
// 19.1 Exception classes
|
// 19.1 Exception classes
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// { dg-options "-std=gnu++0x" }
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
|
||||||
// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
|
// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
|
||||||
//
|
//
|
||||||
// This file is part of the GNU ISO C++ Library. This library is free
|
// 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
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
@ -17,7 +17,6 @@
|
||||||
// with this library; see the file COPYING3. If not see
|
// with this library; see the file COPYING3. If not see
|
||||||
// <http://www.gnu.org/licenses/>.
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
|
@ -30,7 +29,7 @@ void test01()
|
||||||
bool test __attribute__((unused)) = true;
|
bool test __attribute__((unused)) = true;
|
||||||
const std::string xxx(10000, 'x');
|
const std::string xxx(10000, 'x');
|
||||||
test_type t(std::error_code(), xxx);
|
test_type t(std::error_code(), xxx);
|
||||||
VERIFY( std::strcmp(t.what(), xxx.c_str()) == 0 );
|
VERIFY( std::string(t.what()).find(xxx) != std::string::npos );
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
|
Loading…
Reference in New Issue