aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/src
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2014-11-14 12:17:57 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2014-11-14 12:17:57 +0000
commita5dde6ddac80b3a6e4cb3d988c5c449108411704 (patch)
tree7608d5f540586abdbb3a9159b02a5def19043a66 /libstdc++-v3/src
parent78d7f09fff5d074f6c0917559d005e9a2a156be8 (diff)
downloadgcc-a5dde6ddac80b3a6e4cb3d988c5c449108411704.zip
gcc-a5dde6ddac80b3a6e4cb3d988c5c449108411704.tar.gz
gcc-a5dde6ddac80b3a6e4cb3d988c5c449108411704.tar.bz2
Define C++11 version of std::ios_base::failure.
* config/abi/pre/gnu.ver: Add new exports. * include/bits/ios_base.h (ios_base::failure): New definition using abi_tag. (io_errc, make_error_code, make_error_category, iostream_category): Define. * include/std/system_error (system_error): Add char* constructors. * src/c++11/Makefile.am: Add new file. * src/c++11/Makefile.in: Regenerate. * src/c++11/cxx11-ios_failure.cc: New file. * src/c++98/ios_failure.cc: Compile old definition without abi_tag. * testsuite/27_io/ios_base/failure/cxx11.cc: New. * testsuite/27_io/ios_base/failure/what-1.cc: Allow string returned by ios_base::failure::what() to contain additional data. * testsuite/27_io/ios_base/failure/what-2.cc: Likewise.. * testsuite/27_io/ios_base/failure/what-3.cc: Likewise.. * testsuite/27_io/ios_base/failure/what-big.cc: Likewise.. From-SVN: r217559
Diffstat (limited to 'libstdc++-v3/src')
-rw-r--r--libstdc++-v3/src/c++11/Makefile.am8
-rw-r--r--libstdc++-v3/src/c++11/Makefile.in16
-rw-r--r--libstdc++-v3/src/c++11/cxx11-ios_failure.cc89
-rw-r--r--libstdc++-v3/src/c++98/ios_failure.cc3
4 files changed, 110 insertions, 6 deletions
diff --git a/libstdc++-v3/src/c++11/Makefile.am b/libstdc++-v3/src/c++11/Makefile.am
index c8507ce..71306db 100644
--- a/libstdc++-v3/src/c++11/Makefile.am
+++ b/libstdc++-v3/src/c++11/Makefile.am
@@ -39,6 +39,13 @@ ctype_configure_char.cc: ${glibcxx_srcdir}/$(OS_INC_SRCDIR)/ctype_configure_char
ctype_members.cc: ${glibcxx_srcdir}/$(CCTYPE_CC)
$(LN_S) ${glibcxx_srcdir}/$(CCTYPE_CC) . || true
+if ENABLE_CXX11_ABI
+cxx11_abi_sources = \
+ cxx11-ios_failure.cc
+else
+cxx11_abi_sources =
+endif
+
sources = \
chrono.cc \
condition_variable.cc \
@@ -59,6 +66,7 @@ sources = \
snprintf_lite.cc \
system_error.cc \
thread.cc \
+ ${cxx11_abi_sources} \
${host_sources}
if ENABLE_EXTERN_TEMPLATE
diff --git a/libstdc++-v3/src/c++11/Makefile.in b/libstdc++-v3/src/c++11/Makefile.in
index fd3e780..dd9e110 100644
--- a/libstdc++-v3/src/c++11/Makefile.in
+++ b/libstdc++-v3/src/c++11/Makefile.in
@@ -67,19 +67,20 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libc__11convenience_la_LIBADD =
-am__objects_1 = ctype_configure_char.lo ctype_members.lo
-am__objects_2 = chrono.lo condition_variable.lo ctype.lo debug.lo \
+@ENABLE_CXX11_ABI_TRUE@am__objects_1 = cxx11-ios_failure.lo
+am__objects_2 = ctype_configure_char.lo ctype_members.lo
+am__objects_3 = chrono.lo condition_variable.lo ctype.lo debug.lo \
functexcept.lo functional.lo future.lo hash_c++0x.lo \
hashtable_c++0x.lo ios.lo limits.lo mutex.lo placeholders.lo \
random.lo regex.lo shared_ptr.lo snprintf_lite.lo \
- system_error.lo thread.lo $(am__objects_1)
-@ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_3 = ext11-inst.lo \
+ system_error.lo thread.lo $(am__objects_1) $(am__objects_2)
+@ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_4 = ext11-inst.lo \
@ENABLE_EXTERN_TEMPLATE_TRUE@ fstream-inst.lo ios-inst.lo \
@ENABLE_EXTERN_TEMPLATE_TRUE@ iostream-inst.lo istream-inst.lo \
@ENABLE_EXTERN_TEMPLATE_TRUE@ ostream-inst.lo sstream-inst.lo \
@ENABLE_EXTERN_TEMPLATE_TRUE@ streambuf-inst.lo string-inst.lo \
@ENABLE_EXTERN_TEMPLATE_TRUE@ wstring-inst.lo
-am_libc__11convenience_la_OBJECTS = $(am__objects_2) $(am__objects_3)
+am_libc__11convenience_la_OBJECTS = $(am__objects_3) $(am__objects_4)
libc__11convenience_la_OBJECTS = $(am_libc__11convenience_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp =
@@ -322,6 +323,10 @@ host_sources = \
ctype_configure_char.cc \
ctype_members.cc
+@ENABLE_CXX11_ABI_FALSE@cxx11_abi_sources =
+@ENABLE_CXX11_ABI_TRUE@cxx11_abi_sources = \
+@ENABLE_CXX11_ABI_TRUE@ cxx11-ios_failure.cc
+
sources = \
chrono.cc \
condition_variable.cc \
@@ -342,6 +347,7 @@ sources = \
snprintf_lite.cc \
system_error.cc \
thread.cc \
+ ${cxx11_abi_sources} \
${host_sources}
# XTEMPLATE_FLAGS =
diff --git a/libstdc++-v3/src/c++11/cxx11-ios_failure.cc b/libstdc++-v3/src/c++11/cxx11-ios_failure.cc
new file mode 100644
index 0000000..143d70e
--- /dev/null
+++ b/libstdc++-v3/src/c++11/cxx11-ios_failure.cc
@@ -0,0 +1,89 @@
+// Iostreams base classes -*- C++ -*-
+
+// Copyright (C) 2014 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.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+//
+// ISO C++ 14882:2011: 27.5.3.1.1 Class ios_base::failure
+//
+
+#include <ios>
+
+namespace
+{
+ struct io_error_category : std::error_category
+ {
+ virtual const char*
+ name() const noexcept
+ { return "iostream"; }
+
+ virtual std::string message(int __ec) const
+ {
+ std::string __msg;
+ switch (std::io_errc(__ec))
+ {
+ case std::io_errc::stream:
+ __msg = "iostream error";
+ break;
+ default:
+ __msg = "Unknown error";
+ break;
+ }
+ return __msg;
+ }
+ };
+
+ const io_error_category&
+ __io_category_instance() noexcept
+ {
+ static const io_error_category __ec{};
+ return __ec;
+ }
+
+} // namespace
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ const error_category&
+ iostream_category() noexcept
+ { return __io_category_instance(); }
+
+ ios_base::failure::failure(const string& __str)
+ : system_error(io_errc::stream, __str) { }
+
+ ios_base::failure::failure(const string& __str, const error_code& __ec)
+ : system_error(__ec, __str) { }
+
+ ios_base::failure::failure(const char* __str, const error_code& __ec)
+ : system_error(__ec, __str) { }
+
+ ios_base::failure::~failure()
+ { }
+
+ const char*
+ ios_base::failure::what() const throw()
+ { return runtime_error::what(); }
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/libstdc++-v3/src/c++98/ios_failure.cc b/libstdc++-v3/src/c++98/ios_failure.cc
index 9d32e51..0f45178 100644
--- a/libstdc++-v3/src/c++98/ios_failure.cc
+++ b/libstdc++-v3/src/c++98/ios_failure.cc
@@ -23,9 +23,10 @@
// <http://www.gnu.org/licenses/>.
//
-// ISO C++ 14882: 27.4.2.1.1 Class ios_base::failure
+// ISO C++ 14882:1998: 27.4.2.1.1 Class ios_base::failure
//
+#define _GLIBCXX_USE_CXX11_ABI 0
#include <ios>
namespace std _GLIBCXX_VISIBILITY(default)