Commit Graph

10563 Commits

Author SHA1 Message Date
Jakub Jelinek 8f10fb5065 re PR ipa/86590 (Codegen is poor when passing std::string by value with _GLIBCXX_EXTERN_TEMPLATE undefined)
PR libstdc++/86590
	* include/bits/char_traits.h (__constant_string_p,
	__constant_char_array_p): Use __builtin_is_constant_evaluated if
	available.

From-SVN: r268112
2019-01-21 12:55:52 +01:00
Ulrich Drepper d715f55431 Fix after P0600.
gcc/testsuite/ChangeLog
2019-02-20  Ulrich Drepper  <drepper@redhat.com>

	Fix after P0600.
	* g++.dg/init/new39.C: Don't just ignore result of new.

libstdc++/ChangeLog
2019-02-20  Ulrich Drepper  <drepper@redhat.com>

	Implement C++20 P0600r1.
	* include/backward/hash_map: Add nodiscard attribute to empty.
	* include/backward/hash_set: Likewise.
	* backward/hashtable.h: Likewise.
	* include/bits/basic_string.h: Likewise.
	* include/bits/forward_list.h: Likewise.
	* include/bits/hashtable.h: Likewise.
	* include/bits/regex.h: Likewise.
	* include/bits/stl_deque.h: Likewise.
	* include/bits/stl_list.h: Likewise.
	* include/bits/stl_map.h: Likewise.
	* include/bits/stl_multimap.h: Likewise.
	* include/bits/stl_multiset.h: Likewise.
	* include/bits/stl_queue.h: Likewise.
	* include/bits/stl_set.h: Likewise.
	* include/bits/stl_stack.h: Likewise.
	* include/bits/stl_tree.h: Likewise.
	* include/bits/stl_vector.h: Likewise.
	* include/bits/unordered_map.h: Likewise.
	* include/bits/unordered_set.h: Likewise.
	* include/debug/array: Likewise.
	* include/experimental/any: Likewise.
	* include/experimental/bits/fs_path.h: Likewise.
	* include/experimental/internet: Likewise.
	* include/experimental/string_view: Likewise.
	* include/ext/pb_ds/detail/bin_search_tree_/info_fn_imps.hpp:
	Likewise.
	* include/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp:
	Likewise.
	* include/ext/pb_ds/detail/binary_heap_/info_fn_imps.hpp:
	Likewise.
	* include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp:
	Likewise.
	* include/ext/pb_ds/detail/cc_hash_table_map_/info_fn_imps.hpp:
	Likewise.
	* include/ext/pb_ds/detail/cc_hash_table_map_/size_fn_imps.hpp:
	Likewise.
	* include/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp:
	Likewise.
	* include/ext/pb_ds/detail/gp_hash_table_map_/info_fn_imps.hpp:
	Likewise.
	* include/ext/pb_ds/detail/left_child_next_sibling_heap_/info_fn_imps.hpp:
	Likewise.
	*
include/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp:
	Likewise.
	* include/ext/pb_ds/detail/list_update_map_/info_fn_imps.hpp:
	Likewise.
	* include/ext/pb_ds/detail/list_update_map_/lu_map_.hpp:
	Likewise.
	* include/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp:
	Likewise.
	* include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hp:
	Likewise.
	* include/ext/pb_ds/detail/pat_trie_/info_fn_imps.hpp:
	Likewise.
	* include/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp:
	Likewise.
	* include/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp:
	Likewise.
	* include/ext/pb_ds/detail/tree_trace_base.hpp: Likewise.
	* include/ext/pb_ds/trie_policy.hpp: Likewise.
	* include/ext/rope: Likewise.
	* include/ext/slist: Likewise.
	* include/ext/vstring.h: Likewise.
	* include/profile/array: Likewise.
	* include/std/array: Likewise.
	* include/tr1/array: Likewise.
	* include/tr1/hashtable.h: Likewise.
	* include/tr1/regex: Likewise.
	* include/tr2/dynamic_bitset: Likewise.
	* include/bits/alloc_traits.h: Add nodiscard attribute to
	allocate.
	* include/experimental/memory_resource: Likewise.
	* include/ext/alloc_traits.h: Likewise.
	* include/ext/array_allocator.h: Likewise.
	* include/ext/bitmap_allocator.h: Likewise.
	* include/ext/debug_allocator.h: Likewise.
	* include/ext/extptr_allocator.h: Likewise.
	* include/ext/mt_allocator.h: Likewise.
	* include/ext/new_allocator.h: Likewise.
	* include/ext/pool_allocator.h: Likewise.
	* include/ext/throw_allocator.h: Likewise.
	* include/std/scoped_allocator: Likewise.
	* libsupc++/eh_alloc.cc: Likewise.
	* include/std/future: Add nodiscard attribute to async.
	* libsupc++/new: Add nodiscard attribute to new.

