Commit Graph

4209 Commits

Author SHA1 Message Date
Jonathan Wakely 271ad97b6b PR libstdc++/89023 fix test that fails when <omp.h> not available
Instead of a single test that only checks whether <regex> can be
included in Parallel Mode, add tests for each of C++11/C++14/C++17 that
check whether <bits/extc++.h> is compatible with _GLIBCXX_PARALLEL.
This increases the coverage to (almost) all headers.

If <omp.h> is not available then the tests will trivially pass, because
we don't care about compatibility with _GLIBCXX_PARALLEL in that case.

	PR libstdc++/89023
	* testsuite/17_intro/headers/c++2011/parallel_mode.cc: New test.
	* testsuite/17_intro/headers/c++2014/parallel_mode.cc: New test.
	* testsuite/17_intro/headers/c++2017/parallel_mode.cc: New test.
	* testsuite/28_regex/headers/regex/parallel_mode.cc: Remove.

From-SVN: r268769
2019-02-11 12:56:59 +00:00
Jonathan Wakely 373c726ec6 PR libstdc++/89102 fix common_type<> and common_type<T> specializations
This is a partial implementation of the revised std::common_type rules
from P0435R1.

	PR libstdc++/89102 (partial)
	* include/std/type_traits (common_type<>): Define.
	(common_type<T>): Derive from common_type<T, T>.
	* testsuite/20_util/common_type/requirements/explicit_instantiation.cc:
	Test zero-length template argument list.
	* testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc:
	Test additional single argument cases.
	* testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc:
	Adjust expected error.

From-SVN: r268586
2019-02-06 17:25:26 +00:00
Jonathan Wakely 5bb89e0a28 PR libstdc++/89128 add deduction guides for container adaptors
PR libstdc++/89128
	* include/bits/stl_queue.h (queue, priority_queue): Add deduction
	guides.
	* include/bits/stl_stack.h (stack): Likewise.
	* testsuite/23_containers/priority_queue/deduction.cc: New test.
	* testsuite/23_containers/queue/deduction.cc: New test.
	* testsuite/23_containers/stack/deduction.cc: New test.

From-SVN: r268566
2019-02-05 22:58:22 +00:00
Jonathan Wakely 39bc6f8752 Restore previous behaviour of test
Go back to using CopyConsOnlyType as before r265485, because it works
again now. Add test using DelAnyAssign for completeness and additional
coverage.

	* testsuite/23_containers/vector/modifiers/push_back/49836.cc: Restore
	use of CopyConsOnlyType, but also test DelAnyAssign for completeness.

From-SVN: r268539
2019-02-05 14:53:53 +00:00
Jonathan Wakely 258bd1d63a PR libstdc++/89130 restore support for non-MoveConstructible types
The changes to "relocate" std::vector elements can lead to new errors
outside the immediate context, because moving the elements to new
storage no longer makes use of the move-if-noexcept utilities. This
means that types with deleted moves no longer degenerate to copies, but
are just ill-formed. The errors happen while instantiating the
noexcept-specifier for __relocate_object_a, when deciding whether to try
to relocate.

This patch introduces indirections to avoid the ill-formed
instantiations of std::__relocate_object_a. In order to avoid using
if-constexpr prior to C++17 this is done by tag dispatching. After this
patch all uses of std::__relocate_a are guarded by checks that will
support sensible code (i.e. code not using custom allocators that fool
the new checks).

	PR libstdc++/89130
	* include/bits/alloc_traits.h (__is_copy_insertable_impl): Rename to
	__is_alloc_insertable_impl. Replace single type member with two
	members, one for each of copy and move insertable.
	(__is_move_insertable): New trait for internal use.
	* include/bits/stl_vector.h (vector::_S_nothrow_relocate(true_type))
	(vector::_S_nothrow_relocate(true_type)): New functions to
	conditionally check if __relocate_a can throw.
	(vector::_S_use_relocate()): Dispatch to _S_nothrow_relocate based
	on __is_move_insertable.
	(vector::_S_do_relocate): New overloaded functions to conditionally
	call __relocate_a.
	(vector::_S_relocate): New function that dispatches to _S_do_relocate
	based on _S_use_relocate.
	* include/bits/vector.tcc (vector::reserve, vector::_M_realloc_insert)
	(vector::_M_default_append): Call _S_relocate instead of __relocate_a.
	* testsuite/23_containers/vector/modifiers/push_back/89130.cc: New.

From-SVN: r268537
2019-02-05 14:45:00 +00:00
Jonathan Wakely 9c5365902a PR libstdc++/89117 fix path::replace_extension("") case
Previously the operator+=(extension) call would have re-parsed the path
and recreated the components with the right extension. Since optimising
it to not re-parse the whole string, we need to actually remove the
extension from the final filename before appending anything to it, and
append the dot to that final component too.

	PR libstdc++/89117
	* src/c++17/fs_path.cc (path::replace_extension): Erase extension from
	final component as well as from _M_pathname. Append the dot using
	operator+= instead of only to _M_pathname.
	(path::_M_find_extension): Reformat slightly.
	* testsuite/27_io/filesystem/path/modifiers/replace_extension.cc:
	Add more test cases.

From-SVN: r268406
2019-01-30 23:18:22 +00:00
Jonathan Wakely 375d59849a Fix tests for complex overloads of std::arg and std::proj
The test for the synopsis of <complex> incorrectly adds constexpr to
two functions in C++2a mode, but the C++2a draft and the <complex>
header do not declare them constexpr.

	* testsuite/26_numerics/headers/complex/synopsis.cc: Remove incorrect
	constexpr specifiers from arg and proj.

From-SVN: r268359
2019-01-29 01:49:36 +00:00
Jonathan Wakely 2104ca71da Fix tests that fail in C++2a mode
The nested typedefs in std::reference_wrapper are no longer present in
C++2a mode, so skip the tests that check for them.

The addition of the [[nodiscard]] attribute to a few functions causes
some failures in tests that intentionally ignore the return value.
Casting the result to void suppresses the new warnings.

	* testsuite/20_util/reference_wrapper/result_type.cc: Disable for
	C++2a.
	* testsuite/20_util/reference_wrapper/typedefs-2.cc: Likewise.
	* testsuite/20_util/reference_wrapper/typedefs-3.cc: Likewise.
	* testsuite/20_util/reference_wrapper/typedefs.cc: Likewise.
	* testsuite/30_threads/async/54297.cc: Suppress nodiscard warning.
	* testsuite/ext/array_allocator/26875.cc: Likewise.
	* testsuite/ext/pool_allocator/allocate_chunk.cc: Likewise.
	* testsuite/util/replacement_memory_operators.h: Likewise.
	* testsuite/util/testsuite_allocator.h: Likewise.

