Commit Graph

8866 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 4fe5c8c730 Add noexcept to filesystem::path query functions
In the standard these member functions are specified in terms of the
potentially-throwing path decompositions functions, but we implement
them without constructing any new paths or doing anything else that can
throw.

	PR libstdc++/71044
	* include/bits/fs_path.h (path::has_root_name)
	(path::has_root_directory, path::has_root_path)
	(path::has_relative_path, path::has_parent_path)
	(path::has_filename, path::has_stem, path::has_extension)
	(path::is_absolute, path::is_relative, path::_M_find_extension): Add
	noexcept.
	* src/c++17/fs_path.cc (path::has_root_name)
	(path::has_root_directory, path::has_root_path)
	(path::has_relative_path, path::has_parent_path)
	(path::has_filename, path::_M_find_extension): Add noexcept.

From-SVN: r268713
2019-02-09 00:25:39 +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 ed99e818e0 PR libstdc++/89194 untangle is_convertible and is_nothrow_convertible
The additional logic added to __is_convertible_helper in order to
support is_nothrow_convertible makes some uses of is_convertible
ill-formed. This appears to be due to PR c++/87603, but can be avoided
just by defining a separate helper for is_nothrow_convertible. The same
problems are likely to still exist for is_nothrow_convertible, but that
is new and so won't cause regressions for existing users of
is_convertible.

	PR libstdc++/89194
	* include/std/type_traits (__is_convertible_helper)
	(__is_convertible_helper<_From, _To, false>): Revert changes to
	support is_nothrow_convertible.
	(__is_nt_convertible_helper): New helper.
	(is_nothrow_convertible): Use __is_nt_convertible_helper.

From-SVN: r268543
2019-02-05 15:45:24 +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 2781287255 PR libstdc++/89090 avoid C++17 features in C++11/C++14 code
Although GCC and Clang both allow these features pre-C++17 in system
headers, Clang does issue warnings with -Wsystem-headers. It can also
complicate bisection and/or testcase reduction if # line markers are
stripped, because the code won't be known to come from system headers.

	PR libstdc++/89090
	* include/bits/stl_uninitialized.h (__relocate_a_1): Make unused
	parameter unnamed. Add message to static assertion.
	* include/bits/vector.tcc (vector::reserve, vector::_M_realloc_insert)
	(vector::_M_default_append): Use _GLIBCXX17_CONSTEXPR for if constexpr
	in C++11 code.

From-SVN: r268536
2019-02-05 14:44:56 +00:00
Marc Glisse 9aa2470ab2 Rename __is_trivially_relocatable to __is_bitwise_relocatable.
2019-02-05  Marc Glisse  <marc.glisse@inria.fr>

	PR libstdc++/87106
	* include/bits/stl_uninitialized.h (__is_trivially_relocatable):
	Rename...
	(__is_bitwise_relocatable): ... to this.
	(__relocate_a_1): Adapt.
	* include/bits/stl_deque.h (__is_trivially_relocatable): Rename...
	(__is_bitwise_relocatable): ... to this.

From-SVN: r268532
2019-02-05 09:33:36 +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
Ulrich Drepper 7341a03ab8 * doc/xml/manual/status_cxx2020.xml: Update P0600 entry.
From-SVN: r268398
2019-01-30 16:23:44 +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 45e7df858b Add missing exports for symbols used by directory iterators
* config/abi/pre/gnu.ver (GLIBCXX_3.4.26): Add missing exports for
	__shared_ptr instantiations used by gcc4-compatible ABI.

From-SVN: r268357
2019-01-29 00:47:43 +00:00
Jonathan Wakely f7f07df5e2 Avoid ambiguity between C++2a std::erase_if and LFTS version
These calls should have been qualified to avoid ADL anyway, but in C++2a
it becomes essential to qualify the calls in experimental::erase because
std::erase_if is also declared and the calls become ambiguous.

	* include/experimental/forward_list (experimental::erase): Qualify
	call to erase_if.
	* include/experimental/list (experimental::erase): Likewise.
	* include/std/forward_list (std::erase): Likewise.
	* include/std/list (std::erase): Likewise.

From-SVN: r268356
2019-01-29 00:47:38 +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 1f48525ded Ensure pool resources always use normal mode vector
The __pool_resource::_M_unpooled member was declared with type
std::vector, which means that the type depends on whether debug mode is
active or not. Because the non-inline definitions in
src/c++17/memory_resource.cc are never compiled with debug mode, the
type declared in the header doesn't match the type in the library
definitions, leading to undefined behaviour.

The solution is to ensure the header always uses the non-debug vector,
even when debug mode is active. To make this easier a new alias template
is defined: _GLIBCXX_STD_C::pmr::vector.

	* include/std/memory_resource (__pool_resource::_M_unpooled): Use
	normal mode vector, even for debug mode.
	* include/std/vector [_GLIBCXX_DEBUG] (_GLIBCXX_STD_C::pmr::vector):
	Define alias template for normal mode vector.

From-SVN: r268354
2019-01-29 00:47:25 +00:00
Jonathan Wakely c98f255154 PR libstdc++/68737 Do not use vsnprintf on HPUX
It doesn't conform to the spec, so use vsprintf with a large buffer
instead.

	PR libstdc++/68737
	* config/locale/generic/c_locale.h (__convert_from_v)
	[_GLIBCXX_USE_C99_STDIO]: Also check _GLIBCXX_HAVE_BROKEN_VSNPRINTF.
	* config/os/hpux/os_defines.h: Define _GLIBCXX_HAVE_BROKEN_VSNPRINTF.
	* include/bits/locale_facets.tcc (num_put::_M_insert_float)
	[_GLIBCXX_USE_C99_STDIO]: Also check _GLIBCXX_HAVE_BROKEN_VSNPRINTF.

From-SVN: r268350
2019-01-28 23:58:57 +00:00
Jonathan Wakely e658669fe1 PR libstdc++/88840 delay evaluation of constant until type is complete
Clang fails to compile std::vector<Incomplete> because the static member
__use_relocate cannot be evaluated for an incomplete type. Replace with
a static member function that will not be odr-used until needed, by
which point the type must be complete.

	PR libstdc++/88840
	* include/bits/stl_vector.h (vector::__use_relocate): Replace static
	data member with static member function _S_use_relocate().
	* include/bits/vector.tcc (vector::reserve, vector::_M_realloc_insert)
	(vector::_M_default_append): Use _S_use_relocate() instead of
	__use_relocate.

From-SVN: r268239
2019-01-24 15:39:25 +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
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 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