From-SVN: r268111
2019-01-21 11:47:30 +00:00
Jonathan Wakely fb54aa5915 PR libstdc++/88782 avoid ODR problems in std::make_shared
The old version of _Sp_counted_ptr_inplace::_M_get_deleter (up to GCC
8.2.0) expects to be passed a real std::typeinfo object, so mixing that
with the new definition of the __shared_ptr constructor (which always
passes the fake tag) leads to accessing the fake object as a real
std::typeinfo. Instead of trying to make it safe to mix the old and new
definitions, just stop using that function. By passing a reference to
__shared_ptr::_M_ptr to the __shared_count constructor it can be set
directly, without needing to obtain the pointer via the _M_get_deleter
back-channel. This avoids a virtual dispatch (which fixes PR 87514).

This means that code built against new libstdc++ headers doesn't use
_M_get_deleter at all, and so make_shared works the same whether RTTI is
enabled or not.

Also change _M_get_deleter so that it checks for a real type_info object
even when RTTI is disabled, by calling a library function. Unless
libstdc++ itself is built without RTTI that library function will be
able to test if it's the right type_info. This means the new definition
of _M_get_deleter can handle both the fake type_info tag and a real
type_info object, even if built without RTTI.

If linking to objects built against older versions of libstdc++ then if
all objects use -frtti or all use -fno-rtti, then the caller of
_M_get_deleter and the definition of _M_get_deleter will be consistent
and it will work. If mixing -frtti with -fno-rtti it can still fail if
the linker picks an old definition of _M_get_deleter and an old
__shared_ptr constructor that are incompatible. In that some or all
objects might need to be recompiled.

	PR libstdc++/87514
	PR libstdc++/87520
	PR libstdc++/88782
	* config/abi/pre/gnu.ver (GLIBCXX_3.4.26): Export new symbol.
	* include/bits/shared_ptr.h
	(shared_ptr(_Sp_make_shared_tag, const Alloc&, Args&&...))
	(allocate_shared): Change to use new tag type.
	* include/bits/shared_ptr_base.h (_Sp_make_shared_tag::_S_eq):
	Declare new member function.
	(_Sp_alloc_shared_tag): Define new type.
	(_Sp_counted_ptr_inplace): Declare __shared_count<_Lp> as a friend.
	(_Sp_counted_ptr_inplace::_M_get_deleter) [!__cpp_rtti]: Use
	_Sp_make_shared_tag::_S_eq to check type_info.
	(__shared_count(Ptr, Deleter),__shared_count(Ptr, Deleter, Alloc)):
	Constrain to prevent being called with _Sp_alloc_shared_tag.
	(__shared_count(_Sp_make_shared_tag, const _Alloc&, Args&&...)):
	Replace constructor with ...
	(__shared_count(Tp*&, _Sp_alloc_shared_tag<_Alloc>, Args&&...)): Use
	reference parameter so address of the new object can be returned to
	the caller. Obtain the allocator from the tag type.
	(__shared_ptr(_Sp_make_shared_tag, const Alloc&, Args&&...)): Replace
	constructor with ...
	(__shared_ptr(_Sp_alloc_shared_tag<Alloc>, Args&&...)): Pass _M_ptr
	to the __shared_count constructor.
	(__allocate_shared): Change to use new tag type.
	* src/c++11/shared_ptr.cc (_Sp_make_shared_tag::_S_eq): Define.