From-SVN: r268355
2019-01-29 00:47:32 +00:00
Jonathan Wakely 400a08e284 Fix failing test due to inconsistent strcmp results
* testsuite/27_io/filesystem/path/compare/strings.cc: Only compare
	sign of results.

From-SVN: r268238
2019-01-24 15:39:19 +00:00
Jonathan Wakely 4c6b09810b PR libstdc++/88740 Print assertion messages to stderr
PR libstdc++/88740
	* testsuite/util/testsuite_hooks.h [stderr] (VERIFY): Use fprintf to
	write to stderr instead of using printf.

From-SVN: r268154
2019-01-22 16:08:18 +00:00
Jonathan Wakely dd0f7ba273 PR libstdc++/88881 adjust filesystem::status and tests for mingw semantics
On Windows stat("foo/bar/../.") will resolve to "foo" even if that is a
non-directory and "foo/bar" does not exist. This is the expected
behaviour and consistent with boost::filesystem, so don't try to correct
it. The only unwanted behaviour is that stat("baz/") fails due to a
mingw bug (fixed in mingw-w64 v6.0.0) so add a workaround.

	PR libstdc++/88881
	* src/c++17/fs_ops.cc (canonical(const path&, error_code&))
	[_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Normalize path, to match behaviour
	of filesystem::exists.
	(create_directories(const path&, error_code&)): Add assertions.
	(status(const path&, error_code&)) [_GLIBCXX_FILESYSTEM_IS_WINDOWS]:
	Add workaround for bug in _wstat for paths with trailing slash.
	* testsuite/27_io/filesystem/operations/create_directories.cc: Adjust
	for expected behaviour on mingw.
	* testsuite/experimental/filesystem/operations/create_directories.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/temp_directory_path.cc: Use
	"TMP" instead of "TMPDIR" and clean environment before each test. Do
	not test permissions on mingw targets.

From-SVN: r268034
2019-01-17 15:31:59 +00:00
Jonathan Wakely edfe833a31 Fix failing filesystem tests on mingw targets
* config/abi/pre/gnu.ver (GLIBCXX_3.4.26): Add exports for fstream
	constructors and open members taking wide strings. Fix patterns for
	filesystem::path members to match wstring_view parameters. Add
	exports for shared_ptr members used by directory iterators.
	* src/c++17/fs_ops.cc (remove(const path&, error_code&)): Clear the
	error code parameter if the file doesn't exist.
	* src/filesystem/ops.cc (remove(const path&, error_code&)):
	Likewise.
	* testsuite/27_io/filesystem/operations/canonical.cc: Fix expected
	values for mingw targets, where "/" is not an absolute path. Do not
	test symlinks on mingw targets.
	* testsuite/experimental/filesystem/operations/canonical.cc: Likewise.
	* testsuite/27_io/filesystem/operations/copy.cc: Do not test symlinks
	on mingw targets.
	* testsuite/experimental/filesystem/operations/copy.cc: Likewise.
	* testsuite/27_io/filesystem/operations/create_directories.cc: Check
	that each component of the path is created.
	* testsuite/experimental/filesystem/operations/create_directories.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/exists.cc: Do not test
	permissions on mingw targets.
	* testsuite/experimental/filesystem/operations/exists.cc: Likewise.
	* testsuite/27_io/filesystem/operations/is_empty.cc: Likewise.
	* testsuite/experimental/filesystem/operations/is_empty.cc: Likewise.
	* testsuite/27_io/filesystem/operations/permissions.cc: XFAIL for
	mingw targets.
	* testsuite/experimental/filesystem/operations/permissions.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/remove.cc: Do not test
	symlinks or permissions on mingw targets.
	* testsuite/experimental/filesystem/operations/remove.cc: Likewise.
	* testsuite/27_io/filesystem/operations/remove_all.cc: Do not test
	symlinks on mingw targets.
	* testsuite/experimental/filesystem/operations/remove_all.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/status.cc: Do not test
	permissions on mingw targets.
	* testsuite/27_io/filesystem/operations/weakly_canonical.cc: Do not
	test symlinks on mingw targets.
	* testsuite/experimental/filesystem/operations/space.cc: Fix test
	for mingw targets.

From-SVN: r267991
2019-01-16 23:11:10 +00:00
Jonathan Wakely 7f00fdb285 PR libstdc++/88811 fix typo introduced in r266569
PR libstdc++/88811
	PR libstdc++/83306
	* src/filesystem/path.cc: Fix typo. If first path is empty, show []
	before second path.
	* testsuite/experimental/filesystem/filesystem_error/cons.cc: New
	test.

From-SVN: r267868
2019-01-12 00:12:20 +00:00
Jonathan Wakely aaeac1568d P0357R3 reference_wrapper for incomplete types
This patch implements the C++2a proposal to allow incomplete types in
std::reference_wrapper, which was previously undefined.

The change cannot be implemented for earlier standards, because prior to
C++2a std::reference_wrapper has a weak result type, so must inspect the
template argument to see if it defines a nested result_type member. That
is deprecated (but still required) in C++17, and removed from C++2a.

The removal of the base class from reference_wrapper is a potential ABI
change, as it could alter the layout of a type which derives from
reference_wrapper<T> and from an empty type with _Weak_result_type<T> as
a base class.  Previously the repeated _Weak_result_type<T> base class
would have prevented the empty base-class optimization, but if
reference_wrapper<T> no longer derives from it, the empty class could be
placed at the same address as the reference_wrapper<T> base.  In
practice, the only types which derive from _Weak_result_type or from
_Reference_wrapper_base_memfun or any of its base classes are non-empty
types defined in libstdc++: std::reference_wrapper, std::function, and
std::_Bind. As they are non-empty types, they are not eligible for EBO
anyway.

	* include/bits/refwrap.h [__cplusplus > 201703L]
	(_Refwrap_base_arg1, _Refwrap_base_arg2, _Reference_wrapper_base)
	(_Reference_wrapper_base_memfun): Do not define for C++2a.
	(reference_wrapper): Do not derive from _Reference_wrapper_base_memfun
	for C++2a.
	(reference_wrapper::operator()): Add static assertion.
	* testsuite/20_util/reference_wrapper/incomplete.cc: New test.

From-SVN: r267866
2019-01-11 23:41:11 +00:00
Jonathan Wakely 5e9aed14dc P0972R0 <chrono> zero(), min(), and max() should be noexcept
This paper has been included in the C++20 draft, but the changes to add
noexcept can be made unconditionally, to apply for C++11 too.

	* include/std/chrono (duration_values::zero(), duration_values::min())
	(duration_values::max()): Add noexcept.
	(duration::zero(), duration::min(), duration::max()): Likewise.
	(time_point::zero(), time_point::min(), time_point::max()): Likewise.
	* testsuite/20_util/duration/requirements/noexcept.cc: New test.
	* testsuite/20_util/time_point/requirements/noexcept.cc: New test.

From-SVN: r267865
2019-01-11 23:41:05 +00:00
Jonathan Wakely 17a73b3c47 PR libstdc++/88802 define std::hash<nullptr_t> for C++17
PR libstdc++/88802
	* include/bits/functional_hash.h (hash<nullptr_t>): Define
	specialization for C++17 (P0513R0, LWG 2817).
	* testsuite/20_util/hash/nullptr.cc: New test.

From-SVN: r267845
2019-01-11 14:54:49 +00:00
Jonathan Wakely 174f1d2642 Fix filesystem::last_write_time failure with 32-bit time_t
* testsuite/27_io/filesystem/operations/last_write_time.cc: Fix
	test failures on targets with 32-bit time_t.

From-SVN: r267811
2019-01-10 15:39:28 +00:00
Jonathan Wakely 45a8d80fec Define __cpp_lib_erase_if feature test macro
The C++2a draft specifies the value 201811L for this, but as an
extension we return the number of elements erased. This is expected to
be standardised, so the macro has the value 201900L until a proper value
is specified in the draft.

	* include/bits/erase_if.h: Define __cpp_lib_erase_if.
	* include/std/deque: Likewise.
	* include/std/forward_list: Likewise.
	* include/std/list: Likewise.
	* include/std/string: Likewise.
	* include/std/vector: Likewise.
	* include/std/version: Likewise.
	* testsuite/21_strings/basic_string/erasure.cc: Test macro.
	* testsuite/23_containers/deque/erasure.cc: Likewise.
	* testsuite/23_containers/forward_list/erasure.cc: Likewise.
	* testsuite/23_containers/list/erasure.cc: Likewise.
	* testsuite/23_containers/map/erasure.cc: Likewise.
	* testsuite/23_containers/set/erasure.cc: Likewise.
	* testsuite/23_containers/unordered_map/erasure.cc: Likewise.
	* testsuite/23_containers/unordered_set/erasure.cc: Likewise.
	* testsuite/23_containers/vector/erasure.cc: Likewise.

From-SVN: r267810
2019-01-10 13:49:31 +00:00
Jonathan Wakely cbe0bca404 Check AI_NUMERICSERV is defined before using it
The AI_NUMERICSERV constant is missing from old Darwin systems, so only
use it if it's supported.

	* include/experimental/internet [AI_NUMERICSERV]
	(resolver_base::numeric_service): Define conditionally.
	* testsuite/experimental/net/internet/resolver/base.cc: Test it
	conditionally.
	* testsuite/experimental/net/internet/resolver/ops/lookup.cc:
	Likewise.

From-SVN: r267809
2019-01-10 13:21:54 +00:00
Ville Voutilainen c3799b164f Implement LWG 2221: formatted output operator for nullptr
2019-01-10  Ville Voutilainen  <ville.voutilainen@gmail.com>
	    Jonathan Wakely  <jwakely@redhat.com>

	Implement LWG 2221
	* config/abi/pre/gnu.ver (GLIBCXX_3.4): Tighten patterns.
	(GLIBCXX_3.4.26): Add new exports.
	* include/Makefile.am: Add ostream-inst.cc. Move string-inst.cc to
	correct list of sources.
	* include/Makefile.in: Regenerate.
	* include/std/ostream (operator<<(nullptr_t)): New member function.
	* src/c++17/ostream-inst.cc: New file.
	* testsuite/27_io/basic_ostream/inserters_other/char/lwg2221.cc: New
	test.

Co-Authored-By: Jonathan Wakely <jwakely@redhat.com>

From-SVN: r267808
2019-01-10 13:14:57 +00:00
Jonathan Wakely 7c4979b2b2 Include name of test in filesystem-test.XXXXXX filenames
Also fix some tests that were not cleaning up after themselves, as
identified by the change to nonexistent_path.

	* testsuite/util/testsuite_fs.h (nonexistent_path): Include name
	of the source file containing the caller.
	* testsuite/27_io/filesystem/iterators/directory_iterator.cc: Remove
	directories created by test.
	* testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc:
	Likewise.
	* testsuite/experimental/filesystem/iterators/directory_iterator.cc:
	Likewise.
	* testsuite/experimental/filesystem/iterators/
	recursive_directory_iterator.cc: Likewise.

From-SVN: r267801
2019-01-10 11:12:00 +00:00
Jonathan Wakely d3c8a7cfdb Fix failing prettyprinter test
The failure for "p2" went unnoticed due to the pre-existing failures for
variables with similar names, like "p" and "q". This fixes the failure,
and gives the filesystem::path variables better names.

	* testsuite/libstdc++-prettyprinters/cxx17.cc: Fix expected output
	for filesystem::path. Give variables more distinctive names.

From-SVN: r267762
2019-01-09 10:46:52 +00:00
Jonathan Wakely c86fab9d08 PR libstdc++/88204 disable std::complex<long double> tests
The IBM128 long double format isn't foldable in constant expressions, so
conditionally skip the std::complex<long double> cases when they'll
fail.

	PR libstdc++/88204
	* testsuite/26_numerics/complex/operators/more_constexpr.cc: Do not
	test std::complex<long double> if long double format is IBM128.
	* testsuite/26_numerics/complex/requirements/more_constexpr.cc:
	Likewise.

From-SVN: r267757
2019-01-09 09:37:34 +00:00
Jonathan Wakely 416f555930 Pretty printer test fixes and improvements
Test that StdUniquePtrPrinter correctly prints std::unique_ptr objects
using the old layout, prior to the PR libstdc++/77990 changes.

The printer test for a valueless std::variant started to fail because
the PR libstdc++/87431 fix meant it no longer became valueless. Change
the test to use a type that is not trivially copyable, so that the
exception causes it to become valueless.

	* testsuite/libstdc++-prettyprinters/compat.cc: Test printer support
	for old std::unique_ptr layout.
	* testsuite/libstdc++-prettyprinters/cxx17.cc: Fix std::variant test
	to become valueless. Add filesystem::path tests.

From-SVN: r267743
2019-01-08 23:15:49 +00:00
Jonathan Wakely d942bc80e4 PR libstdc++/87855 fix optional for types with non-trivial copy/move
When the contained value is not trivially copy (or move) constructible
the union's copy (or move) constructor will be deleted, and so the
_Optional_payload delegating constructors are invalid. G++ fails to
diagnose this because it incorrectly performs copy elision in the
delegating constructors. Clang does diagnose it (llvm.org/PR40245).

The solution is to avoid performing any copy (or move) when the
contained value's copy (or move) constructor isn't trivial. Instead the
contained value can be constructed by calling _M_construct. This is OK,
because the relevant constructor doesn't need to be constexpr when the
contained value isn't trivially copy (or move) constructible.

Additionally, this patch removes a lot of code duplication in the
_Optional_payload partial specializations and the _Optional_base partial
specialization, by hoisting it into common base classes.

The Python pretty printer for std::optional needs to be adjusted to
support the new layout. Retain support for the old layout, and add a
test to verify that the support still works.

	PR libstdc++/87855
	* include/std/optional (_Optional_payload_base): New class template
	for common code hoisted from _Optional_payload specializations. Use
	a template for the union, to allow a partial specialization for
	types with non-trivial destructors. Add constructors for in-place
	initialization to the union.
	(_Optional_payload(bool, const _Optional_payload&)): Use _M_construct
	to perform non-trivial copy construction, instead of relying on
	non-standard copy elision in a delegating constructor.
	(_Optional_payload(bool, _Optional_payload&&)): Likewise for
	non-trivial move construction.
	(_Optional_payload): Derive from _Optional_payload_base and use it
	for everything except the non-trivial assignment operators, which are
	defined as needed.
	(_Optional_payload<false, C, M>): Derive from the specialization
	_Optional_payload<true, false, false> and add a destructor.
	(_Optional_base_impl::_M_destruct, _Optional_base_impl::_M_reset):
	Forward to corresponding members of _Optional_payload.
	(_Optional_base_impl::_M_is_engaged, _Optional_base_impl::_M_get):
	Hoist common members from _Optional_base.
	(_Optional_base): Make all members and base class public.
	(_Optional_base::_M_get, _Optional_base::_M_is_engaged): Move to
	_Optional_base_impl.
	* python/libstdcxx/v6/printers.py (StdExpOptionalPrinter): Add
	support for new std::optional layout.
	* testsuite/libstdc++-prettyprinters/compat.cc: New test.

From-SVN: r267742
2019-01-08 23:00:46 +00:00
Jonathan Wakely cf4b581f2e Fix build for systems without POSIX truncate
Older versions of newlib do not provide truncate so add a configure
check for it, and provide a fallback definition.

There were also some missing exports in the linker script, which went
unnoticed because there are no tests for some functions. A new link-only
test checks that every filesystem operation function is defined by the
library.

	* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for truncate.
	* config.h.in: Regenerate.
	* config/abi/pre/gnu.ver: Order patterns for filesystem operations
	alphabetically and add missing entries for copy_symlink,
	hard_link_count, rename, and resize_file.
	* configure: Regenerate.
	* src/c++17/fs_ops.cc (resize_file): Remove #if so posix::truncate is
	used unconditionally.
	* src/filesystem/ops-common.h (__gnu_posix::truncate)
	[!_GLIBCXX_HAVE_TRUNCATE]: Provide fallback definition that only
	supports truncating to zero length.
	* testsuite/27_io/filesystem/operations/all.cc: New test.
	* testsuite/27_io/filesystem/operations/resize_file.cc: New test.

From-SVN: r267647
2019-01-07 12:38:51 +00:00
Jonathan Wakely de4db54fd9 PR libstdc++/86756 Move rest of std::filesystem to libstdc++.so
Move std::filesystem directory iterators and operations from
libstdc++fs.a to main libstdc++ library. These components have many
dependencies on OS support, which is not available on all targets. Some
additional autoconf checks and conditional compilation is needed to
ensure the files will build for all targets. Previously this code was
not compiled without --enable-libstdcxx-filesystem-ts but the C++17
components should be available for all hosted builds.

The tests for these components no longer need to link to libstdc++fs.a,
but are not expected to pass on all targets. To avoid numerous failures
on targets which are not expected to pass the tests (due to missing OS
functionality) leave the dg-require-filesystem-ts directives in place
for now. This will ensure the tests only run for builds where the
filesystem-ts library is built, which presumably means some level of OS
support is present.

	PR libstdc++/86756
	* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for utime and
	lstat and define _GLIBCXX_USE_UTIME and _GLIBCXX_USE_LSTAT.
	* config.h.in: Regenerate.
	* config/abi/pre/gnu.ver (GLIBCXX_3.4.26): Export symbols for
	remaining std::filesystem types and functions.
	* configure: Regenerate.
	* src/c++17/Makefile.am: Add C++17 filesystem sources.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++17/cow-fs_dir.cc: Move src/filesystem/cow-std-dir.cc to
	here, and change name of included file.
	* src/c++17/cow-fs_ops.cc: Move src/filesystem/cow-std-ops.cc to
	here, and change name of included file.
	* src/c++17/fs_dir.cc: Move src/filesystem/std-dir.cc to here. Change
	path to dir-common.h.
	* src/c++17/fs_ops.cc: Move src/filesystem/std-ops.cc to here. Change
	path to ops-common.h. Disable -Wunused-parameter warnings.
	(internal_file_clock): Define unconditionally.
	[!_GLIBCXX_HAVE_SYS_STAT_H] (internal_file_clock::from_stat): Do not
	define.
	(do_copy_file, do_space): Move definitions to ops.common.h.
	(copy, file_size, hard_link_count, last_write_time, space): Only
	perform operation when _GLIBCXX_HAVE_SYS_STAT_H is defined, otherwise
	report an error.
	(last_write_time, read_symlink): Remove unused attributes from
	parameters.
	* src/filesystem/Makefile.am: Remove C++17 filesystem sources.
	* src/filesystem/Makefile.in: Regenerate.
	* src/filesystem/cow-std-dir.cc: Move to src/c++17/cow-fs_dir.cc.
	* src/filesystem/cow-std-ops.cc: Move to src/c++17/cow-fs_ops.cc.
	* src/filesystem/std-dir.cc: Move to src/c++17/fs_dir.cc.
	* src/filesystem/std-ops.cc: Move to src/c++17/fs_ops.cc.
	* src/filesystem/dir-common.h [!_GLIBCXX_HAVE_DIRENT_H]: Define
	dummy types and functions instead of using #error.
	* src/filesystem/dir.cc [!_GLIBCXX_HAVE_DIRENT_H]: Use #error.
	* src/filesystem/ops-common.h [!_GLIBCXX_USE_LSTAT] (lstat): Define
	in terms of stat.
	[!_GLIBCXX_HAVE_UNISTD_H]: Define dummy types and functions.
	(do_copy_file, do_space): Move definitions here from std-ops.cc.
	* src/filesystem/ops.cc: Adjust calls to do_copy_file and do_space
	to account for new namespace.
	* testsuite/27_io/filesystem/directory_entry/86597.cc: Remove
	-lstdc++fs from dg-options.
	* testsuite/27_io/filesystem/directory_entry/lwg3171.cc: Likewise.
	* testsuite/27_io/filesystem/file_status/1.cc: Likewise.
	* testsuite/27_io/filesystem/filesystem_error/cons.cc: Likewise.
	* testsuite/27_io/filesystem/filesystem_error/copy.cc: Likewise.
	* testsuite/27_io/filesystem/iterators/directory_iterator.cc:
	Likewise.
	* testsuite/27_io/filesystem/iterators/pop.cc: Likewise.
	* testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/absolute.cc: Likewise.
	* testsuite/27_io/filesystem/operations/canonical.cc: Likewise.
	* testsuite/27_io/filesystem/operations/copy.cc: Likewise.
	* testsuite/27_io/filesystem/operations/copy_file.cc: Likewise.
	* testsuite/27_io/filesystem/operations/create_directories.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/create_directory.cc: Likewise.
	* testsuite/27_io/filesystem/operations/create_symlink.cc: Likewise.
	* testsuite/27_io/filesystem/operations/current_path.cc: Likewise.
	* testsuite/27_io/filesystem/operations/equivalent.cc: Likewise.
	* testsuite/27_io/filesystem/operations/exists.cc: Likewise.
	* testsuite/27_io/filesystem/operations/file_size.cc: Likewise.
	* testsuite/27_io/filesystem/operations/is_empty.cc: Likewise.
	* testsuite/27_io/filesystem/operations/last_write_time.cc: Likewise.
	* testsuite/27_io/filesystem/operations/permissions.cc: Likewise.
	* testsuite/27_io/filesystem/operations/proximate.cc: Likewise.
	* testsuite/27_io/filesystem/operations/read_symlink.cc: Likewise.
	* testsuite/27_io/filesystem/operations/relative.cc: Likewise.
	* testsuite/27_io/filesystem/operations/remove.cc: Likewise.
	* testsuite/27_io/filesystem/operations/remove_all.cc: Likewise.
	* testsuite/27_io/filesystem/operations/space.cc: Likewise.
	* testsuite/27_io/filesystem/operations/status.cc: Likewise.
	* testsuite/27_io/filesystem/operations/symlink_status.cc: Likewise.
	* testsuite/27_io/filesystem/operations/temp_directory_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/weakly_canonical.cc: Likewise.

From-SVN: r267616
2019-01-06 22:34:37 +00:00
Jonathan Wakely 2b5225352e PR libstdc++/86756 add std::filesystem::path to libstdc++.so
Move the C++17 std::filesystem::path definitions from the libstdc++fs.a
archive to the main libstdc++ library. The path classes do not depend on
any OS functions, so can be defined unconditionally on all targets
(rather than depending on --enable-libstdcxx-filesystem-ts). The tests
should pass on all targets too.

	PR libstdc++/86756
	* config/abi/pre/gnu.ver (GLIBCXX_3.4): Make various patterns for
	typeinfo and vtables less greedy.
	(GLIBCXX_3.4.26): Export symbols for std::filesystem::path.
	* src/c++17/Makefile.am: Add fs_path.cc and cow-fs_path.cc.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++17/cow-fs_path.cc: Move src/filesystem/cow-std-path.cc to
	here, and change name of included file.
	* src/c++17/fs_path.cc: Move src/filesystem/std-path.cc to here.
	* src/filesystem/Makefile.am: Remove std-path.cc and cow-std-path.cc
	from sources.
	* src/filesystem/Makefile.in: Regenerate.
	* src/filesystem/cow-std-path.cc: Move to src/c++17/cow-fs_path.cc.
	* src/filesystem/std-path.cc: Move to src/c++17/fs_path.cc.
	* testsuite/27_io/filesystem/path/append/path.cc: Remove -lstdc++fs
	from dg-options and remove dg-require-filesystem-ts.
	* testsuite/27_io/filesystem/path/append/source.cc: Likewise.
	* testsuite/27_io/filesystem/path/assign/assign.cc: Likewise.
	* testsuite/27_io/filesystem/path/assign/copy.cc: Likewise.
	* testsuite/27_io/filesystem/path/compare/compare.cc: Likewise.
	* testsuite/27_io/filesystem/path/compare/lwg2936.cc: Likewise.
	* testsuite/27_io/filesystem/path/compare/path.cc: Likewise.
	* testsuite/27_io/filesystem/path/compare/strings.cc: Likewise.
	* testsuite/27_io/filesystem/path/concat/path.cc: Likewise.
	* testsuite/27_io/filesystem/path/concat/strings.cc: Likewise.
	* testsuite/27_io/filesystem/path/construct/80762.cc: Likewise.
	* testsuite/27_io/filesystem/path/construct/copy.cc: Likewise.
	* testsuite/27_io/filesystem/path/construct/default.cc: Likewise.
	* testsuite/27_io/filesystem/path/construct/format.cc: Likewise.
	* testsuite/27_io/filesystem/path/construct/locale.cc: Likewise.
	* testsuite/27_io/filesystem/path/construct/range.cc: Likewise.
	* testsuite/27_io/filesystem/path/construct/string_view.cc: Likewise.
	* testsuite/27_io/filesystem/path/decompose/extension.cc: Likewise.
	* testsuite/27_io/filesystem/path/decompose/filename.cc: Likewise.
	* testsuite/27_io/filesystem/path/decompose/parent_path.cc: Likewise.
	* testsuite/27_io/filesystem/path/decompose/relative_path.cc: Likewise.
	* testsuite/27_io/filesystem/path/decompose/root_directory.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/decompose/root_name.cc: Likewise.
	* testsuite/27_io/filesystem/path/decompose/root_path.cc: Likewise.
	* testsuite/27_io/filesystem/path/decompose/stem.cc: Likewise.
	* testsuite/27_io/filesystem/path/generation/normal.cc: Likewise.
	* testsuite/27_io/filesystem/path/generation/normal2.cc: Likewise.
	* testsuite/27_io/filesystem/path/generation/proximate.cc: Likewise.
	* testsuite/27_io/filesystem/path/generation/relative.cc: Likewise.
	* testsuite/27_io/filesystem/path/generic/generic_string.cc: Likewise.
	* testsuite/27_io/filesystem/path/itr/components.cc: Likewise.
	* testsuite/27_io/filesystem/path/itr/traversal.cc: Likewise.
	* testsuite/27_io/filesystem/path/modifiers/clear.cc: Likewise.
	* testsuite/27_io/filesystem/path/modifiers/make_preferred.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/modifiers/remove_filename.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/modifiers/replace_extension.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/modifiers/replace_filename.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/modifiers/swap.cc: Likewise.
	* testsuite/27_io/filesystem/path/native/string.cc: Likewise.
	* testsuite/27_io/filesystem/path/nonmember/append.cc: Likewise.
	* testsuite/27_io/filesystem/path/nonmember/hash_value.cc: Likewise.
	* testsuite/27_io/filesystem/path/query/empty.cc: Likewise.
	* testsuite/27_io/filesystem/path/query/has_extension.cc: Likewise.
	* testsuite/27_io/filesystem/path/query/has_filename.cc: Likewise.
	* testsuite/27_io/filesystem/path/query/has_parent_path.cc: Likewise.
	* testsuite/27_io/filesystem/path/query/has_relative_path.cc: Likewise.
	* testsuite/27_io/filesystem/path/query/has_root_directory.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_root_name.cc: Likewise.
	* testsuite/27_io/filesystem/path/query/has_root_path.cc: Likewise.
	* testsuite/27_io/filesystem/path/query/has_stem.cc: Likewise.
	* testsuite/27_io/filesystem/path/query/is_absolute.cc: Likewise.
	* testsuite/27_io/filesystem/path/query/is_relative.cc: Likewise.

From-SVN: r267615
2019-01-06 22:34:29 +00:00
Jonathan Wakely caf80d87b5 PR libstdc++/87431 fix regression introduced by r264574
The previous patch for PR 87431 assumed that initialing a scalar type
could not throw, but it can obtain its value via a conversion operator,
which could throw. This meant the variant could get into a valueless
state, but the valueless_by_exception() member function would always
return false.

This patch fixes it by changing the emplace members to have strong
exception safety when initializing a contained value of trivially
copyable type. The _M_valid() member gets a corresponding change to
always return true for trivially copyable types, not just scalar types.

Strong exception safety (i.e. never becoming valueless) is achieved by
only replacing the current contained value once any potentially throwing
operations have completed. If constructing the new contained value can
throw then a new std::variant object is constructed to hold it, and then
move-assigned to *this (which won't throw).

	PR libstdc++/87431
	* include/std/variant (_Variant_storage<true, _Types...>::_M_valid):
	Check is_trivially_copyable instead of is_scalar.
	(variant::emplace<N, Args>(Args&&...)): If construction of the new
	contained value can throw and its type is trivially copyable then
	construct into a temporary variant and move from it, to provide the
	strong exception safety guarantee.
	(variant::emplace<N, U, Args>(initializer_list<U>, Args&&...)):
	Likewise.
	* testsuite/20_util/variant/87431.cc: New test.
	* testsuite/20_util/variant/run.cc: Adjust test so that throwing
	conversion causes valueless state.

From-SVN: r267614
2019-01-06 20:52:34 +00:00
Jonathan Wakely ecaad8d5cf PR libstdc++/88607 add tests using -finput-charset=ascii
This verifies that the <bits/extc++.h> header can be compiled with ASCII
as the input character set.

	PR libstdc++/88607
	* testsuite/17_intro/headers/c++1998/charset.cc: New test.
	* testsuite/17_intro/headers/c++2011/charset.cc: New test.
	* testsuite/17_intro/headers/c++2014/charset.cc: New test.
	* testsuite/17_intro/headers/c++2017/charset.cc: New test.
	* testsuite/17_intro/headers/c++2020/charset.cc: New test.

From-SVN: r267607
2019-01-06 00:49:11 +00:00
Jonathan Wakely 4ff3e65090 Add allocator-extended copy/move ctors to COW string
Add these constructors from C++11 which were missing from the COW
basic_string. Additionally simplify the definitions of the
basic_string::reference and basic_string::const_reference types as
required by C++11.

This allows filesystem::path::string<Allocator>() to be simplified, so
that the same code is used for both basic_string implementations.

	* config/abi/pre/gnu.ver (GLIBCXX_3.4.26): Export allocator-extended
	copy/move constructors for old std::basic_string.
	* include/bits/basic_string.h [!_GLIBCXX_USE_CXX11_ABI]
	(basic_string::reference, basic_string::const_reference): Define
	as plain references for C++11 and later.
	(basic_string::basic_string()): Put constructor body outside
	preprocessor conditional groups.
	(basic_string::basic_string(basic_string&&)): Move _Alloc_hider
	instead of copying it.
	(basic_string::basic_string(const basic_string&, const _Alloc&)):
	Define.
	(basic_string::basic_string(basic_string&&, const _Alloc&)):
	Define.
	* include/bits/fs_path.h [!_GLIBCXX_USE_CXX11_ABI]: Remove special
	cases for old basic_string.
	* testsuite/21_strings/basic_string/cons/char/8.cc: Test
	allocator-extended constructors unconditionally. Add extra members to
	allocator type when using old string ABI.
	* testsuite/21_strings/basic_string/allocator/71964.cc: Enable test
	for old string ABI.
	* testsuite/21_strings/basic_string/cons/wchar_t/8.cc: Likewise.

From-SVN: r267584
2019-01-04 23:23:17 +00:00
Jonathan Wakely 6908c1dc6f Fix test failure when -fno-inline is used
This currently checks _GLIBCXX_USE_DUAL_ABI which is incorrect, as that
can be true when _GLIBCXX_USE_CXX11_ABI == 0. The correct check would be
_GLIBCXX_USE_CXX11_ABI == 1, but that's made redundant by the cxx11-abi
effective target that the test requires. However, the test will fail if
-fno-inline is used, so check __NO_INLINE__ instead.

	* testsuite/23_containers/list/61347.cc: Avoid spurious failure when
	-fno-inline added to test flags.

From-SVN: r267582
2019-01-04 18:56:26 +00:00
Jonathan Wakely 9fc5a9a144 Remove XFAIL from test that no longer fails
This test started passing with the old ABI with r263808, so doesn't need
to be marked XFAIL now.

	* testsuite/21_strings/basic_string/requirements/
	explicit_instantiation/debug.cc: Remove XFAIL for old ABI.

From-SVN: r267578
2019-01-04 16:07:06 +00:00
Jonathan Wakely 66f3122436 Fix test failure with old Copy-On-Write std::string
* testsuite/27_io/filesystem/filesystem_error/copy.cc: Fix static
	assertion failures with old std::string ABI.

From-SVN: r267577
2019-01-04 15:42:33 +00:00
Jonathan Wakely 73d968d945 Fix bugs in filesystem::path::lexically_normal()
Using path::_List::erase(const_iterator) to remove a non-final component
in path::lexically_normal() is a bug, because it leaves the following
component with an incorrect _M_pos value.

Instead of providing erase members that allow removing components from
the middle, replace them with pop_back() and
_M_erase_from(const_iterator) which only allow removing elements at the
end. Most uses of erase are unaffected, because they only remove
elements from the end anyway. The one use of erasure from the middle in
lexically_normal() is replaced by calls to pop_back() and/or clearing
the last component to leave it as an empty final filename.

Also replace the "???" comment in lexically_normal() to document when
that branch is taken.

	* include/bits/fs_path.h (path::_List::erase): Replace both overloads
	with ...
	(path::pop_back(), path::_M_erase_from(const_iterator)): New member
	functions that will only erase elements at the end.
	* src/filesystem/std-path.cc (path::_List::_Impl::pop_back()): Define.
	(path::_List::_Impl::_M_erase_from(const_iterator)): Define.
	(path::_List::operator=(const _List&)): Use _M_erase_from(p) instead
	of erase(p, end()).
	(path::_List::pop_back()): Define.
	(path::_List::_M_erase_from(const_iterator)): Define.
	(path::operator/=(const path&)): Use pop_back to remove last component
	and _M_erase_from to remove multiple components.
	(path::_M_append(basic_string_view<value_type>)): Likewise.
	(path::operator+=(const path&)): Likewise.
	(path::_M_concat(basic_string_view<value_type>)): Likewise.
	(path::remove_filename()): Likewise.
	(path::lexically_normal()): Use _List::_Impl iterators instead of
	path::iterator. Use pop_back to remove components from the end. Clear
	trailing filename, instead of using erase(const_iterator) to remove
	a non-final component.
	* testsuite/27_io/filesystem/path/generation/normal.cc: Test
	additional cases.
	* testsuite/27_io/filesystem/path/generation/normal2.cc: New test.

From-SVN: r267576
2019-01-04 14:03:59 +00:00
Jonathan Wakely b30802179a Fix concatenation bug in filesystem::path
When erasing a trailing empty filename component, the output iterator
was not decremented, causing the next component to be created at the
wrong position.

	* src/filesystem/std-path.cc (path::operator+=(const path&)): Fix
	incorrect treatment of empty filename after trailing slash.
	* testsuite/27_io/filesystem/path/concat/path.cc: Test problem case.

From-SVN: r267574
2019-01-04 11:43:09 +00:00
Jonathan Wakely 5db78cac10 Avoid spurious test failures when -fno-inline in test flags
These tests rely on inlining, so if -fno-inline is added to the compiler
flags the tests fail. Use the predefined __NO_INLINE__ macro to detect
that situation, and don't bother testing the move assignment.

	* testsuite/21_strings/basic_string/modifiers/assign/char/
	move_assign_optim.cc: Avoid spurious failure when -fno-inline added
	to test flags.
	* testsuite/21_strings/basic_string/modifiers/assign/wchar_t/
	move_assign_optim.cc: Likewise.

From-SVN: r267573
2019-01-04 11:06:49 +00:00
Jonathan Wakely dd87c5c228 PR libstdc++/88681 export missing symbols
These new facet functions were added to GCC 5.1 but the versions for the
old std::string ABI were never exported from the shared library.

	PR libstdc++/88681
	* config/abi/pre/gnu.ver: Add missing exports.
	* testsuite/22_locale/collate_byname/88681.cc: New test.
	* testsuite/22_locale/time_get/get/char/88681.cc: New test.
	* testsuite/22_locale/time_get/get/wchar_t/88681.cc: New test.

From-SVN: r267563
2019-01-03 20:38:04 +00:00
Jonathan Wakely b3e2dc1ed9 Add more testcases for class template argument deduction of maps
This adds additional tests for std::map and std::multimap CTAD. The
tests ensure that deduction works for braced-init-list of value_type
objects, and for pairs of input iterators (with both std::pair<Key, T>
and value_type as the iterator's value_type). This ensures deduction
from value_type still works, as well as the non-value_type cases in LWG
3025.

Similar tests for unordered maps do not work, apparently because the
constructor taking an initializer_list<value_type> is not usable for
deduction, and the deduction guide taking initializer_list<pair<Key, T>>
deduces key_type to be const. I am not addressing that.

	* testsuite/23_containers/map/cons/deduction.cc: Test deduction from
	initializer_list<value_type> and from input iterator ranges.
	* testsuite/23_containers/multimap/cons/deduction.cc: Likewise.

From-SVN: r267518
2019-01-02 16:30:49 +00:00
Jonathan Wakely 362eea7cbf Fix year range in copyright header
* testsuite/experimental/string_view/element_access/char/empty.cc:
	Fix year range in copyright header.

From-SVN: r267508
2019-01-02 10:44:35 +00:00
Joel Brobecker 2667a5d04a Fix year range in libstdc++v3/testsuite/.../empty.cc copyright header
libstdc++-v3/ChangeLog:

        * testsuite/21_strings/basic_string_view/element_access/char/empty.cc:
        Fix year range in copyright header.

From-SVN: r267504
2019-01-02 06:04:51 +00:00
Jakub Jelinek a554497024 Update copyright years.
From-SVN: r267494
2019-01-01 13:31:55 +01:00
François Dumont 4483dd3fa3 2018-12-23 François Dumont <fdumont@gcc.gnu.org>
* libstdc++-v3/testsuite/util/testsuite_allocator.h
	(CustomPointerAlloc<>::allocate(size_t, pointer)): Replace by...
	(CustomPointerAlloc<>::allocate(size_t, const_void_pointer)): ...this.

From-SVN: r267381
2018-12-23 18:11:38 +00:00
Jonathan Wakely 080cec7f9a Fix filesystem::path tests that fail on Windows
* testsuite/27_io/filesystem/operations/proximate.cc: Fix test for
	MinGW.
	* testsuite/27_io/filesystem/path/append/source.cc: Likewise.
	* testsuite/27_io/filesystem/path/compare/lwg2936.cc: Likewise.

From-SVN: r267308
2018-12-20 18:12:11 +00:00
Jonathan Wakely 26bf4e3134 Add missing test from previous commit
* testsuite/27_io/filesystem/directory_entry/lwg3171.cc: New test
	(missed from previous commit).

From-SVN: r267297
2018-12-20 12:32:17 +00:00
Jonathan Wakely 36313a6bce LWG 2936: update path::compare logic and optimize string comparisons
The resolution for LWG 2936 defines the comparison more precisely, which
this patch implements. The patch also defines comparisons with strings
to work without constructing a temporary path object (so avoids any
memory allocations).

	* include/bits/fs_path.h (path::compare(const string_type&))
	(path::compare(const value_type*)): Add noexcept and construct a
	string view to compare to instead of a path.
	(path::compare(basic_string_view<value_type>)): Add noexcept. Remove
	inline definition.
	* src/filesystem/std-path.cc (path::_Parser): Track last type read
	from input.
	(path::_Parser::next()): Return a final empty component when the
	input ends in a non-root directory separator.
	(path::_M_append(basic_string_view<value_type>)): Remove special cases
	for trailing non-root directory separator.
	(path::_M_concat(basic_string_view<value_type>)): Likewise.
	(path::compare(const path&)): Implement LWG 2936.
	(path::compare(basic_string_view<value_type>)): Define in terms of
	components returned by parser, consistent with LWG 2936.
	* testsuite/27_io/filesystem/path/compare/lwg2936.cc: New.
	* testsuite/27_io/filesystem/path/compare/path.cc: Test more cases.
	* testsuite/27_io/filesystem/path/compare/strings.cc: Likewise.

From-SVN: r267235
2018-12-18 15:52:33 +00:00
Jonathan Wakely 2017595dfa PR libstdc++/71044 fix off-by-one errors introduced recently
The recent changes to append/concat directly from strings (without
constructing paths) introduced regressions where one of the components
could be omitted from the iteration sequence in the result.

	PR libstdc++/71044
	* src/filesystem/std-path.cc (path::_M_append): Fix off-by-one error
	that caused a component to be lost from the iteration sequence.
	(path::_M_concat): Likewise.
	* testsuite/27_io/filesystem/path/append/source.cc: Test appending
	long strings.
	* testsuite/27_io/filesystem/path/concat/strings.cc: Test
	concatenating long strings.
	* testsuite/27_io/filesystem/path/construct/string_view.cc: Test
	construction from long string.

From-SVN: r267222
2018-12-17 22:43:31 +00:00
Jonathan Wakely 2b462958e2 Fix handling of POSIX paths containing a root-name
Fix path appending and concatenating to work correctly for a leading
root-name. Check a new macro, SLASHSLASH_IS_ROOT_NAME, instead of making
the behaviour depend directly on __CYGWIN__.

	* src/filesystem/std-path.cc (SLASHSLASH_IS_ROOT_NAME): New macro to
	control whether interpret paths with two slashes as a root-name.
	(path::operator/=(const path&)) [SLASHSLASH_IS_ROOT_NAME]: Add a
	root-directory when appending to a root-name.
	(path::_M_append(basic_string_view<value_type>))
	[SLASHSLASH_IS_ROOT_NAME]: Likewise.
	(path::operator/=(const path&)) [SLASHSLASH_IS_ROOT_NAME]: Likewise.
	(path::_M_concat(basic_string_view<value_type>))
	[SLASHSLASH_IS_ROOT_NAME]: Likewise.
	(path::lexically_normal()) [SLASHSLASH_IS_ROOT_NAME]: Use += instead
	of /= to add a root-directory to the result.
	* testsuite/27_io/filesystem/path/decompose/root_directory.cc: Fix
	expected result for Cygwin.

From-SVN: r267107
2018-12-13 20:34:10 +00:00
Jonathan Wakely 4f87bb8d6e PR libstdc++/71044 optimize std::filesystem::path construction
This new implementation has a smaller footprint than the previous
implementation, due to replacing std::vector<_Cmpt> with a custom pimpl
type that only needs a single pointer. The _M_type enumeration is also
combined with the pimpl type, by using a tagged pointer, reducing
sizeof(path) further still.

Construction and modification of paths is now done more efficiently, by
splitting the input into a stack-based buffer of string_view objects
instead of a dynamically-allocated vector containing strings. Once the
final size is known only a single allocation is needed to reserve space
for it.  The append and concat operations no longer require constructing
temporary path objects, nor re-parsing the entire native pathname.

This results in algorithmic improvements to path construction, and
working with large paths is much faster.

	PR libstdc++/71044
	* include/bits/fs_path.h (path::path(path&&)): Add noexcept when
	appropriate. Move _M_cmpts instead of reparsing the native pathname.
	(path::operator=(const path&)): Do not define as defaulted.
	(path::operator/=, path::append): Call _M_append.
	(path::concat): Call _M_concat.
	(path::path(string_type, _Type): Change type of first parameter to
	basic_string_view<value_type>.
	(path::_M_append(basic_string_view<value_type>)): New member function.
	(path::_M_concat(basic_string_view<value_type>)): New member function.
	(_S_convert(value_type*, __null_terminated)): Return string view.
	(_S_convert(const value_type*, __null_terminated)): Return string view.
	(_S_convert(value_type*, value_type*))
	(_S_convert(const value_type*, const value_type*)): Add overloads for
	pairs of pointers.
	(_S_convert(_InputIterator, __null_terminated)): Construct string_type
	explicitly, for cases where _S_convert returns a string view.
	(path::_S_is_dir_sep): Replace with non-member is_dir_sep.
	(path::_M_trim, path::_M_add_root_name, path::_M_add_root_dir)
	(path::_M_add_filename): Remove.
	(path::_M_type()): New member function to replace _M_type data member.
	(path::_List): Define new struct type instead of using std::vector.
	(path::_Cmpt::_Cmpt(string_type, _Type, size_t)): Change type of
	first parameter to basic_string_view<value_type>.
	(path::operator+=(const path&)): Do not define inline.
	(path::operator+=(const string_type&)): Call _M_concat.
	(path::operator+=(const value_type*)): Likewise.
	(path::operator+=(value_type)): Likewise.
	(path::operator+=(basic_string_view<value_type>)): Likewise.
	(path::operator/=(const path&)): Do not define inline.
	(path::_M_append(path)): Remove.
	* python/libstdcxx/v6/printers.py (StdPathPrinter): New printer that
	understands the new path::_List type.
	* src/filesystem/std-path.cc (is_dir_sep): New function to replace
	path::_S_is_dir_sep.
	(path::_Parser): New helper class to parse strings as paths.
	(path::_List::_Impl): Define container type for path components.
	(path::_List): Define members.
	(path::operator=(const path&)): Define explicitly, to provide the
	strong exception safety guarantee.
	(path::operator/=(const path&)): Implement manually by processing
	each component of the argument, rather than using _M_split_cmpts
	to parse the entire string again.
	(path::_M_append(string_type)): Likewise.
	(path::operator+=(const path&)): Likewise.
	(path::_M_concat(string_type)): Likewise.
	(path::remove_filename()): Perform trim directly instead of calling
	_M_trim().
	(path::_M_split_cmpts()): Rewrite in terms of _Parser class.
	(path::_M_trim, path::_M_add_root_name, path::_M_add_root_dir)
	(path::_M_add_filename): Remove.
	* testsuite/27_io/filesystem/path/append/source.cc: Test appending a
	string view that aliases the path.
	testsuite/27_io/filesystem/path/concat/strings.cc: Test concatenating
	a string view that aliases the path.

From-SVN: r267106
2018-12-13 20:33:55 +00:00
Jonathan Wakely a7a6c14a55 Fix [fs.path.gen] tests to use backslashes for mingw
The normalized paths contain backslashes so fix the expected values to
use backslashes too.

	* testsuite/27_io/filesystem/path/generation/proximate.cc: Use
	preferred directory separators for normalized paths.
	* testsuite/27_io/filesystem/path/generation/relative.cc: Likewise.

From-SVN: r267090
2018-12-13 12:26:52 +00:00