aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVille Voutilainen <ville.voutilainen@gmail.com>2019-01-10 15:14:57 +0200
committerJonathan Wakely <redi@gcc.gnu.org>2019-01-10 13:14:57 +0000
commitc3799b164fac7576ada4cad5a5069cbe911b4849 (patch)
treef84fa45aa7f81f4cb7d7a541bd155b083ede00ec
parente222497dcb808dc0c8e24dcded5b90bac4b59122 (diff)
downloadgcc-c3799b164fac7576ada4cad5a5069cbe911b4849.zip
gcc-c3799b164fac7576ada4cad5a5069cbe911b4849.tar.gz
gcc-c3799b164fac7576ada4cad5a5069cbe911b4849.tar.bz2
Implement LWG 2221: formatted output operator for nullptr
2019-01-10 Ville Voutilainen <ville.voutilainen@gmail.com> Jonathan Wakely <jwakely@redhat.com> Implement LWG 2221 * config/abi/pre/gnu.ver (GLIBCXX_3.4): Tighten patterns. (GLIBCXX_3.4.26): Add new exports. * include/Makefile.am: Add ostream-inst.cc. Move string-inst.cc to correct list of sources. * include/Makefile.in: Regenerate. * include/std/ostream (operator<<(nullptr_t)): New member function. * src/c++17/ostream-inst.cc: New file. * testsuite/27_io/basic_ostream/inserters_other/char/lwg2221.cc: New test. Co-Authored-By: Jonathan Wakely <jwakely@redhat.com> From-SVN: r267808
-rw-r--r--libstdc++-v3/ChangeLog14
-rw-r--r--libstdc++-v3/config/abi/pre/gnu.ver8
-rw-r--r--libstdc++-v3/include/std/ostream6
-rw-r--r--libstdc++-v3/src/c++17/Makefile.am3
-rw-r--r--libstdc++-v3/src/c++17/Makefile.in8
-rw-r--r--libstdc++-v3/src/c++17/ostream-inst.cc42
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/lwg2221.cc9
7 files changed, 84 insertions, 6 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 6bc27c5..fdaf477 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,17 @@
+2019-01-10 Ville Voutilainen <ville.voutilainen@gmail.com>
+ Jonathan Wakely <jwakely@redhat.com>
+
+ Implement LWG 2221
+ * config/abi/pre/gnu.ver (GLIBCXX_3.4): Tighten patterns.
+ (GLIBCXX_3.4.26): Add new exports.
+ * include/Makefile.am: Add ostream-inst.cc. Move string-inst.cc to
+ correct list of sources.
+ * include/Makefile.in: Regenerate.
+ * include/std/ostream (operator<<(nullptr_t)): New member function.
+ * src/c++17/ostream-inst.cc: New file.
+ * testsuite/27_io/basic_ostream/inserters_other/char/lwg2221.cc: New
+ test.
+
2019-01-10 Jonathan Wakely <jwakely@redhat.com>
* testsuite/util/testsuite_fs.h (nonexistent_path): Include name
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index 92af1ae..788c2e0 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -495,7 +495,7 @@ GLIBCXX_3.4 {
_ZNSo8_M_writeEPKc[ilx];
_ZNSo3put*;
_ZNSo[5-9][a-z]*;
- _ZNSolsE*[^g];
+ _ZNSolsE*[^Dg];
# std::basic_ostream<wchar_t>
_ZNSt13basic_ostreamIwSt11char_traitsIwEEC[12]Ev;
@@ -509,7 +509,7 @@ GLIBCXX_3.4 {
_ZNSt13basic_ostreamIwSt11char_traitsIwEE5writeEPKw*;
_ZNSt13basic_ostreamIwSt11char_traitsIwEE6sentry*;
_ZNSt13basic_ostreamIwSt11char_traitsIwEE8_M_writeEPKw[ilx];
- _ZNSt13basic_ostreamIwSt11char_traitsIwEElsE*[^g];
+ _ZNSt13basic_ostreamIwSt11char_traitsIwEElsE*[^Dg];
# std::ostream operators and inserters
_ZSt4end[ls]I[cw]St11char_traitsI[cw]EERSt13basic_ostream*;
@@ -2223,6 +2223,10 @@ GLIBCXX_3.4.26 {
_ZNSt10filesystem7__cxx1128recursive_directory_iteratoraSEOS1_;
_ZNSt10filesystem7__cxx1128recursive_directory_iteratorppEv;
+ # basic_ostream::operator<<(nullptr_t)
+ _ZNSolsEDn;
+ _ZNSt13basic_ostreamIwSt11char_traitsIwEElsEDn;
+
} GLIBCXX_3.4.25;
# Symbols in the support library (libsupc++) have their own tag.
diff --git a/libstdc++-v3/include/std/ostream b/libstdc++-v3/include/std/ostream
index 50c99b2..2541d97 100644
--- a/libstdc++-v3/include/std/ostream
+++ b/libstdc++-v3/include/std/ostream
@@ -245,6 +245,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(const void* __p)
{ return _M_insert(__p); }
+#if __cplusplus >= 201703L
+ __ostream_type&
+ operator<<(nullptr_t)
+ { return *this << "nullptr"; }
+#endif
+
/**
* @brief Extracting from another streambuf.
* @param __sb A pointer to a streambuf
diff --git a/libstdc++-v3/src/c++17/Makefile.am b/libstdc++-v3/src/c++17/Makefile.am
index 4200f7f..1a00770 100644
--- a/libstdc++-v3/src/c++17/Makefile.am
+++ b/libstdc++-v3/src/c++17/Makefile.am
@@ -41,6 +41,8 @@ endif
if ENABLE_EXTERN_TEMPLATE
# XTEMPLATE_FLAGS = -fno-implicit-templates
inst_sources = \
+ ostream-inst.cc \
+ string-inst.cc \
$(extra_string_inst_sources)
else
# XTEMPLATE_FLAGS =
@@ -52,7 +54,6 @@ sources = \
fs_ops.cc \
fs_path.cc \
memory_resource.cc \
- string-inst.cc \
$(extra_fs_sources)
vpath % $(top_srcdir)/src/c++17
diff --git a/libstdc++-v3/src/c++17/Makefile.in b/libstdc++-v3/src/c++17/Makefile.in
index a402d13..639cb5c 100644
--- a/libstdc++-v3/src/c++17/Makefile.in
+++ b/libstdc++-v3/src/c++17/Makefile.in
@@ -124,9 +124,10 @@ libc__17convenience_la_LIBADD =
@ENABLE_DUAL_ABI_TRUE@am__objects_1 = cow-fs_dir.lo cow-fs_ops.lo \
@ENABLE_DUAL_ABI_TRUE@ cow-fs_path.lo
am__objects_2 = fs_dir.lo fs_ops.lo fs_path.lo memory_resource.lo \
- string-inst.lo $(am__objects_1)
+ $(am__objects_1)
@ENABLE_DUAL_ABI_TRUE@am__objects_3 = cow-string-inst.lo
-@ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_4 = $(am__objects_3)
+@ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_4 = ostream-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@ string-inst.lo $(am__objects_3)
am_libc__17convenience_la_OBJECTS = $(am__objects_2) $(am__objects_4)
libc__17convenience_la_OBJECTS = $(am_libc__17convenience_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
@@ -426,6 +427,8 @@ headers =
# XTEMPLATE_FLAGS = -fno-implicit-templates
@ENABLE_EXTERN_TEMPLATE_TRUE@inst_sources = \
+@ENABLE_EXTERN_TEMPLATE_TRUE@ ostream-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@ string-inst.cc \
@ENABLE_EXTERN_TEMPLATE_TRUE@ $(extra_string_inst_sources)
sources = \
@@ -433,7 +436,6 @@ sources = \
fs_ops.cc \
fs_path.cc \
memory_resource.cc \
- string-inst.cc \
$(extra_fs_sources)
libc__17convenience_la_SOURCES = $(sources) $(inst_sources)
diff --git a/libstdc++-v3/src/c++17/ostream-inst.cc b/libstdc++-v3/src/c++17/ostream-inst.cc
new file mode 100644
index 0000000..b2fbafc
--- /dev/null
+++ b/libstdc++-v3/src/c++17/ostream-inst.cc
@@ -0,0 +1,42 @@
+// std::ostream instantiations for C++17 -*- C++ -*-
+
+// Copyright (C) 2019 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:2017 28 Input/output library
+//
+
+#include <ostream>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+template basic_ostream<char>& basic_ostream<char>::operator<<(nullptr_t);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+template basic_ostream<wchar_t>& basic_ostream<wchar_t>::operator<<(nullptr_t);
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/lwg2221.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/lwg2221.cc
new file mode 100644
index 0000000..b4ff52b
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/lwg2221.cc
@@ -0,0 +1,9 @@
+// { dg-options "-std=gnu++17 -fno-inline" }
+// { dg-do link }
+
+#include <iostream>
+
+int main()
+{
+ std::cout << nullptr << std::endl;
+}