From-SVN: r268086
2019-01-18 21:28:48 +00:00
Jonathan Wakely 16d46c7bfd Fix filesystem::equivalent for mingw
* src/c++17/fs_ops.cc
	(equivalent(const path&, const path&, error_code&))
	[_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Use GetFileInformationByHandle to
	compare files instead of relying on incomplete info returned by stat.

From-SVN: r268036
2019-01-17 15:32:10 +00:00
Jonathan Wakely fc6f857bd3 PR libstdc++/88884 fix filesystem::absolute("//") for mingw
PR libstdc++/88884
	* src/c++17/fs_ops.cc (absolute(const path&, error_code&)): Do nothing
	if the path is already absolute.
	[_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Normalize root-directory.
	[!_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Pass error_code to current_path.

From-SVN: r268035
2019-01-17 15:32:05 +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
Ulrich Drepper ec0d53719f PR libstdc++/88738 treat shared_ptr and unique_ptr more like plain old pointers
PR libstdc++/88738
        Warn about unused comparisons of shared_ptr/unique_ptr
        * include/bits/c++config [_GLIBCXX_NODISCARD]: Define.
        * include/bits/shared_ptr.h: Use it for operator ==, !=,
        <, <=, >, >= for shared_ptr.
        * include/bits/unique_ptr.h: Likewise for unique_ptr.

From-SVN: r267964
2019-01-16 08:01:22 +00:00
Jonathan Wakely 10ddff67d3 Update value of __cpp_lib_shared_ptr_arrays macro
* include/bits/shared_ptr_base.h (__cpp_lib_shared_ptr_arrays): Define
	as 201611L, because P0497R0 changes are supported.
	* include/std/version (__cpp_lib_shared_ptr_arrays): Likewise.

From-SVN: r267938
2019-01-15 13:13:11 +00:00
Jonathan Wakely 6e3dd211ca Fix more missing or incorrect feature test macros
* include/bits/erase_if.h [__cplusplus > 201703L]
	(__cpp_lib_erase_if): Only define for C++2a.
	* include/std/iterator [__cplusplus >= 201402L && !_GLIBCXX_DEBUG]
	(__cpp_lib_null_iterators): Define.
	* include/std/version [__cplusplus >= 201402L && !_GLIBCXX_DEBUG]
	(__cpp_lib_null_iterators): Define.
	[__cpp_impl_destroying_delete] (__cpp_lib_destroying_delete): Define.

From-SVN: r267937
2019-01-15 12:58:19 +00:00
Jonathan Wakely 56a9eaf9ab Fix missing or incorrect feature test macros
* doc/xml/manual/status_cxx2017.xml: Document P0032R3 and P0307R2
	status.
	* include/bits/stl_uninitialized.h (__cpp_lib_raw_memory_algorithms):
	Define.
	* include/std/any (__cpp_lib_any): Define as 201606L, because P0032R3
	changes are supported.
	* include/std/optional (__cpp_lib_optional): Likewise.
	* include/std/variant (__cpp_lib_variant): Likewise.
	* include/std/version [!__STRICT_ANSI__]
	(__cpp_lib_uncaught_exceptions): Define as long integer.
	[__cplusplus >= 201703L] (__cpp_lib_any)
	(__cpp_lib_raw_memory_algorithms, __cpp_lib_uncaught_exceptions)
	(__cpp_lib_variant): Define for C++17.
	[__cplusplus >= 201703L] (__cpp_lib_optional): Update value and define
	as long integer.
	* libsupc++/exception (__cpp_lib_uncaught_exceptions): Define as long
	integer.

From-SVN: r267936
2019-01-15 12:01:12 +00:00
Jonathan Wakely 04fdd1fdec * doc/xml/manual/status_cxx2020.xml: Update P1123R0 status.
From-SVN: r267935
2019-01-15 10:34:18 +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 66dc59e24f Document C++20 library status
* doc/xml/manual/intro.xml: Include new section.
	* doc/xml/manual/status_cxx2017.xml: Document more
	implementation-defined properties of the library.
	* doc/xml/manual/status_cxx2020.xml: Document C++2a status.
	* doc/html/*: Regenerate.

From-SVN: r267867
2019-01-11 23:41:15 +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 e334d7a702 Fix location of __cpp_lib_erase_if macro
This macro should only be defined for C++2a, not C++17.

	* include/std/version (__cpp_lib_erase_if): Move to C++20 group.

From-SVN: r267863
2019-01-11 23:40:58 +00:00
Jakub Jelinek 8aa1550e23 Remove trailing whitespace from latest commit.
From-SVN: r267849
2019-01-11 17:55:13 +01:00
Jakub Jelinek 134a6f7b10 type_traits (__cpp_lib_is_constant_evaluated): Define.
* include/std/type_traits (__cpp_lib_is_constant_evaluated): Define.
	* include/std/version (__cpp_lib_is_constant_evaluated): Define.

From-SVN: r267847
2019-01-11 17:01:23 +01: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 bbed72f559 PR libstdc++/88125 remove duplicate entry in linker script
PR libstdc++/88125
	* config/abi/pre/gnu.ver (GLIBCXX_3.4.6): Remove unused duplicate
	pattern for std::basic_stringbuf::str().

From-SVN: r267834
2019-01-11 11:39:45 +00:00
Jonathan Wakely 8ce7e3f8e9 Fix incorrect linker script patterns
The recent changes to support operator<<(nullptr_t) changed the glob
patterns for existing operator<<(T) overloads, but did so incorrectly so
they still matched the new symbols. That broke Solaris bootstrap. This
patch replaces each of the existing globs by two more precise ones,
which match the old symbols but not the new ones.

	* config/abi/pre/gnu.ver (GLIBCXX_3.4): Correct recent changes to
	basic_ostream::operator<< patterns.

From-SVN: r267832
2019-01-11 10:25:46 +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
Jakub Jelinek 6cdf1946f6 re PR tree-optimization/88775 (Optimize std::string assignment)
PR tree-optimization/88775
	* include/bits/stl_function.h (greater<_Tp*>::operator(),
	less<_Tp*>::operator(), greater_equal<_Tp*>::operator(),
	less_equal<_Tp*>::operator()): Use __builtin_is_constant_evaluated
	instead of __builtin_constant_p if available.  Don't bother with
	the pointer comparison in C++11 and earlier.

From-SVN: r267800
2019-01-10 11:56:56 +01:00
Sandra Loosemore 6791469314 PR other/16615 [1/5]
2019-01-09  Sandra Loosemore  <sandra@codesourcery.com>

	PR other/16615 [1/5]

	contrib/
	* mklog: Mechanically replace "can not" with "cannot".

	gcc/
	* Makefile.in: Mechanically replace "can not" with "cannot".
	* alias.c: Likewise.
	* builtins.c: Likewise.
	* calls.c: Likewise.
	* cgraph.c: Likewise.
	* cgraph.h: Likewise.
	* cgraphclones.c: Likewise.
	* cgraphunit.c: Likewise.
	* combine-stack-adj.c: Likewise.
	* combine.c: Likewise.
	* common/config/i386/i386-common.c: Likewise.
	* config/aarch64/aarch64.c: Likewise.
	* config/alpha/sync.md: Likewise.
	* config/arc/arc.c: Likewise.
	* config/arc/predicates.md: Likewise.
	* config/arm/arm-c.c: Likewise.
	* config/arm/arm.c: Likewise.
	* config/arm/arm.h: Likewise.
	* config/arm/arm.md: Likewise.
	* config/arm/cortex-r4f.md: Likewise.
	* config/csky/csky.c: Likewise.
	* config/csky/csky.h: Likewise.
	* config/darwin-f.c: Likewise.
	* config/epiphany/epiphany.md: Likewise.
	* config/i386/i386.c: Likewise.
	* config/i386/sol2.h: Likewise.
	* config/m68k/m68k.c: Likewise.
	* config/mcore/mcore.h: Likewise.
	* config/microblaze/microblaze.md: Likewise.
	* config/mips/20kc.md: Likewise.
	* config/mips/sb1.md: Likewise.
	* config/nds32/nds32.c: Likewise.
	* config/nds32/predicates.md: Likewise.
	* config/pa/pa.c: Likewise.
	* config/rs6000/e300c2c3.md: Likewise.
	* config/rs6000/rs6000.c: Likewise.
	* config/s390/s390.h: Likewise.
	* config/sh/sh.c: Likewise.
	* config/sh/sh.md: Likewise.
	* config/spu/vmx2spu.h: Likewise.
	* cprop.c: Likewise.
	* dbxout.c: Likewise.
	* df-scan.c: Likewise.
	* doc/cfg.texi: Likewise.
	* doc/extend.texi: Likewise.
	* doc/fragments.texi: Likewise.
	* doc/gty.texi: Likewise.
	* doc/invoke.texi: Likewise.
	* doc/lto.texi: Likewise.
	* doc/md.texi: Likewise.
	* doc/objc.texi: Likewise.
	* doc/rtl.texi: Likewise.
	* doc/tm.texi: Likewise.
	* dse.c: Likewise.
	* emit-rtl.c: Likewise.
	* emit-rtl.h: Likewise.
	* except.c: Likewise.
	* expmed.c: Likewise.
	* expr.c: Likewise.
	* fold-const.c: Likewise.
	* genautomata.c: Likewise.
	* gimple-fold.c: Likewise.
	* hard-reg-set.h: Likewise.
	* ifcvt.c: Likewise.
	* ipa-comdats.c: Likewise.
	* ipa-cp.c: Likewise.
	* ipa-devirt.c: Likewise.
	* ipa-fnsummary.c: Likewise.
	* ipa-icf.c: Likewise.
	* ipa-inline-transform.c: Likewise.
	* ipa-inline.c: Likewise.
	* ipa-polymorphic-call.c: Likewise.
	* ipa-profile.c: Likewise.
	* ipa-prop.c: Likewise.
	* ipa-pure-const.c: Likewise.
	* ipa-reference.c: Likewise.
	* ipa-split.c: Likewise.
	* ipa-visibility.c: Likewise.
	* ipa.c: Likewise.
	* ira-build.c: Likewise.
	* ira-color.c: Likewise.
	* ira-conflicts.c: Likewise.
	* ira-costs.c: Likewise.
	* ira-int.h: Likewise.
	* ira-lives.c: Likewise.
	* ira.c: Likewise.
	* ira.h: Likewise.
	* loop-invariant.c: Likewise.
	* loop-unroll.c: Likewise.
	* lower-subreg.c: Likewise.
	* lra-assigns.c: Likewise.
	* lra-constraints.c: Likewise.
	* lra-eliminations.c: Likewise.
	* lra-lives.c: Likewise.
	* lra-remat.c: Likewise.
	* lra-spills.c: Likewise.
	* lra.c: Likewise.
	* lto-cgraph.c: Likewise.
	* lto-streamer-out.c: Likewise.
	* postreload-gcse.c: Likewise.
	* predict.c: Likewise.
	* profile-count.h: Likewise.
	* profile.c: Likewise.
	* recog.c: Likewise.
	* ree.c: Likewise.
	* reload.c: Likewise.
	* reload1.c: Likewise.
	* reorg.c: Likewise.
	* resource.c: Likewise.
	* rtl.def: Likewise.
	* rtl.h: Likewise.
	* rtlanal.c: Likewise.
	* sched-deps.c: Likewise.
	* sched-ebb.c: Likewise.
	* sched-rgn.c: Likewise.
	* sel-sched-ir.c: Likewise.
	* sel-sched.c: Likewise.
	* shrink-wrap.c: Likewise.
	* simplify-rtx.c: Likewise.
	* symtab.c: Likewise.
	* target.def: Likewise.
	* toplev.c: Likewise.
	* tree-call-cdce.c: Likewise.
	* tree-cfg.c: Likewise.
	* tree-complex.c: Likewise.
	* tree-core.h: Likewise.
	* tree-eh.c: Likewise.
	* tree-inline.c: Likewise.
	* tree-loop-distribution.c: Likewise.
	* tree-nrv.c: Likewise.
	* tree-profile.c: Likewise.
	* tree-sra.c: Likewise.
	* tree-ssa-alias.c: Likewise.
	* tree-ssa-dce.c: Likewise.
	* tree-ssa-dom.c: Likewise.
	* tree-ssa-forwprop.c: Likewise.
	* tree-ssa-loop-im.c: Likewise.
	* tree-ssa-loop-ivcanon.c: Likewise.
	* tree-ssa-loop-ivopts.c: Likewise.
	* tree-ssa-loop-niter.c: Likewise.
	* tree-ssa-phionlycprop.c: Likewise.
	* tree-ssa-phiopt.c: Likewise.
	* tree-ssa-propagate.c: Likewise.
	* tree-ssa-threadedge.c: Likewise.
	* tree-ssa-threadupdate.c: Likewise.
	* tree-ssa-uninit.c: Likewise.
	* tree-ssanames.c: Likewise.
	* tree-streamer-out.c: Likewise.
	* tree.c: Likewise.
	* tree.h: Likewise.
	* vr-values.c: Likewise.

	gcc/ada/
	* exp_ch9.adb: Mechanically replace "can not" with "cannot".
	* libgnat/s-regpat.ads: Likewise.
	* par-ch4.adb: Likewise.
	* set_targ.adb: Likewise.
	* types.ads: Likewise.

	gcc/cp/
	* cp-tree.h: Mechanically replace "can not" with "cannot".
	* parser.c: Likewise.
	* pt.c: Likewise.

	gcc/fortran/
	* class.c: Mechanically replace "can not" with "cannot".
	* decl.c: Likewise.
	* expr.c: Likewise.
	* gfc-internals.texi: Likewise.
	* intrinsic.texi: Likewise.
	* invoke.texi: Likewise.
	* io.c: Likewise.
	* match.c: Likewise.
	* parse.c: Likewise.
	* primary.c: Likewise.
	* resolve.c: Likewise.
	* symbol.c: Likewise.
	* trans-array.c: Likewise.
	* trans-decl.c: Likewise.
	* trans-intrinsic.c: Likewise.
	* trans-stmt.c: Likewise.

	gcc/go/
	* go-backend.c: Mechanically replace "can not" with "cannot".
	* go-gcc.cc: Likewise.

	gcc/lto/
	* lto-partition.c: Mechanically replace "can not" with "cannot".
	* lto-symtab.c: Likewise.
	* lto.c: Likewise.

	gcc/objc/
	* objc-act.c: Mechanically replace "can not" with "cannot".

	libbacktrace/
	* backtrace.h: Mechanically replace "can not" with "cannot".

	libgcc/
	* config/c6x/libunwind.S: Mechanically replace "can not" with
	"cannot".
	* config/tilepro/atomic.h: Likewise.
	* config/vxlib-tls.c: Likewise.
	* generic-morestack-thread.c: Likewise.
	* generic-morestack.c: Likewise.
	* mkmap-symver.awk: Likewise.

	libgfortran/
	* caf/single.c: Mechanically replace "can not" with "cannot".
	* io/unit.c: Likewise.

	libobjc/
	* class.c: Mechanically replace "can not" with "cannot".
	* objc/runtime.h: Likewise.
	* sendmsg.c: Likewise.

	liboffloadmic/
	* include/coi/common/COIResult_common.h: Mechanically replace
	"can not" with "cannot".
	* include/coi/source/COIBuffer_source.h: Likewise.

	libstdc++-v3/
	* include/ext/bitmap_allocator.h: Mechanically replace "can not"
	with "cannot".

From-SVN: r267783
2019-01-09 16:37:45 -05: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 50b0a3d672 Remove some more code duplication in std::optional
Hoist the duplicated code from the _Optional_payload partial
specializations into the _Optional_payload_base base class.

	* include/std/optional (_Optional_payload_base::_M_copy_assign): New
	member function to perform non-trivial assignment.
	(_Optional_payload_base::_M_move_assign): Likewise.
	(_Optional_payload<T, true, false, true>::operator=)
	(_Optional_payload<T, true, true, false>::operator=)
	(_Optional_payload<T, true, false, false>::operator=): Call
	_M_copy_assign and/or _M_move_assign to do non-trivial assignments.

From-SVN: r267761
2019-01-09 10:40:49 +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 9f5391ee95 PR libstdc++/88066 use <> for includes not ""
Using #include "..." to include a header in the same directory fails if
the user compiles with -I-, so always use something like <bits/...> for
internal headers.

I haven't added tests for this, because dg-options adds options to the
end, and the position of -I- matters (if it's at the end then the tests
won't find any headers in the build tree, as they're specified by -I
options earlier in the flags). It's been manually tested though.

	PR libstdc++/88066
	* include/bits/locale_conv.h: Use <> for includes not "".
	* include/ext/random: Likewise.
	* include/ext/vstring.h: Likewise.

From-SVN: r267726
2019-01-08 13:25:19 +00:00
Rainer Orth e93bfd2de5 Fix libstdc++.so link on Solaris with C++17 std::basic_string member functions
* config/abi/pre/gnu.ver (GLIBCXX_3.4): Tighten existing patterns.
	(GLIBCXX_3.4.21): Likewise.

From-SVN: r267723
2019-01-08 12:04:38 +00:00
Jonathan Wakely 35724e5154 PR libstdc++/88749 fix build failure in src/filesystem/ops.cc
PR libstdc++/88749
	* src/filesystem/ops.cc (last_write_time): Fix preprocessor condition
	to match the one that controls whether utimbuf and utime are declared.

From-SVN: r267705
2019-01-08 10:18:54 +00:00
Jonathan Wakely e002afaa8e PR libstdc++/87787 avoid undefined null args to memcpy and memmove
The C++ char_traits and ctype APIs do not disallow null pointer
arguments, so we need explicit checks to ensure we don't forward null
pointers to memcpy or memmove.

	PR libstdc++/87787
	* include/bits/char_traits.h (char_traits::move): Do not pass null
	pointers to memmove.
	* include/bits/locale_facets.h
	(ctype<char>::widen(const char*, const char*, char*)): Do not
	pass null pointers to memcpy.
	(ctype<char>::narrow(const char*, const char*, char, char*)):
	Likewise.
	(ctype<char>::do_widen(const char*, const char*, char*)):
	Likewise.
	(ctype<char>::do_narrow(const char*, const char*, char, char*)):
	Likewise.

From-SVN: r267651
2019-01-07 14:58:44 +00:00
Jonathan Wakely f0f1121b40 Update documentation for C++17 filesystem library
* doc/xml/manual/spine.xml: Update copyright years.
	* doc/xml/manual/status_cxx2017.xml: Adjust note about -lstdc++fs.
	* doc/xml/manual/using.xml: Remove requirement to link with -lstdc++fs
	for C++17 filesystem library.
	* doc/html/*: Regenerate.

From-SVN: r267648
2019-01-07 12:46:40 +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 beb04ce9d4 Define new filesystem::__file_clock type
In C++17 the clock used for filesystem::file_time_type is unspecified,
allowing it to be chrono::system_clock. The C++2a draft requires it to
be a distinct type, with additional member functions to convert to/from
other clocks (either the system clock or UTC). In order to avoid an ABI
change later, this patch defines a new distinct type now, which will be
used for std::chrono::file_clock later.

	* include/bits/fs_fwd.h (__file_clock): Define new clock.
	(file_time_type): Redefine in terms of __file_clock.
	* src/filesystem/ops-common.h (file_time): Add FIXME comment about
	overflow.
	* src/filesystem/std-ops.cc (is_set(perm_options, perm_options)): Give
	internal linkage.
	(internal_file_lock): New helper type for accessing __file_clock.
	(do_copy_file): Use internal_file_lock to convert system time to
	file_time_type.
	(last_write_time(const path&, error_code&)): Likewise.
	(last_write_time(const path&, file_time_type, error_code&)): Likewise.

From-SVN: r267602
2019-01-05 20:03:22 +00:00
Jonathan Wakely 1a289fa362 Export explicit instantiations for C++17 members of std::string
The C++17 standard added some new members to std::basic_string, which
were not previously instantiated in the library. This meant that the
extern template declarations had to be disabled for C++17 mode. With
this patch the new members are instantiated in the library and so the
explicit instantiation declarations can be used for C++17.

The new members added by C++2a are still not exported, and so the
explicit instantiation declarations are still disabled for C++2a.

	* config/abi/pre/gnu.ver (GLIBCXX_3.4.21): Make patterns less greedy
	for const member functions of std::basic_string.
	(GLIBCXX_3.4.26): Export member functions of std::basic_string added
	in C++17.
	* include/bits/basic_string.h (basic_string(__sv_wrapper, const A&)):
	Make non-standard constructor private.
	[!_GLIBCXX_USE_CXX11_ABI] (basic_string(__sv_wrapper, const A&)):
	Likewise.
	* include/bits/basic_string.tcc (std::string, std::wstring): Declare
	explicit instantiations for C++17 as well as earlier dialects.
	* src/c++17/Makefile.am: Add new source files.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++17/cow-string-inst.cc: New file defining explicit
	instantiations for basic_string member functions added in C++17.
	* src/c++17/string-inst.cc: Likewise.

From-SVN: r267585
2019-01-04 23:23:22 +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