diff options
Diffstat (limited to 'libstdc++-v3')
68 files changed, 2193 insertions, 226 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 58e7d079b7..3e8f33cf11 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,305 @@ +2016-08-22 Release Manager + + * GCC 6.2.0 released. + +2016-08-06 Jonathan Wakely <jwakely@redhat.com> + + Backport from mainline + 2016-08-05 Jonathan Wakely <jwakely@redhat.com> + + * include/std/functional (function::_Callable): Use lvalue in + result_of expression. + * testsuite/20_util/function/cons/refqual.cc: New test. + + Backport from mainline + 2016-07-22 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/71964 + * include/bits/stl_tree.h (_Rb_tree(_Rb_tree&&)): Move allocator. + * testsuite/23_containers/set/allocator/71964.cc: New test. + + Backport from mainline + 2016-08-02 Jonathan Wakely <jwakely@redhat.com> + + * testsuite/21_strings/basic_string/allocator/wchar_t/copy.cc: + Remove reundant check for _GLIBCXX_USE_WCHAR_T and fix char type. + * testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc: + Likewise. + * testsuite/21_strings/basic_string/allocator/wchar_t/minimal.cc: + Likewise. + * testsuite/21_strings/basic_string/allocator/wchar_t/move.cc: + Likewise. + * testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc: + Likewise. + * testsuite/21_strings/basic_string/allocator/wchar_t/noexcept.cc: + Likewise. + * testsuite/21_strings/basic_string/allocator/wchar_t/swap.cc: + Likewise. + + Backport from mainline + 2016-05-04 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/70940 + * include/experimental/memory_resource + (__resource_adaptor_imp::do_allocate): Do not default-construct + rebound allocator. + (__resource_adaptor_imp::do_deallocate): Likewise. Use + allocator_traits to get pointer type. + (__null_memory_resource::do_allocate): Remove unused parameters. + (__null_memory_resource::do_deallocate): Likewise. + (__null_memory_resource::do_is_equal): Likewise. Add return statement. + * testsuite/experimental/type_erased_allocator/1.cc: Combine with ... + * testsuite/experimental/type_erased_allocator/1_neg.cc: This, and + move to ... + * testsuite/experimental/memory_resource/1.cc: Here. + * testsuite/experimental/memory_resource/null_memory_resource.cc: New. + * testsuite/experimental/memory_resource/resource_adaptor.cc: New. + + Backport from mainline + 2016-08-03 Jonathan Wakely <jwakely@redhat.com> + + * include/bits/allocator.h (__cpp_lib_incomplete_container_elements): + Define feature-test macro. + * include/std/shared_mutex (__cpp_lib_shared_mutex): Uncomment. + * include/std/type_traits (__cpp_lib_logical_traits): Fix value. + + Backport from mainline + 2016-08-03 Jonathan Wakely <jwakely@redhat.com> + + * include/bits/stl_function.h: Remove commented-out macro. + * include/bits/stl_tree.h (__cpp_lib_generic_associative_lookup): + Define feature-test macro. + * testsuite/experimental/feat-cxx14.cc: Add tests for more macros. + + * testsuite/lib/libstdc++.exp (check_v3_target_filesystem_ts): Improve + comments. + + * doc/xml/manual/status_cxx2011.xml: Change "mainline GCC SVN" to + refer to the release series. + * doc/xml/manual/status_cxx2014.xml: Likewise. Update TS status. + * doc/xml/manual/status_cxx2017.xml: Likewise. + * doc/html/manual/status.html: Regenerate. + + * include/experimental/propagate_const (propagate_const::__t): Rename + to _M_t and remove comment. Qualify std::move and std::forward. + * testsuite/experimental/propagate_const/cons/default.cc: Fix test. + +2016-08-02 Jonathan Wakely <jwakely@redhat.com> + + * testsuite/lib/libstdc++.exp (v3-build_support): Add + -fno-lto to additional flags for compiling libtestc++.a objects. + +2016-07-29 Jonathan Wakely <jwakely@redhat.com> + + * doc/xml/manual/abi.xml: Document 6.0.22 library version. + * doc/html/manual/abi.html: Regenerate. + +2016-07-19 Jonathan Wakely <jwakely@redhat.com> + + Backport from mainline + 2016-07-14 Jonathan Wakely <jwakely@redhat.com> + + * include/experimental/functional: Include <parallel/algorithm> in + Parallel Mode. + + Backport from mainline + 2016-07-14 Jonathan Wakely <jwakely@redhat.com> + + * testsuite/experimental/functional/searchers.cc: Include <algorithm> + for std::search. + + PR libstdc++/71856 + * include/bits/c++config (_GLIBCXX_ASSERTIONS): Define to 1 not empty. + * include/parallel/balanced_quicksort.h: Include <unistd.h> for sleep. + * include/parallel/compiletime_settings.h (_GLIBCXX_ASSERTIONS): + Do not define here. + + Backport from mainline + 2016-06-06 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/71320 + * src/filesystem/ops.cc (permissions(const path&, perms, error_code&)): + Add or remove permissions according to perms argument. + * testsuite/experimental/filesystem/operations/permissions.cc: New + test. + +2016-07-06 Ville Voutilainen <ville.voutilainen@gmail.com> + + Implement LWG 2451, optional<T> should 'forward' T's + implicit conversions. + * include/experimental/optional (__is_optional_impl, __is_optional): + New. + (optional()): Make constexpr and default. + (optional(_Up&&), optional(const optional<_Up>&), + optional(optional<_Up>&& __t): New. + (operator=(_Up&&)): Constrain. + (operator=(const optional<_Up>&), operator=(optional<_Up>&&)): New. + * testsuite/experimental/optional/cons/value.cc: + Add tests for the functionality added by LWG 2451. + * testsuite/experimental/optional/cons/value_neg.cc: New. + +2016-07-05 Ville Voutilainen <ville.voutilainen@gmail.com> + + Implement LWG 2509, + any_cast doesn't work with rvalue reference targets and cannot + move with a value target. + * include/experimental/any (any(_ValueType&&)): Constrain and + add an overload that doesn't forward. + (any_cast(any&&)): Constrain and add an overload that moves. + * testsuite/experimental/any/misc/any_cast.cc: Add tests for + the functionality added by LWG 2509. + +2016-07-04 Ville Voutilainen <ville.voutilainen@gmail.com> + + PR libstdc++/71313 + * src/filesystem/ops.cc (remove_all(const path&, error_code&)): + Call remove_all for children of a directory. + * testsuite/experimental/filesystem/operations/create_directories.cc: + Adjust. + +2016-06-17 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/71545 + * include/bits/stl_algobase.h (lower_bound, lexicographical_compare): + Remove irreflexive checks. + * include/bits/stl_algo.h (lower_bound, upper_bound, equal_range, + binary_search): Likewise. + * testsuite/25_algorithms/equal_range/partitioned.cc: New test. + * testsuite/25_algorithms/lexicographical_compare/71545.cc: New test. + * testsuite/25_algorithms/lower_bound/partitioned.cc: New test. + * testsuite/25_algorithms/upper_bound/partitioned.cc: New test. + * testsuite/util/testsuite_iterators.h (__gnu_test::test_container): + Add constructor from array. + +2016-05-26 Jonathan Wakely <jwakely@redhat.com> + + Backport from mainline + 2016-04-24 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/70762 + * testsuite/util/testsuite_fs.h (__gnu_test::nonexistent_path): Use + static counter to return a different path on every call. + + * testsuite/experimental/filesystem/path/native/string.cc: Add + dg-require-filesystem-ts directive. + +2016-05-25 Jonathan Wakely <jwakely@redhat.com> + + Backport from mainline + 2016-04-20 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/69703 + * src/c++11/codecvt.cc (__codecvt_utf8_base<char16_t>::do_in, + __codecvt_utf8_utf16_base<char16_t>::do_in): Fix mask operations. + + Backport from mainline + 2016-04-19 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/69703 + * src/c++11/codecvt.cc (__codecvt_utf8_base<char16_t>::do_in)): + Override endianness bit in mode. + * testsuite/22_locale/codecvt/codecvt_utf8/69703.cc: New test. + * testsuite/22_locale/codecvt/codecvt_utf8_utf16/66855.cc: Test + that little_endian mode is ignored. + * testsuite/experimental/filesystem/path/native/string.cc: New test. + + Backport from mainline + 2016-05-10 Jonathan Wakely <jwakely@redhat.com> + + * include/experimental/bits/fs_dir.h (begin, end): Add noexcept. + * testsuite/experimental/filesystem/iterators/directory_iterator.cc: + Test begin and end functions. + * testsuite/experimental/filesystem/iterators/ + recursive_directory_iterator.cc: Likewise. + + Backport from mainline + 2016-05-10 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/71038 + * src/filesystem/ops.cc (do_copy_file): Fix backwards conditions. + * testsuite/experimental/filesystem/operations/copy_file.cc: New test. + + Backport from mainline + 2016-05-10 Jonathan Wakely <jwakely@redhat.com> + + * include/experimental/bits/fs_dir.h (__directory_iterator_proxy): + Overload operator* to move from rvalues. + + Backport from mainline + 2016-05-10 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/71036 + * src/filesystem/ops.cc (create_dir): Handle EEXIST from mkdir. + * testsuite/experimental/filesystem/operations/create_directory.cc: + New test. + + Backport from mainline + 2016-05-10 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/71037 + * src/filesystem/ops.cc (canonical(const path&, const path&)): Add + base path to exception. + * testsuite/experimental/filesystem/operations/canonical.cc: Test + paths contained in exception. + + Backport from mainline + 2016-05-10 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/71005 + * include/experimental/bits/fs_dir.h (__directory_iterator_proxy): + New type. + (directory_iterator::operator++(int)): Return proxy. + (recursive_directory_iterator::operator++(int)): Likewise. + * testsuite/experimental/filesystem/iterators/directory_iterator.cc: + Test post-increment. + * testsuite/experimental/filesystem/iterators/ + recursive_directory_iterator.cc: Likewise. + + Backport from mainline + 2016-05-09 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/71004 + * include/experimental/bits/fs_dir.h (recursive_directory_iterator): + Initialize scalar member variables in default constructor. + * testsuite/experimental/filesystem/iterators/ + recursive_directory_iterator.cc: Test default construction. + + Backport from mainline + 2016-04-19 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/70609 + * src/filesystem/ops.cc (close_fd): New function. + (do_copy_file): Set permissions before copying file contents. Check + result of closing file descriptors. Don't copy streambuf when file + is empty. + (copy(const path&, const path&, copy_options, error_code&)): Use + lstat for source file when copy_symlinks is set. + * testsuite/experimental/filesystem/operations/copy.cc: Test copy(). + + Backport from mainline + 2016-04-19 Jonathan Wakely <jwakely@redhat.com> + + * include/experimental/bits/fs_fwd.h (operator&, operator|, operator^, + operator~ operator&=, operator|=, operator^=): Add noexcept to + overloaded operators for copy_options, perms and directory_options. + * src/filesystem/ops.cc (make_file_type, make_file_status, + is_not_found_errno, file_time): Add noexcept. + +2016-05-11 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/71049 + * src/c++11/cow-stdexcept.cc [!_GLIBCXX_USE_DUAL_ABI]: Don't define + exception constructors with __sso_string parameters. + +2016-05-09 Ville Voutilainen <ville.voutilainen@gmail.com> + + Avoid endless run-time recursion for copying single-element + tuples where the element type is by-value constructible + from any type. + * include/std/tuple (_NotSameTuple): New. + * include/std/tuple (tuple(_UElements&&...): Use it. + * testsuite/20_util/tuple/cons/element_accepts_anything_byval.cc: New. + 2016-04-27 Release Manager * GCC 6.1.0 released. diff --git a/libstdc++-v3/doc/html/manual/abi.html b/libstdc++-v3/doc/html/manual/abi.html index e7de3a5264..276c2ebb4f 100644 --- a/libstdc++-v3/doc/html/manual/abi.html +++ b/libstdc++-v3/doc/html/manual/abi.html @@ -129,7 +129,7 @@ compatible. GLIBCPP_3.2 for symbols that were introduced in the GCC 3.2.0 release.) If a particular release is not listed, it has the same version labels as the preceding release. - </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>GCC 3.0.0: (Error, not versioned)</p></li><li class="listitem"><p>GCC 3.0.1: (Error, not versioned)</p></li><li class="listitem"><p>GCC 3.0.2: (Error, not versioned)</p></li><li class="listitem"><p>GCC 3.0.3: (Error, not versioned)</p></li><li class="listitem"><p>GCC 3.0.4: (Error, not versioned)</p></li><li class="listitem"><p>GCC 3.1.0: GLIBCPP_3.1, CXXABI_1</p></li><li class="listitem"><p>GCC 3.1.1: GLIBCPP_3.1, CXXABI_1</p></li><li class="listitem"><p>GCC 3.2.0: GLIBCPP_3.2, CXXABI_1.2</p></li><li class="listitem"><p>GCC 3.2.1: GLIBCPP_3.2.1, CXXABI_1.2</p></li><li class="listitem"><p>GCC 3.2.2: GLIBCPP_3.2.2, CXXABI_1.2</p></li><li class="listitem"><p>GCC 3.2.3: GLIBCPP_3.2.2, CXXABI_1.2</p></li><li class="listitem"><p>GCC 3.3.0: GLIBCPP_3.2.2, CXXABI_1.2.1</p></li><li class="listitem"><p>GCC 3.3.1: GLIBCPP_3.2.3, CXXABI_1.2.1</p></li><li class="listitem"><p>GCC 3.3.2: GLIBCPP_3.2.3, CXXABI_1.2.1</p></li><li class="listitem"><p>GCC 3.3.3: GLIBCPP_3.2.3, CXXABI_1.2.1</p></li><li class="listitem"><p>GCC 3.4.0: GLIBCXX_3.4, CXXABI_1.3</p></li><li class="listitem"><p>GCC 3.4.1: GLIBCXX_3.4.1, CXXABI_1.3</p></li><li class="listitem"><p>GCC 3.4.2: GLIBCXX_3.4.2</p></li><li class="listitem"><p>GCC 3.4.3: GLIBCXX_3.4.3</p></li><li class="listitem"><p>GCC 4.0.0: GLIBCXX_3.4.4, CXXABI_1.3.1</p></li><li class="listitem"><p>GCC 4.0.1: GLIBCXX_3.4.5</p></li><li class="listitem"><p>GCC 4.0.2: GLIBCXX_3.4.6</p></li><li class="listitem"><p>GCC 4.0.3: GLIBCXX_3.4.7</p></li><li class="listitem"><p>GCC 4.1.1: GLIBCXX_3.4.8</p></li><li class="listitem"><p>GCC 4.2.0: GLIBCXX_3.4.9</p></li><li class="listitem"><p>GCC 4.3.0: GLIBCXX_3.4.10, CXXABI_1.3.2</p></li><li class="listitem"><p>GCC 4.4.0: GLIBCXX_3.4.11, CXXABI_1.3.3</p></li><li class="listitem"><p>GCC 4.4.1: GLIBCXX_3.4.12, CXXABI_1.3.3</p></li><li class="listitem"><p>GCC 4.4.2: GLIBCXX_3.4.13, CXXABI_1.3.3</p></li><li class="listitem"><p>GCC 4.5.0: GLIBCXX_3.4.14, CXXABI_1.3.4</p></li><li class="listitem"><p>GCC 4.6.0: GLIBCXX_3.4.15, CXXABI_1.3.5</p></li><li class="listitem"><p>GCC 4.6.1: GLIBCXX_3.4.16, CXXABI_1.3.5</p></li><li class="listitem"><p>GCC 4.7.0: GLIBCXX_3.4.17, CXXABI_1.3.6</p></li><li class="listitem"><p>GCC 4.8.0: GLIBCXX_3.4.18, CXXABI_1.3.7</p></li><li class="listitem"><p>GCC 4.8.3: GLIBCXX_3.4.19, CXXABI_1.3.7</p></li><li class="listitem"><p>GCC 4.9.0: GLIBCXX_3.4.20, CXXABI_1.3.8</p></li><li class="listitem"><p>GCC 5.1.0: GLIBCXX_3.4.21, CXXABI_1.3.9</p></li></ul></div></li><li class="listitem"><p>Incremental bumping of a compiler pre-defined macro, + </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>GCC 3.0.0: (Error, not versioned)</p></li><li class="listitem"><p>GCC 3.0.1: (Error, not versioned)</p></li><li class="listitem"><p>GCC 3.0.2: (Error, not versioned)</p></li><li class="listitem"><p>GCC 3.0.3: (Error, not versioned)</p></li><li class="listitem"><p>GCC 3.0.4: (Error, not versioned)</p></li><li class="listitem"><p>GCC 3.1.0: GLIBCPP_3.1, CXXABI_1</p></li><li class="listitem"><p>GCC 3.1.1: GLIBCPP_3.1, CXXABI_1</p></li><li class="listitem"><p>GCC 3.2.0: GLIBCPP_3.2, CXXABI_1.2</p></li><li class="listitem"><p>GCC 3.2.1: GLIBCPP_3.2.1, CXXABI_1.2</p></li><li class="listitem"><p>GCC 3.2.2: GLIBCPP_3.2.2, CXXABI_1.2</p></li><li class="listitem"><p>GCC 3.2.3: GLIBCPP_3.2.2, CXXABI_1.2</p></li><li class="listitem"><p>GCC 3.3.0: GLIBCPP_3.2.2, CXXABI_1.2.1</p></li><li class="listitem"><p>GCC 3.3.1: GLIBCPP_3.2.3, CXXABI_1.2.1</p></li><li class="listitem"><p>GCC 3.3.2: GLIBCPP_3.2.3, CXXABI_1.2.1</p></li><li class="listitem"><p>GCC 3.3.3: GLIBCPP_3.2.3, CXXABI_1.2.1</p></li><li class="listitem"><p>GCC 3.4.0: GLIBCXX_3.4, CXXABI_1.3</p></li><li class="listitem"><p>GCC 3.4.1: GLIBCXX_3.4.1, CXXABI_1.3</p></li><li class="listitem"><p>GCC 3.4.2: GLIBCXX_3.4.2</p></li><li class="listitem"><p>GCC 3.4.3: GLIBCXX_3.4.3</p></li><li class="listitem"><p>GCC 4.0.0: GLIBCXX_3.4.4, CXXABI_1.3.1</p></li><li class="listitem"><p>GCC 4.0.1: GLIBCXX_3.4.5</p></li><li class="listitem"><p>GCC 4.0.2: GLIBCXX_3.4.6</p></li><li class="listitem"><p>GCC 4.0.3: GLIBCXX_3.4.7</p></li><li class="listitem"><p>GCC 4.1.1: GLIBCXX_3.4.8</p></li><li class="listitem"><p>GCC 4.2.0: GLIBCXX_3.4.9</p></li><li class="listitem"><p>GCC 4.3.0: GLIBCXX_3.4.10, CXXABI_1.3.2</p></li><li class="listitem"><p>GCC 4.4.0: GLIBCXX_3.4.11, CXXABI_1.3.3</p></li><li class="listitem"><p>GCC 4.4.1: GLIBCXX_3.4.12, CXXABI_1.3.3</p></li><li class="listitem"><p>GCC 4.4.2: GLIBCXX_3.4.13, CXXABI_1.3.3</p></li><li class="listitem"><p>GCC 4.5.0: GLIBCXX_3.4.14, CXXABI_1.3.4</p></li><li class="listitem"><p>GCC 4.6.0: GLIBCXX_3.4.15, CXXABI_1.3.5</p></li><li class="listitem"><p>GCC 4.6.1: GLIBCXX_3.4.16, CXXABI_1.3.5</p></li><li class="listitem"><p>GCC 4.7.0: GLIBCXX_3.4.17, CXXABI_1.3.6</p></li><li class="listitem"><p>GCC 4.8.0: GLIBCXX_3.4.18, CXXABI_1.3.7</p></li><li class="listitem"><p>GCC 4.8.3: GLIBCXX_3.4.19, CXXABI_1.3.7</p></li><li class="listitem"><p>GCC 4.9.0: GLIBCXX_3.4.20, CXXABI_1.3.8</p></li><li class="listitem"><p>GCC 5.1.0: GLIBCXX_3.4.21, CXXABI_1.3.9</p></li><li class="listitem"><p>GCC 6.1.0: GLIBCXX_3.4.22, CXXABI_1.3.10</p></li></ul></div></li><li class="listitem"><p>Incremental bumping of a compiler pre-defined macro, __GXX_ABI_VERSION. This macro is defined as the version of the compiler v3 ABI, with g++ 3.0 being version 100. This macro will be automatically defined whenever g++ is used (the curious can diff --git a/libstdc++-v3/doc/html/manual/status.html b/libstdc++-v3/doc/html/manual/status.html index 8c5a7c998a..ea30b51bb2 100644 --- a/libstdc++-v3/doc/html/manual/status.html +++ b/libstdc++-v3/doc/html/manual/status.html @@ -156,8 +156,7 @@ options. The pre-defined symbol <code class="constant">__cplusplus</code> is used to check for the presence of the required flag. </p><p> -This page describes the C++11 support in mainline GCC SVN, not in any -particular release. +This page describes the C++11 support in the GCC 6 series. </p><div class="table"><a id="table.cxx11_status"></a><p class="title"><strong>Table 1.2. C++ 2011 Implementation Status</strong></p><div class="table-contents"><table summary="C++ 2011 Implementation Status" border="1"><colgroup><col align="left" class="c1" /><col align="left" class="c2" /><col align="left" class="c3" /><col align="left" class="c4" /></colgroup><thead><tr><th align="left">Section</th><th align="left">Description</th><th align="left">Status</th><th align="left">Comments</th></tr></thead><tbody><tr><td align="left"> <span class="emphasis"><em>18</em></span> </td><td colspan="3" align="left"> @@ -335,8 +334,7 @@ options. The pre-defined symbol <code class="constant">__cplusplus</code> is used to check for the presence of the required flag. </p><p> -This page describes the C++14 and library TS support in mainline GCC SVN, -not in any particular release. +This page describes the C++14 and library TS support in the GCC 6 series. </p><div class="table"><a id="table.cxx14_status"></a><p class="title"><strong>Table 1.3. C++ 2014 Implementation Status</strong></p><div class="table-contents"><table summary="C++ 2014 Implementation Status" border="1"><colgroup><col align="left" class="c1" /><col align="left" class="c2" /><col align="left" class="c3" /><col align="left" class="c4" /></colgroup><thead><tr><th align="left">Paper</th><th align="left">Title</th><th align="left">Status</th><th align="left">Comments</th></tr></thead><tbody><tr><td align="left"> <a class="link" href="http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3669.pdf" target="_top"> N3669 @@ -405,7 +403,7 @@ not in any particular release. <a class="link" href="http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3655.pdf" target="_top"> N3655 </a> - </td><td align="left">TransformationTraits Redux</td><td align="left">Y</td><td align="left"> </td></tr><tr bgcolor="#C8B0B0"><td align="left"> + </td><td align="left">TransformationTraits Redux</td><td align="left">Y</td><td align="left"> </td></tr><tr bgcolor="#B0B0B0"><td align="left"> <a class="link" href="http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3644.pdf" target="_top"> N3644 </a> @@ -433,15 +431,15 @@ not in any particular release. <a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3915.pdf" target="_top"> N3915 </a> - </td><td align="left">apply() call a function with arguments from a tuple</td><td align="left">Y</td><td align="left">Library Fundamentals TS</td></tr><tr bgcolor="#C8B0B0"><td align="left"> + </td><td align="left">apply() call a function with arguments from a tuple</td><td align="left">Y</td><td align="left">Library Fundamentals TS</td></tr><tr bgcolor="#B0B0B0"><td align="left"> <a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3916.pdf" target="_top"> N3916 </a> - </td><td align="left">Polymorphic memory resources</td><td align="left">N</td><td align="left">Library Fundamentals TS</td></tr><tr bgcolor="#C8B0B0"><td align="left"> + </td><td align="left">Polymorphic memory resources</td><td align="left">Partial</td><td align="left">Library Fundamentals TS</td></tr><tr><td align="left"> <a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3920.html" target="_top"> N3920 </a> - </td><td align="left">Extending shared_ptr to support arrays</td><td align="left">N</td><td align="left">Library Fundamentals TS</td></tr><tr><td align="left"> + </td><td align="left">Extending shared_ptr to support arrays</td><td align="left">Y</td><td align="left">Library Fundamentals TS</td></tr><tr><td align="left"> <a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3921.html" target="_top"> N3921 </a> @@ -470,8 +468,7 @@ options. The pre-defined symbol <code class="constant">__cplusplus</code> is used to check for the presence of the required flag. </p><p> -This page describes the C++1z and library TS support in mainline GCC SVN, -not in any particular release. +This page describes the C++1z and library TS support in the GCC 6 series. </p><div class="table"><a id="table.cxx1z_status"></a><p class="title"><strong>Table 1.5. C++ 201z Implementation Status</strong></p><div class="table-contents"><table summary="C++ 201z Implementation Status" border="1"><colgroup><col align="left" class="c1" /><col align="left" class="c2" /><col align="left" class="c3" /><col align="left" class="c4" /></colgroup><thead><tr><th align="left">Paper</th><th align="left">Title</th><th align="left">Status</th><th align="left">Comments</th></tr></thead><tbody><tr><td align="left"> <a class="link" href="http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2014/n4259.pdf" target="_top"> N4259 diff --git a/libstdc++-v3/doc/xml/manual/abi.xml b/libstdc++-v3/doc/xml/manual/abi.xml index a2ed57b3f6..aa5aa5be07 100644 --- a/libstdc++-v3/doc/xml/manual/abi.xml +++ b/libstdc++-v3/doc/xml/manual/abi.xml @@ -331,6 +331,7 @@ compatible. <listitem><para>GCC 4.8.3: GLIBCXX_3.4.19, CXXABI_1.3.7</para></listitem> <listitem><para>GCC 4.9.0: GLIBCXX_3.4.20, CXXABI_1.3.8</para></listitem> <listitem><para>GCC 5.1.0: GLIBCXX_3.4.21, CXXABI_1.3.9</para></listitem> + <listitem><para>GCC 6.1.0: GLIBCXX_3.4.22, CXXABI_1.3.10</para></listitem> </itemizedlist> </listitem> diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2011.xml b/libstdc++-v3/doc/xml/manual/status_cxx2011.xml index cf99956b7e..e6d0f0622c 100644 --- a/libstdc++-v3/doc/xml/manual/status_cxx2011.xml +++ b/libstdc++-v3/doc/xml/manual/status_cxx2011.xml @@ -27,8 +27,7 @@ presence of the required flag. </para> <para> -This page describes the C++11 support in mainline GCC SVN, not in any -particular release. +This page describes the C++11 support in the GCC 6 series. </para> <!-- Status is Yes or No, Broken/Partial--> diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2014.xml b/libstdc++-v3/doc/xml/manual/status_cxx2014.xml index 6f1fbe5664..fe9109381b 100644 --- a/libstdc++-v3/doc/xml/manual/status_cxx2014.xml +++ b/libstdc++-v3/doc/xml/manual/status_cxx2014.xml @@ -20,8 +20,7 @@ presence of the required flag. </para> <para> -This page describes the C++14 and library TS support in mainline GCC SVN, -not in any particular release. +This page describes the C++14 and library TS support in the GCC 6 series. </para> <table frame="all" xml:id="table.cxx14_status"> @@ -234,7 +233,7 @@ not in any particular release. </row> <row> - <?dbhtml bgcolor="#C8B0B0" ?> + <?dbhtml bgcolor="#B0B0B0" ?> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3644.pdf"> N3644 @@ -338,26 +337,25 @@ not in any particular release. </row> <row> - <?dbhtml bgcolor="#C8B0B0" ?> + <?dbhtml bgcolor="#B0B0B0" ?> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3916.pdf"> N3916 </link> </entry> <entry>Polymorphic memory resources</entry> - <entry>N</entry> + <entry>Partial</entry> <entry>Library Fundamentals TS</entry> </row> <row> - <?dbhtml bgcolor="#C8B0B0" ?> <entry> <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3920.html"> N3920 </link> </entry> <entry>Extending shared_ptr to support arrays</entry> - <entry>N</entry> + <entry>Y</entry> <entry>Library Fundamentals TS</entry> </row> diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml index 60e5fae43e..1528e0f66c 100644 --- a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml +++ b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml @@ -20,8 +20,7 @@ presence of the required flag. </para> <para> -This page describes the C++1z and library TS support in mainline GCC SVN, -not in any particular release. +This page describes the C++1z and library TS support in the GCC 6 series. </para> <table frame="all" xml:id="table.cxx1z_status"> diff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h index 597d3054c0..984d80075b 100644 --- a/libstdc++-v3/include/bits/allocator.h +++ b/libstdc++-v3/include/bits/allocator.h @@ -49,6 +49,8 @@ #include <type_traits> #endif +#define __cpp_lib_incomplete_container_elements 201505 + namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index 57024e40ec..4625607425 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -414,7 +414,7 @@ namespace std // Debug Mode implies checking assertions. #ifdef _GLIBCXX_DEBUG -# define _GLIBCXX_ASSERTIONS +# define _GLIBCXX_ASSERTIONS 1 #endif // Disable std::string explicit instantiation declarations in order to assert. diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index fbd03a79e1..c2ac0317f1 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -2026,7 +2026,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename iterator_traits<_ForwardIterator>::value_type, _Tp>) __glibcxx_requires_partitioned_lower_pred(__first, __last, __val, __comp); - __glibcxx_requires_irreflexive_pred2(__first, __last, __comp); return std::__lower_bound(__first, __last, __val, __gnu_cxx::__ops::__iter_comp_val(__comp)); @@ -2080,7 +2079,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_LessThanOpConcept< _Tp, typename iterator_traits<_ForwardIterator>::value_type>) __glibcxx_requires_partitioned_upper(__first, __last, __val); - __glibcxx_requires_irreflexive2(__first, __last); return std::__upper_bound(__first, __last, __val, __gnu_cxx::__ops::__val_less_iter()); @@ -2112,7 +2110,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp, typename iterator_traits<_ForwardIterator>::value_type>) __glibcxx_requires_partitioned_upper_pred(__first, __last, __val, __comp); - __glibcxx_requires_irreflexive_pred2(__first, __last, __comp); return std::__upper_bound(__first, __last, __val, __gnu_cxx::__ops::__val_comp_iter(__comp)); @@ -2186,7 +2183,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp, typename iterator_traits<_ForwardIterator>::value_type>) __glibcxx_requires_partitioned_lower(__first, __last, __val); __glibcxx_requires_partitioned_upper(__first, __last, __val); - __glibcxx_requires_irreflexive2(__first, __last); return std::__equal_range(__first, __last, __val, __gnu_cxx::__ops::__iter_less_val(), @@ -2225,7 +2221,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __val, __comp); __glibcxx_requires_partitioned_upper_pred(__first, __last, __val, __comp); - __glibcxx_requires_irreflexive_pred2(__first, __last, __comp); return std::__equal_range(__first, __last, __val, __gnu_cxx::__ops::__iter_comp_val(__comp), @@ -2255,7 +2250,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp, typename iterator_traits<_ForwardIterator>::value_type>) __glibcxx_requires_partitioned_lower(__first, __last, __val); __glibcxx_requires_partitioned_upper(__first, __last, __val); - __glibcxx_requires_irreflexive2(__first, __last); _ForwardIterator __i = std::__lower_bound(__first, __last, __val, @@ -2291,7 +2285,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __val, __comp); __glibcxx_requires_partitioned_upper_pred(__first, __last, __val, __comp); - __glibcxx_requires_irreflexive_pred2(__first, __last, __comp); _ForwardIterator __i = std::__lower_bound(__first, __last, __val, diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index d95ea513a5..210b173454 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -989,7 +989,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_LessThanOpConcept< typename iterator_traits<_ForwardIterator>::value_type, _Tp>) __glibcxx_requires_partitioned_lower(__first, __last, __val); - __glibcxx_requires_irreflexive2(__first, __last); return std::__lower_bound(__first, __last, __val, __gnu_cxx::__ops::__iter_less_val()); @@ -1214,9 +1213,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO __glibcxx_function_requires(_LessThanOpConcept<_ValueType1, _ValueType2>) __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>) __glibcxx_requires_valid_range(__first1, __last1); - __glibcxx_requires_irreflexive2(__first1, __last1); __glibcxx_requires_valid_range(__first2, __last2); - __glibcxx_requires_irreflexive2(__first2, __last2); return std::__lexicographical_compare_aux(std::__niter_base(__first1), std::__niter_base(__last1), @@ -1246,9 +1243,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO __glibcxx_function_requires(_InputIteratorConcept<_II1>) __glibcxx_function_requires(_InputIteratorConcept<_II2>) __glibcxx_requires_valid_range(__first1, __last1); - __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); __glibcxx_requires_valid_range(__first2, __last2); - __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); return std::__lexicographical_compare_impl (__first1, __last1, __first2, __last2, diff --git a/libstdc++-v3/include/bits/stl_function.h b/libstdc++-v3/include/bits/stl_function.h index eabf9baea5..68f39ff269 100644 --- a/libstdc++-v3/include/bits/stl_function.h +++ b/libstdc++-v3/include/bits/stl_function.h @@ -225,7 +225,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus > 201103L #define __cpp_lib_transparent_operators 201210 -//#define __cpp_lib_generic_associative_lookup 201304 template<> struct plus<void> diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index a9ca3facf9..8697a711a5 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -73,6 +73,10 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION +#if __cplusplus > 201103L +# define __cpp_lib_generic_associative_lookup 201304 +#endif + // Red-black tree class, designed for use in implementing STL // associative containers (set, multiset, map, and multimap). The // insertion and deletion algorithms are based on those in Cormen, @@ -851,7 +855,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } _Rb_tree(_Rb_tree&& __x) - : _M_impl(__x._M_impl._M_key_compare, __x._M_get_Node_allocator()) + : _M_impl(__x._M_impl._M_key_compare, + std::move(__x._M_get_Node_allocator())) { if (__x._M_root() != 0) _M_move_data(__x, std::true_type()); diff --git a/libstdc++-v3/include/experimental/any b/libstdc++-v3/include/experimental/any index ae40091fbb..96ad5762f6 100644 --- a/libstdc++-v3/include/experimental/any +++ b/libstdc++-v3/include/experimental/any @@ -158,7 +158,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Construct with a copy of @p __value as the contained object. template <typename _ValueType, typename _Tp = _Decay<_ValueType>, - typename _Mgr = _Manager<_Tp>> + typename _Mgr = _Manager<_Tp>, + typename enable_if<is_constructible<_Tp, _ValueType&&>::value, + bool>::type = true> any(_ValueType&& __value) : _M_manager(&_Mgr::_S_manage) { @@ -167,6 +169,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION "The contained object must be CopyConstructible"); } + /// Construct with a copy of @p __value as the contained object. + template <typename _ValueType, typename _Tp = _Decay<_ValueType>, + typename _Mgr = _Manager<_Tp>, + typename enable_if<!is_constructible<_Tp, _ValueType&&>::value, + bool>::type = false> + any(_ValueType&& __value) + : _M_manager(&_Mgr::_S_manage) + { + _Mgr::_S_create(_M_storage, __value); + static_assert(is_copy_constructible<_Tp>::value, + "The contained object must be CopyConstructible"); + } + /// Destructor, calls @c clear() ~any() { clear(); } @@ -377,7 +392,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __throw_bad_any_cast(); } - template<typename _ValueType> + template<typename _ValueType, + typename enable_if<!is_move_constructible<_ValueType>::value + || is_lvalue_reference<_ValueType>::value, + bool>::type = true> inline _ValueType any_cast(any&& __any) { static_assert(any::__is_valid_cast<_ValueType>(), @@ -387,6 +405,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return *__p; __throw_bad_any_cast(); } + + template<typename _ValueType, + typename enable_if<is_move_constructible<_ValueType>::value + && !is_lvalue_reference<_ValueType>::value, + bool>::type = false> + inline _ValueType any_cast(any&& __any) + { + static_assert(any::__is_valid_cast<_ValueType>(), + "Template argument must be a reference or CopyConstructible type"); + auto __p = any_cast<remove_reference_t<_ValueType>>(&__any); + if (__p) + return std::move(*__p); + __throw_bad_any_cast(); + } // @} template<typename _Tp> diff --git a/libstdc++-v3/include/experimental/bits/fs_dir.h b/libstdc++-v3/include/experimental/bits/fs_dir.h index 4e28c8e924..70a95ebfe6 100644 --- a/libstdc++-v3/include/experimental/bits/fs_dir.h +++ b/libstdc++-v3/include/experimental/bits/fs_dir.h @@ -153,8 +153,25 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 }; struct _Dir; + class directory_iterator; class recursive_directory_iterator; + struct __directory_iterator_proxy + { + const directory_entry& operator*() const& noexcept { return _M_entry; } + + directory_entry operator*() && noexcept { return std::move(_M_entry); } + + private: + friend class directory_iterator; + friend class recursive_directory_iterator; + + explicit + __directory_iterator_proxy(const directory_entry& __e) : _M_entry(__e) { } + + directory_entry _M_entry; + }; + class directory_iterator { public: @@ -177,7 +194,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 : directory_iterator(__p, directory_options::none, __ec) { } directory_iterator(const path& __p, - directory_options __options, error_code& __ec) noexcept + directory_options __options, + error_code& __ec) noexcept : directory_iterator(__p, __options, &__ec) { } directory_iterator(const directory_iterator& __rhs) = default; @@ -186,19 +204,22 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 ~directory_iterator() = default; - directory_iterator& operator=(const directory_iterator& __rhs) = default; - directory_iterator& operator=(directory_iterator&& __rhs) noexcept = default; + directory_iterator& + operator=(const directory_iterator& __rhs) = default; + + directory_iterator& + operator=(directory_iterator&& __rhs) noexcept = default; const directory_entry& operator*() const; const directory_entry* operator->() const { return &**this; } directory_iterator& operator++(); directory_iterator& increment(error_code& __ec) noexcept; - directory_iterator operator++(int) + __directory_iterator_proxy operator++(int) { - auto __tmp = *this; + __directory_iterator_proxy __pr{**this}; ++*this; - return __tmp; + return __pr; } private: @@ -214,10 +235,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 }; inline directory_iterator - begin(directory_iterator __iter) { return __iter; } + begin(directory_iterator __iter) noexcept + { return __iter; } inline directory_iterator - end(directory_iterator) { return directory_iterator(); } + end(directory_iterator) noexcept + { return directory_iterator(); } inline bool operator==(const directory_iterator& __lhs, const directory_iterator& __rhs) @@ -274,18 +297,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 // modifiers recursive_directory_iterator& - operator=(const recursive_directory_iterator& __rhs) noexcept; + operator=(const recursive_directory_iterator& __rhs) noexcept; recursive_directory_iterator& - operator=(recursive_directory_iterator&& __rhs) noexcept; + operator=(recursive_directory_iterator&& __rhs) noexcept; recursive_directory_iterator& operator++(); recursive_directory_iterator& increment(error_code& __ec) noexcept; - recursive_directory_iterator operator++(int) + __directory_iterator_proxy operator++(int) { - auto __tmp = *this; + __directory_iterator_proxy __pr{**this}; ++*this; - return __tmp; + return __pr; } void pop(); @@ -301,15 +324,17 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 struct _Dir_stack; std::shared_ptr<_Dir_stack> _M_dirs; - directory_options _M_options; - bool _M_pending; + directory_options _M_options = {}; + bool _M_pending = false; }; inline recursive_directory_iterator - begin(recursive_directory_iterator __iter) { return __iter; } + begin(recursive_directory_iterator __iter) noexcept + { return __iter; } inline recursive_directory_iterator - end(recursive_directory_iterator) { return recursive_directory_iterator(); } + end(recursive_directory_iterator) noexcept + { return recursive_directory_iterator(); } inline bool operator==(const recursive_directory_iterator& __lhs, diff --git a/libstdc++-v3/include/experimental/bits/fs_fwd.h b/libstdc++-v3/include/experimental/bits/fs_fwd.h index 1482e18082..57aa4d3ee7 100644 --- a/libstdc++-v3/include/experimental/bits/fs_fwd.h +++ b/libstdc++-v3/include/experimental/bits/fs_fwd.h @@ -93,7 +93,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 }; constexpr copy_options - operator&(copy_options __x, copy_options __y) + operator&(copy_options __x, copy_options __y) noexcept { using __utype = typename std::underlying_type<copy_options>::type; return static_cast<copy_options>( @@ -101,7 +101,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 } constexpr copy_options - operator|(copy_options __x, copy_options __y) + operator|(copy_options __x, copy_options __y) noexcept { using __utype = typename std::underlying_type<copy_options>::type; return static_cast<copy_options>( @@ -109,7 +109,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 } constexpr copy_options - operator^(copy_options __x, copy_options __y) + operator^(copy_options __x, copy_options __y) noexcept { using __utype = typename std::underlying_type<copy_options>::type; return static_cast<copy_options>( @@ -117,22 +117,22 @@ _GLIBCXX_END_NAMESPACE_CXX11 } constexpr copy_options - operator~(copy_options __x) + operator~(copy_options __x) noexcept { using __utype = typename std::underlying_type<copy_options>::type; return static_cast<copy_options>(~static_cast<__utype>(__x)); } inline copy_options& - operator&=(copy_options& __x, copy_options __y) + operator&=(copy_options& __x, copy_options __y) noexcept { return __x = __x & __y; } inline copy_options& - operator|=(copy_options& __x, copy_options __y) + operator|=(copy_options& __x, copy_options __y) noexcept { return __x = __x | __y; } inline copy_options& - operator^=(copy_options& __x, copy_options __y) + operator^=(copy_options& __x, copy_options __y) noexcept { return __x = __x ^ __y; } @@ -163,7 +163,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 }; constexpr perms - operator&(perms __x, perms __y) + operator&(perms __x, perms __y) noexcept { using __utype = typename std::underlying_type<perms>::type; return static_cast<perms>( @@ -171,7 +171,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 } constexpr perms - operator|(perms __x, perms __y) + operator|(perms __x, perms __y) noexcept { using __utype = typename std::underlying_type<perms>::type; return static_cast<perms>( @@ -179,7 +179,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 } constexpr perms - operator^(perms __x, perms __y) + operator^(perms __x, perms __y) noexcept { using __utype = typename std::underlying_type<perms>::type; return static_cast<perms>( @@ -187,22 +187,22 @@ _GLIBCXX_END_NAMESPACE_CXX11 } constexpr perms - operator~(perms __x) + operator~(perms __x) noexcept { using __utype = typename std::underlying_type<perms>::type; return static_cast<perms>(~static_cast<__utype>(__x)); } inline perms& - operator&=(perms& __x, perms __y) + operator&=(perms& __x, perms __y) noexcept { return __x = __x & __y; } inline perms& - operator|=(perms& __x, perms __y) + operator|=(perms& __x, perms __y) noexcept { return __x = __x | __y; } inline perms& - operator^=(perms& __x, perms __y) + operator^=(perms& __x, perms __y) noexcept { return __x = __x ^ __y; } // Bitmask type @@ -211,7 +211,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 }; constexpr directory_options - operator&(directory_options __x, directory_options __y) + operator&(directory_options __x, directory_options __y) noexcept { using __utype = typename std::underlying_type<directory_options>::type; return static_cast<directory_options>( @@ -219,7 +219,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 } constexpr directory_options - operator|(directory_options __x, directory_options __y) + operator|(directory_options __x, directory_options __y) noexcept { using __utype = typename std::underlying_type<directory_options>::type; return static_cast<directory_options>( @@ -227,7 +227,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 } constexpr directory_options - operator^(directory_options __x, directory_options __y) + operator^(directory_options __x, directory_options __y) noexcept { using __utype = typename std::underlying_type<directory_options>::type; return static_cast<directory_options>( @@ -235,22 +235,22 @@ _GLIBCXX_END_NAMESPACE_CXX11 } constexpr directory_options - operator~(directory_options __x) + operator~(directory_options __x) noexcept { using __utype = typename std::underlying_type<directory_options>::type; return static_cast<directory_options>(~static_cast<__utype>(__x)); } inline directory_options& - operator&=(directory_options& __x, directory_options __y) + operator&=(directory_options& __x, directory_options __y) noexcept { return __x = __x & __y; } inline directory_options& - operator|=(directory_options& __x, directory_options __y) + operator|=(directory_options& __x, directory_options __y) noexcept { return __x = __x | __y; } inline directory_options& - operator^=(directory_options& __x, directory_options __y) + operator^=(directory_options& __x, directory_options __y) noexcept { return __x = __x ^ __y; } typedef chrono::time_point<chrono::system_clock> file_time_type; diff --git a/libstdc++-v3/include/experimental/functional b/libstdc++-v3/include/experimental/functional index 2095310938..ed41f5a398 100644 --- a/libstdc++-v3/include/experimental/functional +++ b/libstdc++-v3/include/experimental/functional @@ -42,6 +42,9 @@ #include <vector> #include <array> #include <bits/stl_algo.h> +#ifdef _GLIBCXX_PARALLEL +# include <parallel/algorithm> // For std::__parallel::search +#endif namespace std _GLIBCXX_VISIBILITY(default) { diff --git a/libstdc++-v3/include/experimental/memory_resource b/libstdc++-v3/include/experimental/memory_resource index ccdf5e66b0..ea8afb89e0 100644 --- a/libstdc++-v3/include/experimental/memory_resource +++ b/libstdc++-v3/include/experimental/memory_resource @@ -282,7 +282,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION size_t __new_size = _S_aligned_size(__bytes, _S_supported(__alignment) ? __alignment : _S_max_align); - return _Aligned_alloc().allocate(__new_size); + return _Aligned_alloc(_M_alloc).allocate(__new_size); } virtual void @@ -292,9 +292,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION size_t __new_size = _S_aligned_size(__bytes, _S_supported(__alignment) ? __alignment : _S_max_align); - _Aligned_alloc().deallocate(static_cast<typename - _Aligned_alloc::pointer>(__p), - __new_size); + using _Ptr = typename allocator_traits<_Aligned_alloc>::pointer; + _Aligned_alloc(_M_alloc).deallocate(static_cast<_Ptr>(__p), + __new_size); } virtual bool @@ -306,8 +306,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION private: // Calculate Aligned Size - // Returns a size that is larger than or equal to __size and divided by - // __alignment, where __alignment is required to be the power of 2. + // Returns a size that is larger than or equal to __size and divisible + // by __alignment, where __alignment is required to be the power of 2. static size_t _S_aligned_size(size_t __size, size_t __alignment) { return ((__size - 1)|(__alignment - 1)) + 1; } @@ -342,16 +342,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { protected: void* - do_allocate(size_t __bytes, size_t __alignment) + do_allocate(size_t, size_t) { std::__throw_bad_alloc(); } void - do_deallocate(void* __p, size_t __bytes, size_t __alignment) + do_deallocate(void*, size_t, size_t) noexcept { } bool do_is_equal(const memory_resource& __other) const noexcept - { } + { return this == &__other; } friend memory_resource* null_memory_resource() noexcept; }; diff --git a/libstdc++-v3/include/experimental/optional b/libstdc++-v3/include/experimental/optional index 7524a7e135..b6425b7d00 100644 --- a/libstdc++-v3/include/experimental/optional +++ b/libstdc++-v3/include/experimental/optional @@ -470,6 +470,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION bool _M_engaged = false; }; + template<typename _Tp> + class optional; + + template<typename> + struct __is_optional_impl : false_type + { }; + + template<typename _Tp> + struct __is_optional_impl<optional<_Tp>> : true_type + { }; + + template<typename _Tp> + struct __is_optional + : public __is_optional_impl<std::remove_cv_t<std::remove_reference_t<_Tp>>> + { }; + + /** * @brief Class template for optional values. */ @@ -502,6 +519,78 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // _Optional_base has the responsibility for construction. using _Base::_Base; + constexpr optional() = default; + // Converting constructors for engaged optionals. + template <typename _Up, + enable_if_t<__and_< + __not_<is_same<_Tp, _Up>>, + is_constructible<_Tp, _Up&&>, + is_convertible<_Up&&, _Tp> + >::value, bool> = true> + constexpr optional(_Up&& __t) + : _Base(_Tp(std::forward<_Up>(__t))) { } + + template <typename _Up, + enable_if_t<__and_< + __not_<is_same<_Tp, _Up>>, + is_constructible<_Tp, _Up&&>, + __not_<is_convertible<_Up&&, _Tp>> + >::value, bool> = false> + explicit constexpr optional(_Up&& __t) + : _Base(_Tp(std::forward<_Up>(__t))) { } + + template <typename _Up, + enable_if_t<__and_< + __not_<is_same<_Tp, _Up>>, + __not_<is_constructible< + _Tp, const optional<_Up>&>>, + __not_<is_convertible< + const optional<_Up>&, _Tp>>, + is_constructible<_Tp, const _Up&>, + is_convertible<const _Up&, _Tp> + >::value, bool> = true> + constexpr optional(const optional<_Up>& __t) + : _Base(__t ? optional<_Tp>(*__t) : optional<_Tp>()) { } + + template <typename _Up, + enable_if_t<__and_< + __not_<is_same<_Tp, _Up>>, + __not_<is_constructible< + _Tp, const optional<_Up>&>>, + __not_<is_convertible< + const optional<_Up>&, _Tp>>, + is_constructible<_Tp, const _Up&>, + __not_<is_convertible<const _Up&, _Tp>> + >::value, bool> = false> + explicit constexpr optional(const optional<_Up>& __t) + : _Base(__t ? optional<_Tp>(*__t) : optional<_Tp>()) { } + + template <typename _Up, + enable_if_t<__and_< + __not_<is_same<_Tp, _Up>>, + __not_<is_constructible< + _Tp, optional<_Up>&&>>, + __not_<is_convertible< + optional<_Up>&&, _Tp>>, + is_constructible<_Tp, _Up&&>, + is_convertible<_Up&&, _Tp> + >::value, bool> = true> + constexpr optional(optional<_Up>&& __t) + : _Base(__t ? optional<_Tp>(std::move(*__t)) : optional<_Tp>()) { } + + template <typename _Up, + enable_if_t<__and_< + __not_<is_same<_Tp, _Up>>, + __not_<is_constructible< + _Tp, optional<_Up>&&>>, + __not_<is_convertible< + optional<_Up>&&, _Tp>>, + is_constructible<_Tp, _Up&&>, + __not_<is_convertible<_Up&&, _Tp>> + >::value, bool> = false> + explicit constexpr optional(optional<_Up>&& __t) + : _Base(__t ? optional<_Tp>(std::move(*__t)) : optional<_Tp>()) { } + // [X.Y.4.3] (partly) Assignment. optional& operator=(nullopt_t) noexcept @@ -510,8 +599,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return *this; } - template<typename _Up> - enable_if_t<is_same<_Tp, decay_t<_Up>>::value, optional&> + template<typename _Up, + enable_if_t<__and_< + __not_<is_same<_Up, nullopt_t>>, + __not_<__is_optional<_Up>>>::value, + bool> = true> + optional& operator=(_Up&& __u) { static_assert(__and_<is_constructible<_Tp, _Up>, @@ -526,6 +619,57 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return *this; } + template<typename _Up, + enable_if_t<__and_< + __not_<is_same<_Tp, _Up>>>::value, + bool> = true> + optional& + operator=(const optional<_Up>& __u) + { + static_assert(__and_<is_constructible<_Tp, _Up>, + is_assignable<_Tp&, _Up>>(), + "Cannot assign to value type from argument"); + + if (__u) + { + if (this->_M_is_engaged()) + this->_M_get() = *__u; + else + this->_M_construct(*__u); + } + else + { + this->_M_reset(); + } + return *this; + } + + template<typename _Up, + enable_if_t<__and_< + __not_<is_same<_Tp, _Up>>>::value, + bool> = true> + optional& + operator=(optional<_Up>&& __u) + { + static_assert(__and_<is_constructible<_Tp, _Up>, + is_assignable<_Tp&, _Up>>(), + "Cannot assign to value type from argument"); + + if (__u) + { + if (this->_M_is_engaged()) + this->_M_get() = std::move(*__u); + else + this->_M_construct(std::move(*__u)); + } + else + { + this->_M_reset(); + } + + return *this; + } + template<typename... _Args> void emplace(_Args&&... __args) diff --git a/libstdc++-v3/include/experimental/propagate_const b/libstdc++-v3/include/experimental/propagate_const index ea052ca98a..75cd8c0a4b 100644 --- a/libstdc++-v3/include/experimental/propagate_const +++ b/libstdc++-v3/include/experimental/propagate_const @@ -116,14 +116,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION is_convertible<_Up&&, _Tp>>::value, bool >::type=true> constexpr propagate_const(propagate_const<_Up>&& __pu) - : __t(move(get_underlying(__pu))) + : _M_t(std::move(get_underlying(__pu))) {} template <typename _Up, typename enable_if<__and_<is_constructible<_Tp, _Up&&>, __not_<is_convertible<_Up&&, _Tp>>>::value, bool>::type=false> constexpr explicit propagate_const(propagate_const<_Up>&& __pu) - : __t(move(get_underlying(__pu))) + : _M_t(std::move(get_underlying(__pu))) {} template <typename _Up, typename enable_if<__and_<is_constructible<_Tp, _Up&&>, @@ -132,7 +132,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename decay<_Up>::type>> >::value, bool>::type=true> constexpr propagate_const(_Up&& __u) - : __t(forward<_Up>(__u)) + : _M_t(std::forward<_Up>(__u)) {} template <typename _Up, typename enable_if<__and_<is_constructible<_Tp, _Up&&>, @@ -141,7 +141,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename decay<_Up>::type>> >::value, bool>::type=false> constexpr explicit propagate_const(_Up&& __u) - : __t(forward<_Up>(__u)) + : _M_t(std::forward<_Up>(__u)) {} // [propagate_const.assignment], assignment @@ -152,7 +152,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename enable_if<is_convertible<_Up&&, _Tp>::value>::type> constexpr propagate_const& operator=(propagate_const<_Up>&& __pu) { - __t = move(get_underlying(__pu)); + _M_t = std::move(get_underlying(__pu)); } template <typename _Up, typename = @@ -162,13 +162,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION >::value>::type> constexpr propagate_const& operator=(_Up&& __u) { - __t = forward<_Up>(__u); + _M_t = std::forward<_Up>(__u); } // [propagate_const.const_observers], const observers explicit constexpr operator bool() const { - return bool(__t); + return bool(_M_t); } constexpr const element_type* operator->() const @@ -193,7 +193,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr const element_type* get() const { - return __to_raw_pointer(__t); + return __to_raw_pointer(_M_t); } // [propagate_const.non_const_observers], non-const observers @@ -219,7 +219,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr element_type* get() { - return __to_raw_pointer(__t); + return __to_raw_pointer(_M_t); } // [propagate_const.modifiers], modifiers @@ -227,11 +227,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION swap(propagate_const& __pt) noexcept(__is_nothrow_swappable<_Tp>::value) { using std::swap; - swap(__t, get_underlying(__pt)); + swap(_M_t, get_underlying(__pt)); } private: - _Tp __t; //exposition only + _Tp _M_t; }; // [propagate_const.relational], relational operators @@ -408,14 +408,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr const _Tp& get_underlying(const propagate_const<_Tp>& __pt) noexcept { - return __pt.__t; + return __pt._M_t; } template <typename _Tp> constexpr _Tp& get_underlying(propagate_const<_Tp>& __pt) noexcept { - return __pt.__t; + return __pt._M_t; } // @} group propagate_const diff --git a/libstdc++-v3/include/parallel/balanced_quicksort.h b/libstdc++-v3/include/parallel/balanced_quicksort.h index 65dec3073e..16ef1efe88 100644 --- a/libstdc++-v3/include/parallel/balanced_quicksort.h +++ b/libstdc++-v3/include/parallel/balanced_quicksort.h @@ -53,6 +53,9 @@ #if _GLIBCXX_ASSERTIONS #include <parallel/checkers.h> +#ifdef _GLIBCXX_HAVE_UNISTD_H +#include <unistd.h> +#endif #endif namespace __gnu_parallel diff --git a/libstdc++-v3/include/parallel/compiletime_settings.h b/libstdc++-v3/include/parallel/compiletime_settings.h index f4fb404914..c1758aac3d 100644 --- a/libstdc++-v3/include/parallel/compiletime_settings.h +++ b/libstdc++-v3/include/parallel/compiletime_settings.h @@ -55,12 +55,6 @@ #define _GLIBCXX_SCALE_DOWN_FPU 0 #endif -#ifndef _GLIBCXX_ASSERTIONS -/** @brief Switch on many _GLIBCXX_PARALLEL_ASSERTions in parallel code. - * Should be switched on only locally. */ -#define _GLIBCXX_ASSERTIONS 0 -#endif - #ifndef _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_L1 /** @brief Switch on many _GLIBCXX_PARALLEL_ASSERTions in parallel code. * Consider the size of the L1 cache for diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index 979941072b..4f5b3c5c42 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -1847,7 +1847,7 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type) typedef _Res _Signature_type(_ArgTypes...); template<typename _Func, - typename _Res2 = typename result_of<_Func(_ArgTypes...)>::type> + typename _Res2 = typename result_of<_Func&(_ArgTypes...)>::type> struct _Callable : __check_func_return_type<_Res2, _Res> { }; // Used so the return type convertibility checks aren't done when diff --git a/libstdc++-v3/include/std/shared_mutex b/libstdc++-v3/include/std/shared_mutex index d87ac5690e..624139bc00 100644 --- a/libstdc++-v3/include/std/shared_mutex +++ b/libstdc++-v3/include/std/shared_mutex @@ -52,7 +52,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #ifdef _GLIBCXX_HAS_GTHREADS #if __cplusplus > 201402L -// TODO: #define __cpp_lib_shared_mutex 201505 +#define __cpp_lib_shared_mutex 201505 class shared_mutex; #endif diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 53f318455b..7522e43518 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -500,6 +500,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __not_<is_constructible<_Elements..., _SrcTuple>> >::value; } + template<typename... _UElements> + static constexpr bool _NotSameTuple() + { + return __not_<is_same<tuple<_Elements...>, + typename remove_const< + typename remove_reference<_UElements...>::type + >::type>>::value; + } }; template<typename... _Elements> @@ -534,6 +542,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return true; } + template<typename... _UElements> + static constexpr bool _NotSameTuple() + { + return true; + } }; /// Primary class template, tuple @@ -611,7 +624,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Elements...>; template<typename... _UElements, typename - enable_if<_TMC<_UElements...>::template + enable_if< + _TC<sizeof...(_UElements) == 1, _Elements...>::template + _NotSameTuple<_UElements...>() + && _TMC<_UElements...>::template _MoveConstructibleTuple<_UElements...>() && _TMC<_UElements...>::template _ImplicitlyMoveConvertibleTuple<_UElements...>() @@ -621,7 +637,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _Inherited(std::forward<_UElements>(__elements)...) { } template<typename... _UElements, typename - enable_if<_TMC<_UElements...>::template + enable_if< + _TC<sizeof...(_UElements) == 1, _Elements...>::template + _NotSameTuple<_UElements...>() + && _TMC<_UElements...>::template _MoveConstructibleTuple<_UElements...>() && !_TMC<_UElements...>::template _ImplicitlyMoveConvertibleTuple<_UElements...>() diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 3a2b546b22..00df22e3eb 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -156,7 +156,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus > 201402L -#define __cpp_lib_logical_traits 201511 +#define __cpp_lib_logical_traits 201510 template<typename... _Bn> struct conjunction diff --git a/libstdc++-v3/src/c++11/codecvt.cc b/libstdc++-v3/src/c++11/codecvt.cc index 327beb6b91..b60691cf2a 100644 --- a/libstdc++-v3/src/c++11/codecvt.cc +++ b/libstdc++-v3/src/c++11/codecvt.cc @@ -789,7 +789,11 @@ do_in(state_type&, const extern_type* __from, const extern_type* __from_end, { range<const char> from{ __from, __from_end }; range<char16_t> to{ __to, __to_end }; - auto res = ucs2_in(from, to, _M_maxcode, _M_mode); + codecvt_mode mode = codecvt_mode(_M_mode & (consume_header|generate_header)); +#if __BYTE_ORDER__ != __ORDER_BIG_ENDIAN__ + mode = codecvt_mode(mode | little_endian); +#endif + auto res = ucs2_in(from, to, _M_maxcode, mode); __from_next = from.next; __to_next = to.next; return res; @@ -1264,7 +1268,7 @@ do_in(state_type&, const extern_type* __from, const extern_type* __from_end, { range<const char> from{ __from, __from_end }; range<char16_t> to{ __to, __to_end }; - codecvt_mode mode = codecvt_mode(_M_mode | (consume_header|generate_header)); + codecvt_mode mode = codecvt_mode(_M_mode & (consume_header|generate_header)); #if __BYTE_ORDER__ != __ORDER_BIG_ENDIAN__ mode = codecvt_mode(mode | little_endian); #endif diff --git a/libstdc++-v3/src/c++11/cow-stdexcept.cc b/libstdc++-v3/src/c++11/cow-stdexcept.cc index a0f505c218..31a89dfd55 100644 --- a/libstdc++-v3/src/c++11/cow-stdexcept.cc +++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc @@ -292,6 +292,7 @@ _txnal_cow_string_c_str(const void* that) return (const char*) txnal_read_ptr((void**)&bs->_M_dataplus._M_p); } +#if _GLIBCXX_USE_DUAL_ABI const char* _txnal_sso_string_c_str(const void* that) { @@ -299,6 +300,7 @@ _txnal_sso_string_c_str(const void* that) (void* const*)const_cast<char* const*>( &((const std::__sso_string*) that)->_M_s._M_p)); } +#endif void _txnal_cow_string_D1_commit(void* data) @@ -344,9 +346,24 @@ _txnal_runtime_error_get_msg(void* e) // result in undefined behavior, which is in this case not initializing this // string. #if _GLIBCXX_USE_DUAL_ABI -#define CTORDTORSTRINGCSTR(s) _txnal_sso_string_c_str((s)) +#define CTORS_FROM_SSOSTRING(NAME, CLASS, BASE) \ +void \ +_ZGTtNSt##NAME##C1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE( \ + CLASS* that, const std::__sso_string& s) \ +{ \ + CLASS e(""); \ + _ITM_memcpyRnWt(that, &e, sizeof(CLASS)); \ + /* Get the C string from the SSO string. */ \ + _txnal_cow_string_C1_for_exceptions(_txnal_##BASE##_get_msg(that), \ + _txnal_sso_string_c_str(&s), that); \ +} \ +void \ +_ZGTtNSt##NAME##C2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE( \ + CLASS*, const std::__sso_string&) __attribute__((alias \ +("_ZGTtNSt" #NAME \ + "C1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE"))); #else -#define CTORDTORSTRINGCSTR(s) "" +#define CTORS_FROM_SSOSTRING(NAME, CLASS, BASE) #endif // This macro defines transaction constructors and destructors for a specific @@ -373,21 +390,7 @@ _ZGTtNSt##NAME##C1EPKc (CLASS* that, const char* s) \ void \ _ZGTtNSt##NAME##C2EPKc (CLASS*, const char*) \ __attribute__((alias ("_ZGTtNSt" #NAME "C1EPKc"))); \ -void \ -_ZGTtNSt##NAME##C1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE( \ - CLASS* that, const std::__sso_string& s) \ -{ \ - CLASS e(""); \ - _ITM_memcpyRnWt(that, &e, sizeof(CLASS)); \ - /* Get the C string from the SSO string. */ \ - _txnal_cow_string_C1_for_exceptions(_txnal_##BASE##_get_msg(that), \ - CTORDTORSTRINGCSTR(&s), that); \ -} \ -void \ -_ZGTtNSt##NAME##C2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE( \ - CLASS*, const std::__sso_string&) __attribute__((alias \ -("_ZGTtNSt" #NAME \ - "C1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE"))); \ +CTORS_FROM_SSOSTRING(NAME, CLASS, BASE) \ void \ _ZGTtNSt##NAME##D1Ev(CLASS* that) \ { _txnal_cow_string_D1(_txnal_##BASE##_get_msg(that)); } \ diff --git a/libstdc++-v3/src/filesystem/ops.cc b/libstdc++-v3/src/filesystem/ops.cc index c32197e92c..9fb5b639fc 100644 --- a/libstdc++-v3/src/filesystem/ops.cc +++ b/libstdc++-v3/src/filesystem/ops.cc @@ -220,8 +220,9 @@ fs::canonical(const path& p, const path& base) { error_code ec; path can = canonical(p, base, ec); - if (ec.value()) - _GLIBCXX_THROW_OR_ABORT(filesystem_error("cannot canonicalize", p, ec)); + if (ec) + _GLIBCXX_THROW_OR_ABORT(filesystem_error("cannot canonicalize", p, base, + ec)); return can; } @@ -249,7 +250,7 @@ namespace typedef struct ::stat stat_type; inline fs::file_type - make_file_type(const stat_type& st) + make_file_type(const stat_type& st) noexcept { using fs::file_type; #ifdef _GLIBCXX_HAVE_S_ISREG @@ -273,7 +274,7 @@ namespace } inline fs::file_status - make_file_status(const stat_type& st) + make_file_status(const stat_type& st) noexcept { return fs::file_status{ make_file_type(st), @@ -282,13 +283,13 @@ namespace } inline bool - is_not_found_errno(int err) + is_not_found_errno(int err) noexcept { return err == ENOENT || err == ENOTDIR; } inline fs::file_time_type - file_time(const stat_type& st) + file_time(const stat_type& st) noexcept { using namespace std::chrono; return fs::file_time_type{ @@ -300,6 +301,17 @@ namespace }; } + // Returns true if the file descriptor was successfully closed, + // otherwise returns false and the reason will be in errno. + inline bool + close_fd(int fd) + { + while (::close(fd)) + if (errno != EINTR) + return false; + return true; + } + bool do_copy_file(const fs::path& from, const fs::path& to, fs::copy_options option, @@ -376,7 +388,8 @@ namespace } struct CloseFD { - ~CloseFD() { if (fd != -1) ::close(fd); } + ~CloseFD() { if (fd != -1) close_fd(fd); } + bool close() { return close_fd(std::exchange(fd, -1)); } int fd; }; @@ -401,34 +414,49 @@ namespace return false; } +#ifdef _GLIBCXX_USE_FCHMOD + if (::fchmod(out.fd, from_st->st_mode)) +#elif _GLIBCXX_USE_FCHMODAT + if (::fchmodat(AT_FDCWD, to.c_str(), from_st->st_mode, 0)) +#else + if (::chmod(to.c_str(), from_st->st_mode)) +#endif + { + ec.assign(errno, std::generic_category()); + return false; + } + #ifdef _GLIBCXX_USE_SENDFILE - auto n = ::sendfile(out.fd, in.fd, nullptr, from_st->st_size); + const auto n = ::sendfile(out.fd, in.fd, nullptr, from_st->st_size); if (n != from_st->st_size) { ec.assign(errno, std::generic_category()); return false; } + if (!out.close() || !in.close()) + { + ec.assign(errno, std::generic_category()); + return false; + } #else __gnu_cxx::stdio_filebuf<char> sbin(in.fd, std::ios::in); __gnu_cxx::stdio_filebuf<char> sbout(out.fd, std::ios::out); - if ( !(std::ostream(&sbout) << &sbin) ) + if (sbin.is_open()) + in.fd = -1; + if (sbout.is_open()) + out.fd = -1; + if (from_st->st_size && !(std::ostream(&sbout) << &sbin)) { ec = std::make_error_code(std::errc::io_error); return false; } -#endif - -#ifdef _GLIBCXX_USE_FCHMOD - if (::fchmod(out.fd, from_st->st_mode)) -#elif _GLIBCXX_USE_FCHMODAT - if (::fchmodat(AT_FDCWD, to.c_str(), from_st->st_mode, 0)) -#else - if (::chmod(to.c_str(), from_st->st_mode)) -#endif + if (!sbout.close() || !sbin.close()) { ec.assign(errno, std::generic_category()); return false; } +#endif + ec.clear(); return true; } @@ -439,13 +467,15 @@ void fs::copy(const path& from, const path& to, copy_options options, error_code& ec) noexcept { - bool skip_symlinks = is_set(options, copy_options::skip_symlinks); - bool create_symlinks = is_set(options, copy_options::create_symlinks); - bool use_lstat = create_symlinks || skip_symlinks; + const bool skip_symlinks = is_set(options, copy_options::skip_symlinks); + const bool create_symlinks = is_set(options, copy_options::create_symlinks); + const bool copy_symlinks = is_set(options, copy_options::copy_symlinks); + const bool use_lstat = create_symlinks || skip_symlinks; file_status f, t; stat_type from_st, to_st; - if (use_lstat + // N4099 doesn't check copy_symlinks here, but I think that's a defect. + if (use_lstat || copy_symlinks ? ::lstat(from.c_str(), &from_st) : ::stat(from.c_str(), &from_st)) { @@ -488,7 +518,7 @@ fs::copy(const path& from, const path& to, copy_options options, { if (skip_symlinks) ec.clear(); - else if (!exists(t) && is_set(options, copy_options::copy_symlinks)) + else if (!exists(t) && copy_symlinks) copy_symlink(from, to, ec); else // Not clear what should be done here. @@ -630,22 +660,26 @@ namespace bool create_dir(const fs::path& p, fs::perms perm, std::error_code& ec) { + bool created = false; #ifdef _GLIBCXX_HAVE_SYS_STAT_H ::mode_t mode = static_cast<std::underlying_type_t<fs::perms>>(perm); if (::mkdir(p.c_str(), mode)) { - ec.assign(errno, std::generic_category()); - return false; + const int err = errno; + if (err != EEXIST || !is_directory(p)) + ec.assign(err, std::generic_category()); + else + ec.clear(); } else { ec.clear(); - return true; + created = true; } #else ec = std::make_error_code(std::errc::not_supported); - return false; #endif + return created; } } // namespace @@ -1050,6 +1084,28 @@ fs::permissions(const path& p, perms prms) void fs::permissions(const path& p, perms prms, error_code& ec) noexcept { + const bool add = is_set(prms, perms::add_perms); + const bool remove = is_set(prms, perms::remove_perms); + if (add && remove) + { + ec = std::make_error_code(std::errc::invalid_argument); + return; + } + + prms &= perms::mask; + + if (add || remove) + { + auto st = status(p, ec); + if (ec) + return; + auto curr = st.permissions(); + if (add) + prms |= curr; + else + prms = curr & ~prms; + } + #if _GLIBCXX_USE_FCHMODAT if (::fchmodat(AT_FDCWD, p.c_str(), static_cast<mode_t>(prms), 0)) #else @@ -1138,7 +1194,7 @@ fs::remove_all(const path& p, error_code& ec) noexcept uintmax_t count = 0; if (ec.value() == 0 && fs.type() == file_type::directory) for (directory_iterator d(p, ec), end; ec.value() == 0 && d != end; ++d) - count += fs::remove(d->path(), ec); + count += fs::remove_all(d->path(), ec); if (ec.value()) return -1; return fs::remove(p, ec) ? ++count : -1; // fs:remove() calls ec.clear() diff --git a/libstdc++-v3/testsuite/20_util/function/cons/refqual.cc b/libstdc++-v3/testsuite/20_util/function/cons/refqual.cc new file mode 100644 index 0000000000..d3744eefc8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/cons/refqual.cc @@ -0,0 +1,31 @@ +// Copyright (C) 2016 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <functional> + +struct F { + void operator()() && { } + int operator()() & { return 0; } +}; + +int main() { + F f; + std::function<int()> ff{f}; + return ff(); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/element_accepts_anything_byval.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/element_accepts_anything_byval.cc new file mode 100644 index 0000000000..fe9bea678a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/element_accepts_anything_byval.cc @@ -0,0 +1,30 @@ +// Copyright (C) 2016 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <tuple> +using namespace std; + +struct Something { + Something() { } + template <typename T> Something(T) { } +}; + +int main() { + tuple<Something> t1; + tuple<Something> t2 = t1; +} + diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy.cc index 2ed238a336..110f4d9d92 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy.cc @@ -21,9 +21,9 @@ #include <testsuite_hooks.h> #include <testsuite_allocator.h> -#if _GLIBCXX_USE_CXX11_ABI && defined(_GLIBCXX_USE_WCHAR_T) -using C = char; -const C c = 'a'; +#if _GLIBCXX_USE_CXX11_ABI +using C = wchar_t; +const C c = L'a'; using traits = std::char_traits<C>; using __gnu_test::propagating_allocator; diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc index fefa77f85d..3ac15bbf82 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc @@ -21,9 +21,9 @@ #include <testsuite_hooks.h> #include <testsuite_allocator.h> -#if _GLIBCXX_USE_CXX11_ABI && defined(_GLIBCXX_USE_WCHAR_T) -using C = char; -const C c = 'a'; +#if _GLIBCXX_USE_CXX11_ABI +using C = wchar_t; +const C c = L'a'; using traits = std::char_traits<C>; using __gnu_test::propagating_allocator; diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/minimal.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/minimal.cc index 3306438f81..1563abbb2d 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/minimal.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/minimal.cc @@ -22,7 +22,7 @@ #include <testsuite_hooks.h> #include <testsuite_allocator.h> -#if _GLIBCXX_USE_CXX11_ABI && defined(_GLIBCXX_USE_WCHAR_T) +#if _GLIBCXX_USE_CXX11_ABI using C = wchar_t; const C c = L'a'; using traits = std::char_traits<C>; diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move.cc index 84504bc40f..1cee2ac334 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move.cc @@ -21,9 +21,9 @@ #include <testsuite_hooks.h> #include <testsuite_allocator.h> -#if _GLIBCXX_USE_CXX11_ABI && defined(_GLIBCXX_USE_WCHAR_T) -using C = char; -const C c = 'a'; +#if _GLIBCXX_USE_CXX11_ABI +using C = wchar_t; +const C c = L'a'; using traits = std::char_traits<C>; using __gnu_test::uneq_allocator; diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc index d1efc0bf9a..8c94d79860 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc @@ -21,9 +21,9 @@ #include <testsuite_hooks.h> #include <testsuite_allocator.h> -#if _GLIBCXX_USE_CXX11_ABI && defined(_GLIBCXX_USE_WCHAR_T) -using C = char; -const C c = 'a'; +#if _GLIBCXX_USE_CXX11_ABI +using C = wchar_t; +const C c = L'a'; using traits = std::char_traits<C>; using __gnu_test::propagating_allocator; diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/noexcept.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/noexcept.cc index 0ed6940db9..6c462a6bd6 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/noexcept.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/noexcept.cc @@ -21,9 +21,9 @@ #include <string> #include <testsuite_allocator.h> -#if _GLIBCXX_USE_CXX11_ABI && defined(_GLIBCXX_USE_WCHAR_T) -using C = char; -const C c = 'a'; +#if _GLIBCXX_USE_CXX11_ABI +using C = wchar_t; +const C c = L'a'; using traits = std::char_traits<C>; using __gnu_test::propagating_allocator; diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/swap.cc b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/swap.cc index dd496e9316..667d47505d 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/swap.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/swap.cc @@ -21,9 +21,9 @@ #include <testsuite_hooks.h> #include <testsuite_allocator.h> -#if _GLIBCXX_USE_CXX11_ABI && defined(_GLIBCXX_USE_WCHAR_T) -using C = char; -const C c = 'a'; +#if _GLIBCXX_USE_CXX11_ABI +using C = wchar_t; +const C c = L'a'; using traits = std::char_traits<C>; using __gnu_test::propagating_allocator; diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/69703.cc b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/69703.cc new file mode 100644 index 0000000000..745d2c2791 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/69703.cc @@ -0,0 +1,103 @@ +// Copyright (C) 2016 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <codecvt> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + const char out[] = "abc"; + char16_t in[4]; + std::codecvt_utf8<char16_t> cvt; + std::mbstate_t st; + const char* no; + char16_t* ni; + auto res = cvt.in(st, out, out+3, no, in, in+3, ni); + VERIFY( res == std::codecvt_base::ok ); + VERIFY( in[0] == u'a' ); + VERIFY( in[1] == u'b' ); + VERIFY( in[2] == u'c' ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + const char out[] = "abc"; + char16_t in[4]; + std::codecvt_utf8<char16_t, 0x10ffff, std::little_endian> cvt; + std::mbstate_t st; + const char* no; + char16_t* ni; + auto res = cvt.in(st, out, out+3, no, in, in+3, ni); + VERIFY( res == std::codecvt_base::ok ); + VERIFY( in[0] == u'a' ); + VERIFY( in[1] == u'b' ); + VERIFY( in[2] == u'c' ); +} + +void +test03() +{ + bool test __attribute__((unused)) = true; + + const char out[] = "abc"; + char32_t in[4]; + std::codecvt_utf8<char32_t> cvt; + std::mbstate_t st; + const char* no; + char32_t* ni; + auto res = cvt.in(st, out, out+3, no, in, in+3, ni); + VERIFY( res == std::codecvt_base::ok ); + VERIFY( in[0] == U'a' ); + VERIFY( in[1] == U'b' ); + VERIFY( in[2] == U'c' ); +} + + +void +test04() +{ + bool test __attribute__((unused)) = true; + + const char out[] = "abc"; + char32_t in[4]; + std::codecvt_utf8<char32_t, 0x10ffff, std::little_endian> cvt; + std::mbstate_t st; + const char* no; + char32_t* ni; + auto res = cvt.in(st, out, out+3, no, in, in+3, ni); + VERIFY( res == std::codecvt_base::ok ); + VERIFY( in[0] == U'a' ); + VERIFY( in[1] == U'b' ); + VERIFY( in[2] == U'c' ); +} + +int +main() +{ + test01(); + test02(); + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/66855.cc b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/66855.cc index 05e5bc68f2..49b750f91e 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/66855.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/66855.cc @@ -45,8 +45,35 @@ test01() VERIFY( buf[3] == utf16[3] ); } +void +test02() +{ + // Endianness flag should make no difference. + std::codecvt_utf8_utf16<char16_t, 0x10ffff, std::little_endian> cvt; + char16_t utf16[] = u"\ub098\ub294\ud0dc\uc624"; + const char16_t* nf16; + char utf8[16]; + char* nt8; + std::mbstate_t st{}; + auto res = cvt.out(st, utf16, utf16+4, nf16, utf8, utf8+16, nt8); + VERIFY( res == std::codecvt_base::ok ); + + st = {}; + char16_t buf[4] = {}; + const char* nf8 = nt8; + char16_t* nt16; + res = cvt.in(st, utf8, nf8, nf8, buf, buf+4, nt16); + VERIFY( res == std::codecvt_base::ok ); + VERIFY( nt16 == buf+4 ); + VERIFY( buf[0] == utf16[0] ); + VERIFY( buf[1] == utf16[1] ); + VERIFY( buf[2] == utf16[2] ); + VERIFY( buf[3] == utf16[3] ); +} + int main() { test01(); + test02(); } diff --git a/libstdc++-v3/testsuite/23_containers/set/allocator/71964.cc b/libstdc++-v3/testsuite/23_containers/set/allocator/71964.cc new file mode 100644 index 0000000000..f13828feff --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/allocator/71964.cc @@ -0,0 +1,71 @@ +// Copyright (C) 2016 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <set> +#include <testsuite_hooks.h> + +template<typename T> + struct mv_allocator + { + using value_type = T; + using size_type = unsigned; + + mv_allocator() + : moved_to(false), moved_from(false) { } + + template<typename U> + mv_allocator(const mv_allocator<U> & a) + : moved_to(a.moved_to), moved_from(a.moved_from) { } + + mv_allocator(const mv_allocator &) = default; + + mv_allocator(mv_allocator && a) noexcept : moved_to(true) + { + a.moved_from = true; + } + + T* allocate(unsigned n) { return std::allocator<T>{}.allcoate(n); } + void deallocate(T* p, unsigned n) { std::allocator<T>{}.deallocate(p, n); } + + bool moved_to; + bool moved_from; + }; + +template<typename T, typename U> +bool +operator==(const mv_allocator<T>&, const mv_allocator<U>&) { return true; } + +template<typename T, typename U> +bool +operator!=(const mv_allocator<T>&, const mv_allocator<U>&) { return false; } + +void +test01() +{ + std::set<int, std::less<int>, mv_allocator<int>> s; + auto t = std::move(s); + VERIFY( s.get_allocator().moved_from ); + VERIFY( t.get_allocator().moved_to ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/binary_search/partitioned.cc b/libstdc++-v3/testsuite/25_algorithms/binary_search/partitioned.cc new file mode 100644 index 0000000000..63a6cada97 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/binary_search/partitioned.cc @@ -0,0 +1,67 @@ +// Copyright (C) 2016 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -D_GLIBCXX_DEBUG" } + +#include <algorithm> +#include <functional> +#include <testsuite_iterators.h> +#include <testsuite_hooks.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +struct X +{ + int val; + + bool odd() const { return val % 2; } + + // Partitioned so that all odd values come before even values: + bool operator<(const X& x) const { return this->odd() && !x.odd(); } +}; + +void +test01() +{ + bool test __attribute((unused)) = true; + + // Test with range that is partitioned, but not sorted. + X seq[] = { 1, 3, 5, 7, 1, 6, 4 }; + test_container<X, forward_iterator_wrapper> c(seq); + + auto b1 = std::binary_search(c.begin(), c.end(), X{2}); + VERIFY( b1 ); + auto b2 = std::binary_search(c.begin(), c.end(), X{2}, std::less<X>{}); + VERIFY( b2 ); + + auto b3 = std::binary_search(c.begin(), c.end(), X{9}); + VERIFY( b3 ); + auto b4 = std::binary_search(c.begin(), c.end(), X{9}, std::less<X>{}); + VERIFY( b4 ); + + auto b5 = std::binary_search(seq, seq+5, X{2}); + VERIFY( !b5 ); + auto b6 = std::binary_search(seq, seq+5, X{2}, std::less<X>{}); + VERIFY( !b6 ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal_range/partitioned.cc b/libstdc++-v3/testsuite/25_algorithms/equal_range/partitioned.cc new file mode 100644 index 0000000000..d3a43d06a5 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal_range/partitioned.cc @@ -0,0 +1,66 @@ +// Copyright (C) 2016 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -D_GLIBCXX_DEBUG" } + +#include <algorithm> +#include <functional> +#include <testsuite_iterators.h> +#include <testsuite_hooks.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +struct X +{ + int val; + + bool odd() const { return val % 2; } + + // Partitioned so that all odd values come before even values: + bool operator<(const X& x) const { return this->odd() && !x.odd(); } +}; + +void +test01() +{ + bool test __attribute((unused)) = true; + + // Test with range that is partitioned, but not sorted. + X seq[] = { 1, 3, 5, 7, 1, 6, 4, 2 }; + test_container<X, forward_iterator_wrapper> c(seq); + + auto part1 = std::equal_range(c.begin(), c.end(), X{2}); + VERIFY( part1.first != c.end() && part1.second == c.end() ); + VERIFY( part1.first->val == 6 ); + auto part2 = std::equal_range(c.begin(), c.end(), X{2}, std::less<X>{}); + VERIFY( part2.first != c.end() && part1.second == c.end() ); + VERIFY( part2.first->val == 6 ); + + auto part3 = std::equal_range(c.begin(), c.end(), X{9}); + VERIFY( part3.first == c.begin() && part3.second != c.end() ); + VERIFY( part3.second->val == 6 ); + auto part4 = std::equal_range(c.begin(), c.end(), X{9}, std::less<X>{}); + VERIFY( part4.first == c.begin() && part4.second != c.end() ); + VERIFY( part4.second->val == 6 ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/71545.cc b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/71545.cc new file mode 100644 index 0000000000..6c9cd12cfe --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/71545.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2016 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -D_GLIBCXX_DEBUG" } +// { dg-do link } + +#include <algorithm> + +struct X { }; + +bool operator<(X, int) { return true; } +bool operator<(int, X) { return false; } + +bool operator<(X, X); // undefined (PR libstdc++/71545) + +int main() +{ + X x[1]; + int i[1]; + std::lexicographical_compare(x, x+1, i, i+1); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lower_bound/partitioned.cc b/libstdc++-v3/testsuite/25_algorithms/lower_bound/partitioned.cc new file mode 100644 index 0000000000..bba0b66ea8 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lower_bound/partitioned.cc @@ -0,0 +1,100 @@ +// Copyright (C) 2016 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -D_GLIBCXX_DEBUG" } + +#include <algorithm> +#include <functional> +#include <testsuite_iterators.h> +#include <testsuite_hooks.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +struct X +{ + int val; + + bool odd() const { return val % 2; } + + // Partitioned so that all odd values come before even values: + bool operator<(const X& x) const { return this->odd() && !x.odd(); } +}; + +void +test01() +{ + bool test __attribute((unused)) = true; + + // Test with range that is partitioned, but not sorted. + X seq[] = { 1, 3, 5, 7, 1, 6, 4, 2 }; + test_container<X, forward_iterator_wrapper> c(seq); + + auto part1 = std::lower_bound(c.begin(), c.end(), X{2}); + VERIFY( part1 != c.end() ); + VERIFY( part1->val == 6 ); + auto part2 = std::lower_bound(c.begin(), c.end(), X{2}, std::less<X>{}); + VERIFY( part2 != c.end() ); + VERIFY( part2->val == 6 ); + + auto part3 = std::lower_bound(c.begin(), c.end(), X{9}); + VERIFY( part3 != c.end() ); + VERIFY( part3->val == 1 ); + auto part4 = std::lower_bound(c.begin(), c.end(), X{9}, std::less<X>{}); + VERIFY( part4 != c.end() ); + VERIFY( part4->val == 1 ); +} + +struct Y +{ + double val; + + // Not irreflexive, so not a strict weak order. + bool operator<(const Y& y) const { return val < int(y.val); } +}; + +void +test02() +{ + bool test __attribute((unused)) = true; + + // Test that Debug Mode checks don't fire (libstdc++/71545) + + Y seq[] = { -0.1, 1.2, 5.0, 5.2, 5.1, 5.9, 5.5, 6.0 }; + test_container<Y, forward_iterator_wrapper> c(seq); + + auto part1 = std::lower_bound(c.begin(), c.end(), Y{5.5}); + VERIFY( part1 != c.end() ); + VERIFY( part1->val == 5.0 ); + auto part2 = std::lower_bound(c.begin(), c.end(), Y{5.5}, std::less<Y>{}); + VERIFY( part2 != c.end() ); + VERIFY( part2->val == 5.0 ); + + auto part3 = std::lower_bound(c.begin(), c.end(), Y{1.0}); + VERIFY( part3 != c.end() ); + VERIFY( part3->val == 1.2 ); + auto part4 = std::lower_bound(c.begin(), c.end(), Y{1.0}, std::less<Y>{}); + VERIFY( part4 != c.end() ); + VERIFY( part4->val == 1.2 ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/upper_bound/partitioned.cc b/libstdc++-v3/testsuite/25_algorithms/upper_bound/partitioned.cc new file mode 100644 index 0000000000..96cfb2e2de --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/upper_bound/partitioned.cc @@ -0,0 +1,98 @@ +// Copyright (C) 2016 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -D_GLIBCXX_DEBUG" } + +#include <algorithm> +#include <functional> +#include <testsuite_iterators.h> +#include <testsuite_hooks.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +struct X +{ + int val; + + bool odd() const { return val % 2; } + + // Partitioned so that all odd values come before even values: + bool operator<(const X& x) const { return this->odd() && !x.odd(); } +}; + +void +test01() +{ + bool test __attribute((unused)) = true; + + // Test with range that is partitioned, but not sorted. + X seq[] = { 1, 3, 5, 7, 1, 6, 4, 2 }; + test_container<X, forward_iterator_wrapper> c(seq); + + auto part1 = std::upper_bound(c.begin(), c.end(), X{2}); + VERIFY( part1 == c.end() ); + auto part2 = std::upper_bound(c.begin(), c.end(), X{2}, std::less<X>{}); + VERIFY( part2 == c.end() ); + + auto part3 = std::upper_bound(c.begin(), c.end(), X{9}); + VERIFY( part3 != c.end() ); + VERIFY( part3->val == 6 ); + auto part4 = std::upper_bound(c.begin(), c.end(), X{9}, std::less<X>{}); + VERIFY( part3 != c.end() ); + VERIFY( part4->val == 6 ); +} + +struct Y +{ + double val; + + // Not irreflexive, so not a strict weak order. + bool operator<(const Y& y) const { return val < (int)y.val; } +}; + +void +test02() +{ + bool test __attribute((unused)) = true; + + // Test that Debug Mode checks don't fire (libstdc++/71545) + + Y seq[] = { -0.1, 1.2, 5.0, 5.2, 5.1, 5.9, 5.5, 6.0 }; + test_container<Y, forward_iterator_wrapper> c(seq); + + auto part1 = std::upper_bound(c.begin(), c.end(), Y{5.5}); + VERIFY( part1 != c.end() ); + VERIFY( part1->val == 6.0 ); + auto part2 = std::upper_bound(c.begin(), c.end(), Y{5.5}, std::less<Y>{}); + VERIFY( part2 != c.end() ); + VERIFY( part2->val == 6.0 ); + + auto part3 = std::upper_bound(c.begin(), c.end(), Y{1.0}); + VERIFY( part3 != c.end() ); + VERIFY( part3->val == 5.0 ); + auto part4 = std::upper_bound(c.begin(), c.end(), Y{1.0}, std::less<Y>{}); + VERIFY( part4 != c.end() ); + VERIFY( part4->val == 5.0 ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/any/misc/any_cast.cc b/libstdc++-v3/testsuite/experimental/any/misc/any_cast.cc index ce3f213588..bb0f754f54 100644 --- a/libstdc++-v3/testsuite/experimental/any/misc/any_cast.cc +++ b/libstdc++-v3/testsuite/experimental/any/misc/any_cast.cc @@ -77,8 +77,38 @@ void test02() } } +static int move_count = 0; + +void test03() +{ + struct MoveEnabled + { + MoveEnabled(MoveEnabled&&) + { + ++move_count; + } + MoveEnabled() = default; + MoveEnabled(const MoveEnabled&) = default; + }; + MoveEnabled m; + MoveEnabled m2 = any_cast<MoveEnabled>(any(m)); + VERIFY(move_count == 1); + MoveEnabled&& m3 = any_cast<MoveEnabled&&>(any(m)); + VERIFY(move_count == 1); + struct MoveDeleted + { + MoveDeleted(MoveDeleted&&) = delete; + MoveDeleted() = default; + MoveDeleted(const MoveDeleted&) = default; + }; + MoveDeleted md; + MoveDeleted&& md2 = any_cast<MoveDeleted>(any(std::move(md))); + MoveDeleted&& md3 = any_cast<MoveDeleted&&>(any(std::move(md))); +} + int main() { test01(); test02(); + test03(); } diff --git a/libstdc++-v3/testsuite/experimental/any/misc/any_cast_neg.cc b/libstdc++-v3/testsuite/experimental/any/misc/any_cast_neg.cc index 1361db89d4..82957a1f54 100644 --- a/libstdc++-v3/testsuite/experimental/any/misc/any_cast_neg.cc +++ b/libstdc++-v3/testsuite/experimental/any/misc/any_cast_neg.cc @@ -26,5 +26,5 @@ void test01() using std::experimental::any_cast; const any y(1); - any_cast<int&>(y); // { dg-error "qualifiers" "" { target { *-*-* } } 353 } + any_cast<int&>(y); // { dg-error "qualifiers" "" { target { *-*-* } } 368 } } diff --git a/libstdc++-v3/testsuite/experimental/feat-cxx14.cc b/libstdc++-v3/testsuite/experimental/feat-cxx14.cc index 2cc31ca03b..42b633f6ef 100644 --- a/libstdc++-v3/testsuite/experimental/feat-cxx14.cc +++ b/libstdc++-v3/testsuite/experimental/feat-cxx14.cc @@ -11,6 +11,8 @@ #include <complex> #include <iomanip> #include <shared_mutex> +#include <map> +#include <set> #ifndef __cpp_lib_integer_sequence # error "__cpp_lib_integer_sequence" @@ -78,11 +80,11 @@ # error "__cpp_lib_complex_udls != 201309" #endif -//#ifndef __cpp_lib_generic_associative_lookup -//# error "__cpp_lib_generic_associative_lookup" -//#elif __cpp_lib_generic_associative_lookup != 201304 -//# error "__cpp_lib_generic_associative_lookup != 201304" -//#endif +#ifndef __cpp_lib_generic_associative_lookup +# error "__cpp_lib_generic_associative_lookup" +#elif __cpp_lib_generic_associative_lookup != 201304 +# error "__cpp_lib_generic_associative_lookup != 201304" +#endif //#ifndef __cpp_lib_null_iterators //# error "__cpp_lib_null_iterators" @@ -119,3 +121,15 @@ #elif __cpp_lib_is_final != 201402 # error "__cpp_lib_is_final != 201402" #endif + +#ifndef __cpp_lib_is_null_pointer +# error "__cpp_lib_is_null_pointer" +#elif __cpp_lib_is_null_pointer != 201309 +# error "__cpp_lib_is_null_pointer != 201309" +#endif + +#ifndef __cpp_lib_make_reverse_iterator +# error "__cpp_lib_make_reverse_iterator" +#elif __cpp_lib_make_reverse_iterator != 201402 +# error "__cpp_lib_make_reverse_iterator != 201402" +#endif diff --git a/libstdc++-v3/testsuite/experimental/filesystem/iterators/directory_iterator.cc b/libstdc++-v3/testsuite/experimental/filesystem/iterators/directory_iterator.cc index 28b948f2b1..ffd97ce19d 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/iterators/directory_iterator.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/iterators/directory_iterator.cc @@ -70,8 +70,79 @@ test01() remove_all(p, ec); } +void +test02() +{ + bool test __attribute__((unused)) = false; + + std::error_code ec; + const auto p = __gnu_test::nonexistent_path(); + create_directory(p, fs::current_path(), ec); + create_directory_symlink(p, p / "l", ec); + VERIFY( !ec ); + + // Test post-increment (libstdc++/71005) + auto iter = fs::directory_iterator(p, ec); + VERIFY( !ec ); + VERIFY( iter != fs::directory_iterator() ); + const auto entry1 = *iter; + const auto entry2 = *iter++; + VERIFY( entry1 == entry2 ); + VERIFY( entry1.path() == p/"l" ); + VERIFY( iter == fs::directory_iterator() ); + + remove_all(p, ec); +} + +void +test03() +{ + bool test __attribute__((unused)) = false; + + std::error_code ec; + const auto p = __gnu_test::nonexistent_path(); + create_directories(p / "longer_than_small_string_buffer", ec); + VERIFY( !ec ); + + // Test for no reallocation on each dereference (this is a GNU extension) + auto iter = fs::directory_iterator(p, ec); + const auto* s1 = iter->path().c_str(); + const auto* s2 = iter->path().c_str(); + VERIFY( s1 == s2 ); + + remove_all(p, ec); +} + +void +test04() +{ + bool test __attribute__((unused)) = false; + + const fs::directory_iterator it; + VERIFY( it == fs::directory_iterator() ); +} + +void +test05() +{ + bool test __attribute__((unused)) = false; + + auto p = __gnu_test::nonexistent_path(); + create_directory(p); + create_directory_symlink(p, p / "l"); + fs::directory_iterator it(p), endit; + VERIFY( begin(it) == it ); + static_assert( noexcept(begin(it)), "begin is noexcept" ); + VERIFY( end(it) == endit ); + static_assert( noexcept(end(it)), "end is noexcept" ); +} + int main() { test01(); + test02(); + test03(); + test04(); + test05(); } diff --git a/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc b/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc index 5d2e45b2e6..b44ff3f9e9 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc @@ -97,8 +97,83 @@ test01() remove_all(p, ec); } +void +test02() +{ + bool test __attribute__((unused)) = false; + + std::error_code ec; + const auto p = __gnu_test::nonexistent_path(); + create_directories(p / "d1/d2", ec); + VERIFY( !ec ); + + // Test post-increment (libstdc++/71005) + auto iter = fs::recursive_directory_iterator(p, ec); + VERIFY( !ec ); + VERIFY( iter != fs::recursive_directory_iterator() ); + const auto entry1 = *iter; + const auto entry2 = *iter++; + VERIFY( entry1 == entry2 ); + VERIFY( entry1.path() == p/"d1" ); + const auto entry3 = *iter; + const auto entry4 = *iter++; + VERIFY( entry3 == entry4 ); + VERIFY( entry3.path() == p/"d1/d2" ); + VERIFY( iter == fs::recursive_directory_iterator() ); + + remove_all(p, ec); +} + +void +test03() +{ + bool test __attribute__((unused)) = false; + + std::error_code ec; + const auto p = __gnu_test::nonexistent_path(); + create_directories(p / "longer_than_small_string_buffer", ec); + VERIFY( !ec ); + + // Test for no reallocation on each dereference (this is a GNU extension) + auto iter = fs::recursive_directory_iterator(p, ec); + const auto* s1 = iter->path().c_str(); + const auto* s2 = iter->path().c_str(); + VERIFY( s1 == s2 ); + + remove_all(p, ec); +} + +void +test04() +{ + bool test __attribute__((unused)) = false; + + // libstdc++/71004 + const fs::recursive_directory_iterator it; + VERIFY( it == fs::recursive_directory_iterator() ); +} + +void +test05() +{ + bool test __attribute__((unused)) = false; + + auto p = __gnu_test::nonexistent_path(); + create_directory(p); + create_directory_symlink(p, p / "l"); + fs::recursive_directory_iterator it(p), endit; + VERIFY( begin(it) == it ); + static_assert( noexcept(begin(it)), "begin is noexcept" ); + VERIFY( end(it) == endit ); + static_assert( noexcept(end(it)), "end is noexcept" ); +} + int main() { test01(); + test02(); + test03(); + test04(); + test05(); } diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/canonical.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/canonical.cc index e13c4bfe0a..5b4c573eeb 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/operations/canonical.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/canonical.cc @@ -59,8 +59,28 @@ test01() VERIFY( !ec ); } +void +test02() +{ +#if __cpp_exceptions + bool test __attribute__((unused)) = false; + + fs::path p = "rel", base = __gnu_test::nonexistent_path(); + fs::path e1, e2; + try { + canonical(p, base); + } catch (const fs::filesystem_error& e) { + e1 = e.path1(); + e2 = e.path2(); + } + VERIFY( e1 == p ); + VERIFY( e2 == base ); +#endif +} + int main() { test01(); + test02(); } diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc index 9e89002d58..a5f6a3e861 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc @@ -21,34 +21,127 @@ // 15.3 Copy [fs.op.copy] #include <experimental/filesystem> +#include <fstream> #include <testsuite_fs.h> #include <testsuite_hooks.h> -using std::experimental::filesystem::path; +namespace fs = std::experimental::filesystem; +// Test error conditions. void test01() { bool test __attribute__((unused)) = false; - for (const path& p : __gnu_test::test_paths) - VERIFY( absolute(p).is_absolute() ); + auto p = __gnu_test::nonexistent_path(); + std::error_code ec; + + VERIFY( !fs::exists(p) ); + fs::copy(p, ".", fs::copy_options::none, ec); + VERIFY( ec ); + + ec.clear(); + fs::copy(".", ".", fs::copy_options::none, ec); + VERIFY( ec ); + + std::ofstream{p.native()}; + VERIFY( fs::is_directory(".") ); + VERIFY( fs::is_regular_file(p) ); + ec.clear(); + fs::copy(".", p, fs::copy_options::none, ec); + VERIFY( ec ); + + remove(p, ec); } +// Test is_symlink(f) case. void test02() { bool test __attribute__((unused)) = false; - path p1("/"); - VERIFY( absolute(p1) == p1 ); - VERIFY( absolute(p1, "/bar") == p1 ); - path p2("/foo"); - VERIFY( absolute(p2) == p2 ); - VERIFY( absolute(p2, "/bar") == p2 ); - path p3("foo"); - VERIFY( absolute(p3) != p3 ); - VERIFY( absolute(p3, "/bar") == "/bar/foo" ); + auto from = __gnu_test::nonexistent_path(); + auto to = __gnu_test::nonexistent_path(); + std::error_code ec; + + fs::create_symlink(".", from, ec); + VERIFY( !ec ); + VERIFY( fs::exists(from) ); + + fs::copy(from, to, fs::copy_options::skip_symlinks, ec); + VERIFY( !ec ); + VERIFY( !fs::exists(to) ); + + fs::copy(from, to, fs::copy_options::skip_symlinks, ec); + VERIFY( !ec ); + VERIFY( !fs::exists(to) ); + + fs::copy(from, to, + fs::copy_options::skip_symlinks|fs::copy_options::copy_symlinks, + ec); + VERIFY( !ec ); + VERIFY( !fs::exists(to) ); + + fs::copy(from, to, fs::copy_options::copy_symlinks, ec); + VERIFY( !ec ); + VERIFY( fs::exists(to) ); + + fs::copy(from, to, fs::copy_options::copy_symlinks, ec); + VERIFY( ec ); + + remove(from, ec); + remove(to, ec); +} + +// Test is_regular_file(f) case. +void +test03() +{ + bool test __attribute__((unused)) = false; + + auto from = __gnu_test::nonexistent_path(); + auto to = __gnu_test::nonexistent_path(); + + // test empty file + std::ofstream{from.native()}; + VERIFY( fs::exists(from) ); + VERIFY( fs::file_size(from) == 0 ); + fs::copy(from, to); + VERIFY( fs::exists(to) ); + VERIFY( fs::file_size(to) == 0 ); + + remove(to); + VERIFY( !fs::exists(to) ); + std::ofstream{from.native()} << "Hello, filesystem!"; + VERIFY( fs::file_size(from) != 0 ); + fs::copy(from, to); + VERIFY( fs::exists(to) ); + VERIFY( fs::file_size(to) == fs::file_size(from) ); +} + +// Test is_directory(f) case. +void +test04() +{ + bool test __attribute__((unused)) = false; + + auto from = __gnu_test::nonexistent_path(); + auto to = __gnu_test::nonexistent_path(); + std::error_code ec; + +} + +// Test no-op cases. +void +test05() +{ + bool test __attribute__((unused)) = false; + + auto to = __gnu_test::nonexistent_path(); + std::error_code ec; + + fs::copy("/", to, fs::copy_options::create_symlinks, ec); + VERIFY( !ec ); } int @@ -56,4 +149,7 @@ main() { test01(); test02(); + test03(); + test04(); + test05(); } diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/copy_file.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/copy_file.cc new file mode 100644 index 0000000000..cdb7911135 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/copy_file.cc @@ -0,0 +1,82 @@ +// Copyright (C) 2016 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// 15.4 Copy [fs.op.copy_file] + +#include <experimental/filesystem> +#include <fstream> +#include <testsuite_fs.h> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = false; + using std::experimental::filesystem::copy_options; + std::error_code ec; + + auto from = __gnu_test::nonexistent_path(); + auto to = __gnu_test::nonexistent_path(); + + // test non-existent file + bool b = copy_file(from, to, ec); + VERIFY( !b ); + VERIFY( ec ); + VERIFY( !exists(to) ); + + // test empty file + std::ofstream{from.native()}; + VERIFY( exists(from) ); + VERIFY( file_size(from) == 0 ); + + b = copy_file(from, to); + VERIFY( b ); + VERIFY( exists(to) ); + VERIFY( file_size(to) == 0 ); + remove(to); + VERIFY( !exists(to) ); + b = copy_file(from, to, copy_options::none, ec); + VERIFY( b ); + VERIFY( !ec ); + VERIFY( exists(to) ); + VERIFY( file_size(to) == 0 ); + + std::ofstream{from.native()} << "Hello, filesystem!"; + VERIFY( file_size(from) != 0 ); + remove(to); + VERIFY( !exists(to) ); + b = copy_file(from, to); + VERIFY( b ); + VERIFY( exists(to) ); + VERIFY( file_size(to) == file_size(from) ); + remove(to); + VERIFY( !exists(to) ); + b = copy_file(from, to); + VERIFY( b ); + VERIFY( !ec ); + VERIFY( exists(to) ); + VERIFY( file_size(to) == file_size(from) ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directories.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directories.cc index 4be41a6c47..a52efe4ce5 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directories.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directories.cc @@ -65,7 +65,8 @@ test01() VERIFY( b ); VERIFY( is_directory(p/"./d4/../d5") ); - remove_all(p, ec); + std::uintmax_t count = remove_all(p, ec); + VERIFY( count == 6 ); } int diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directory.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directory.cc new file mode 100644 index 0000000000..66c2b3fb79 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/create_directory.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2016 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +#include <experimental/filesystem> +#include <testsuite_hooks.h> +#include <testsuite_fs.h> + +namespace fs = std::experimental::filesystem; + +void +test01() +{ + bool test __attribute__((unused)) = false; + std::error_code ec; + + // Test empty path. + fs::path p; + bool b = create_directory( p, ec ); + VERIFY( ec ); + VERIFY( !b ); + + // Test non-existent path + p = __gnu_test::nonexistent_path(); + VERIFY( !exists(p) ); + + b = create_directory(p, ec); // create the directory once + VERIFY( !ec ); + VERIFY( b ); + VERIFY( exists(p) ); + + // Test existing path (libstdc++/71036). + b = create_directory(p, ec); + VERIFY( !ec ); + VERIFY( !b ); + b = create_directory(p); + VERIFY( !ec ); + VERIFY( !b ); + + remove_all(p, ec); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/permissions.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/permissions.cc new file mode 100644 index 0000000000..e4148609c2 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/permissions.cc @@ -0,0 +1,51 @@ +// Copyright (C) 2016 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +// 15.26 Permissions [fs.op.permissions] + +#include <experimental/filesystem> +#include <fstream> +#include <testsuite_fs.h> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + using perms = std::experimental::filesystem::perms; + + auto p = __gnu_test::nonexistent_path(); + std::ofstream{p.native()}; + VERIFY( exists(p) ); + permissions(p, perms::owner_all); + VERIFY( status(p).permissions() == perms::owner_all ); + permissions(p, perms::group_read | perms::add_perms); + VERIFY( status(p).permissions() == (perms::owner_all | perms::group_read) ); + permissions(p, perms::group_read | perms::remove_perms); + VERIFY( status(p).permissions() == perms::owner_all ); + + remove(p); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/native/string.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/native/string.cc new file mode 100644 index 0000000000..e56fda7b95 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/native/string.cc @@ -0,0 +1,73 @@ +// Copyright (C) 2016 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -lstdc++fs" } +// { dg-require-filesystem-ts "" } + +#include <experimental/filesystem> +#include <string> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + using namespace std::experimental::filesystem; + const std::string s = "abc"; + path p(s); + + VERIFY( p.native() == s ); + VERIFY( p.c_str() == s ); + VERIFY( static_cast<std::string>(p) == s ); + + std::string s2 = p; // implicit conversion + VERIFY( s2 == p.native() ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + using namespace std::experimental::filesystem; + const char* s = "abc"; + path p(s); + + auto str = p.string<char>(); + VERIFY( str == u"abc" ); + VERIFY( str == p.string() ); + + auto strw = p.string<wchar_t>(); + VERIFY( strw == L"abc" ); + VERIFY( strw == p.wstring() ); + + auto str16 = p.string<char16_t>(); + VERIFY( str16 == u"abc" ); + VERIFY( str16 == p.u16string() ); + + auto str32 = p.string<char32_t>(); + VERIFY( str32 == U"abc" ); + VERIFY( str32 == p.u32string() ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/experimental/functional/searchers.cc b/libstdc++-v3/testsuite/experimental/functional/searchers.cc index 5e585f8232..143593fe65 100644 --- a/libstdc++-v3/testsuite/experimental/functional/searchers.cc +++ b/libstdc++-v3/testsuite/experimental/functional/searchers.cc @@ -22,6 +22,7 @@ #ifdef _GLIBCXX_USE_WCHAR_T # include <cwchar> #endif +#include <algorithm> #include <testsuite_hooks.h> using std::experimental::make_default_searcher; diff --git a/libstdc++-v3/testsuite/experimental/type_erased_allocator/1.cc b/libstdc++-v3/testsuite/experimental/memory_resource/1.cc index c000e69681..08c02e5e31 100644 --- a/libstdc++-v3/testsuite/experimental/type_erased_allocator/1.cc +++ b/libstdc++-v3/testsuite/experimental/memory_resource/1.cc @@ -1,4 +1,5 @@ // { dg-options "-std=gnu++14" } +// { dg-require-atomic-builtins "" } // Copyright (C) 2015-2016 Free Software Foundation, Inc. // @@ -17,10 +18,9 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -#include <memory> #include <experimental/memory_resource> #include <vector> -#include <bits/uses_allocator.h> +#include <cstdlib> #include <testsuite_hooks.h> #include <testsuite_allocator.h> @@ -37,6 +37,7 @@ struct A static int ctor_count; static int dtor_count; }; + int A::ctor_count = 0; int A::dtor_count = 0; @@ -44,7 +45,7 @@ struct CountedResource : public memory_resource { public: CountedResource() = default; - ~ CountedResource() = default; + ~CountedResource() = default; static size_t get_alloc_count() { return alloc_count; } static size_t get_dalloc_count() { return dalloc_count; } @@ -55,23 +56,23 @@ protected: void* do_allocate(size_t bytes, size_t alignment) { alloc_count += bytes; - if (auto ptr = std::malloc(bytes)) { + if (auto ptr = std::malloc(bytes)) return ptr; - } throw std::bad_alloc(); } void do_deallocate(void *p, size_t bytes, size_t alignment) { dalloc_count += bytes; - free(p); + std::free(p); } bool do_is_equal(const memory_resource& __other) const noexcept { return this == &__other; } }; - size_t CountedResource::alloc_count = 0; - size_t CountedResource::dalloc_count = 0; + +size_t CountedResource::alloc_count = 0; +size_t CountedResource::dalloc_count = 0; void clear() { @@ -82,8 +83,11 @@ void clear() } // memory resource -void test01() +void +test01() { + bool test __attribute((unused)) = false; + memory_resource* r = new_delete_resource(); VERIFY(get_default_resource() == r); void *p = get_default_resource()->allocate(5); @@ -102,8 +106,11 @@ void test01() } // polymorphic_allocator -void test02() +void +test02() { + bool test __attribute((unused)) = false; + clear(); { CountedResource cr; @@ -116,7 +123,11 @@ void test02() VERIFY(CountedResource::get_dalloc_count() == 5); } -void test03() { +void +test03() +{ + bool test __attribute((unused)) = false; + clear(); CountedResource cr; polymorphic_allocator<A> pa(&cr); @@ -130,7 +141,11 @@ void test03() { VERIFY(CountedResource::get_dalloc_count() == 1); } -void test04() { +void +test04() +{ + bool test __attribute((unused)) = false; + polymorphic_allocator<A> pa1(get_default_resource()); polymorphic_allocator<A> pa2(get_default_resource()); VERIFY(pa1 == pa2); @@ -138,10 +153,10 @@ void test04() { VERIFY(pa1 == pa3); } -int main() { +int main() +{ test01(); test02(); test03(); test04(); - return 0; } diff --git a/libstdc++-v3/testsuite/experimental/type_erased_allocator/1_neg.cc b/libstdc++-v3/testsuite/experimental/memory_resource/null_memory_resource.cc index 55c446eacf..09d9af0ba8 100644 --- a/libstdc++-v3/testsuite/experimental/type_erased_allocator/1_neg.cc +++ b/libstdc++-v3/testsuite/experimental/memory_resource/null_memory_resource.cc @@ -1,7 +1,6 @@ -// { dg-do run { xfail *-*-* } } // { dg-options "-std=gnu++14" } -// Copyright (C) 2015-2016 Free Software Foundation, Inc. +// Copyright (C) 2016 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 @@ -21,17 +20,34 @@ #include <experimental/memory_resource> #include <bits/uses_allocator.h> #include <testsuite_hooks.h> -#include <testsuite_allocator.h> -using std::experimental::pmr::polymorphic_allocator; -using std::experimental::pmr::null_memory_resource; using std::experimental::pmr::memory_resource; +using std::experimental::pmr::null_memory_resource; +using std::experimental::pmr::new_delete_resource; + +// null_memory_resource +void +test06() +{ + bool test __attribute((unused)) = false; -void test01() { memory_resource* r = null_memory_resource(); - auto p = r->allocate(1); + bool caught = false; + + void* p = nullptr; + try { + p = r->allocate(1); + } catch (const std::bad_alloc&) { + caught = true; + } + VERIFY( caught ); + + VERIFY( *r == *r ); + VERIFY( r->is_equal(*r) ); + VERIFY( !r->is_equal(*new_delete_resource()) ); } -int main() { - test01(); +int main() +{ + test06(); } diff --git a/libstdc++-v3/testsuite/experimental/memory_resource/resource_adaptor.cc b/libstdc++-v3/testsuite/experimental/memory_resource/resource_adaptor.cc new file mode 100644 index 0000000000..299bb72ea4 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/memory_resource/resource_adaptor.cc @@ -0,0 +1,87 @@ +// { dg-options "-std=gnu++14" } + +// Copyright (C) 2016 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <experimental/memory_resource> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +using std::experimental::pmr::memory_resource; +using std::experimental::pmr::resource_adaptor; + +template<typename T> + struct Allocator : __gnu_test::SimpleAllocator<T> + { + Allocator(int) { } // not default constructible + + template<typename U> + Allocator(const Allocator<U>&) { } + }; + +template<typename T> + bool aligned(void* p) + { + return (reinterpret_cast<std::uintptr_t>(p) % alignof(T)) == 0; + } + +// resource_adaptor +void +test05() +{ + bool test __attribute((unused)) = false; + using std::max_align_t; + using std::uintptr_t; + void* p = nullptr; + + Allocator<int> a1(1), a2(2); // minimal interface allocators + resource_adaptor<decltype(a1)> r1(a1), r2(a2); + VERIFY( r1 == r1 ); + VERIFY( r1 == r2 ); + p = r1.allocate(1); + VERIFY( aligned<max_align_t>(p) ); + r1.deallocate(p, 1); + p = r1.allocate(1, alignof(short)); + VERIFY( aligned<short>(p) ); + r1.deallocate(p, 1, alignof(short)); + p = r1.allocate(1, alignof(long)); + VERIFY( aligned<long>(p) ); + r1.deallocate(p, 1, alignof(long)); + + __gnu_test::uneq_allocator<double> a3(3), a4(4); // non-equal allocators + resource_adaptor<decltype(a3)> r3(a3), r4(a4); + VERIFY( r3 == r3 ); + VERIFY( r4 == r4 ); + VERIFY( r3 != r4 ); + p = r3.allocate(1); + VERIFY( aligned<max_align_t>(p) ); + r3.deallocate(p, 1); + p = r3.allocate(1, alignof(short)); + VERIFY( aligned<short>(p) ); + r3.deallocate(p, 1, alignof(short)); + p = r3.allocate(1, alignof(long)); + VERIFY( aligned<long>(p) ); + r3.deallocate(p, 1, alignof(long)); + + // TODO test with an allocator that doesn't use new or malloc, so + // returns pointers that are not suitably aligned for any type. +} + +int main() +{ + test05(); +} diff --git a/libstdc++-v3/testsuite/experimental/optional/cons/value.cc b/libstdc++-v3/testsuite/experimental/optional/cons/value.cc index a916951b87..123a89ede0 100644 --- a/libstdc++-v3/testsuite/experimental/optional/cons/value.cc +++ b/libstdc++-v3/testsuite/experimental/optional/cons/value.cc @@ -22,6 +22,7 @@ #include <testsuite_hooks.h> #include <vector> +#include <string> struct tracker { @@ -236,4 +237,22 @@ int main() VERIFY( result == caught ); } + + { + std::experimental::optional<std::string> os = "foo"; + struct X + { + explicit X(int) {} + X& operator=(int) {return *this;} + }; + std::experimental::optional<X> ox{42}; + std::experimental::optional<int> oi{42}; + std::experimental::optional<X> ox2{oi}; + std::experimental::optional<std::string> os2; + os2 = "foo"; + std::experimental::optional<X> ox3; + ox3 = 42; + std::experimental::optional<X> ox4; + ox4 = oi; + } } diff --git a/libstdc++-v3/testsuite/experimental/optional/cons/value_neg.cc b/libstdc++-v3/testsuite/experimental/optional/cons/value_neg.cc new file mode 100644 index 0000000000..c862a04986 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/optional/cons/value_neg.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++14" } +// { dg-do compile } + +// Copyright (C) 2013-2016 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. + +// You should have received a moved_to of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <experimental/optional> +#include <testsuite_hooks.h> + +#include <string> +#include <memory> + +int main() +{ + { + struct X + { + explicit X(int) {} + }; + std::experimental::optional<X> ox{42}; + std::experimental::optional<X> ox2 = 42; // { dg-error "conversion" } + std::experimental::optional<std::unique_ptr<int>> oup{new int}; + std::experimental::optional<std::unique_ptr<int>> oup2 = new int; // { dg-error "conversion" } + } +} diff --git a/libstdc++-v3/testsuite/experimental/propagate_const/cons/default.cc b/libstdc++-v3/testsuite/experimental/propagate_const/cons/default.cc index 6a9a8c6e3b..ed597fb2cf 100644 --- a/libstdc++-v3/testsuite/experimental/propagate_const/cons/default.cc +++ b/libstdc++-v3/testsuite/experimental/propagate_const/cons/default.cc @@ -27,6 +27,7 @@ int main() { constexpr propagate_const<int*> test1{}; static_assert(!test1.get(), ""); - propagate_const<int*> test2; - VERIFY(!test2.get()); + propagate_const<int*> test2; // wrapped pointer is not initialized + propagate_const<int*> test3{}; + VERIFY(!test3.get()); } diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index 9a930de166..18ee31882e 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -635,8 +635,9 @@ proc v3-build_support { } { set object_file [file tail $obj] # Compile with "-w" so that warnings issued by the compiler # do not prevent compilation. + # Disable LTO so that ar/ranlib don't need the LTO plugin. if { [v3_target_compile $srcdir/util/$f $object_file "object" \ - [list "incdir=$srcdir" "additional_flags=-w"]] + [list "incdir=$srcdir" "additional_flags=-w -fno-lto"]] != "" } { error "could not compile $f" } @@ -1923,6 +1924,8 @@ proc check_v3_target_little_endian { } { return $et_little_endian } +# Return 1 if the Filesystem TS is supported, 0 otherwise. +# Cache the result. proc check_v3_target_filesystem_ts { } { global cxxflags global DEFAULT_CXXFLAGS @@ -1950,7 +1953,7 @@ proc check_v3_target_filesystem_ts { } { set et_filesystem_ts 0 # Set up and preprocess a C++ test program that depends - # on debug mode activated. + # on the Filesystem TS feature-test macro being defined. set src filesystem_ts[pid].cc set f [open $src "w"] diff --git a/libstdc++-v3/testsuite/util/testsuite_fs.h b/libstdc++-v3/testsuite/util/testsuite_fs.h index d2b3b1848e..f1e0bfcc25 100644 --- a/libstdc++-v3/testsuite/util/testsuite_fs.h +++ b/libstdc++-v3/testsuite/util/testsuite_fs.h @@ -83,11 +83,13 @@ namespace __gnu_test p = tmp; #else char buf[64]; + static int counter; #if _GLIBCXX_USE_C99_STDIO - std::snprintf(buf, 64, "filesystem-ts-test.%lu", (unsigned long)::getpid()); + std::snprintf(buf, 64, #else - std::sprintf(buf, "filesystem-ts-test.%lu", (unsigned long)::getpid()); + std::sprintf(buf, #endif + "filesystem-ts-test.%d.%lu", counter++, (unsigned long) ::getpid()); p = buf; #endif return p; diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h index f749165923..19b7cdc32a 100644 --- a/libstdc++-v3/testsuite/util/testsuite_iterators.h +++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h @@ -542,6 +542,13 @@ namespace __gnu_test test_container(T* _first, T* _last):bounds(_first, _last) { } +#if __cplusplus >= 201103L + template<std::size_t N> + explicit + test_container(T (&arr)[N]) : test_container(arr, arr+N) + { } +#endif + ItType<T> it(int pos) { |