Commit Graph

10925 Commits

Author SHA1 Message Date
Jonathan Wakely 74fda2dc9f Fix value category bugs in std::reduce
* include/std/numeric (reduce(Iter, Iter, T, BinOp)): Fix value
	category used in invocable check.
	(reduce(Iter, Iter, T)): Pass initial value as rvalue.
	* testsuite/26_numerics/reduce/2.cc: New test.

From-SVN: r272477
2019-06-19 16:29:49 +01:00
Jonathan Wakely ed920373a5 Implement new serial algorithms from Parallelism TS (P0024R2)
These new (non-parallel) algorithms were added to C++17 along with the
parallel algorithms, but were missing from libstdc++.

	* include/bits/algorithmfwd.h: Change title of doc group.
	* include/bits/stl_algo.h (for_each_n): Add new C++17 algorithm from
	P0024R2.
	* include/bits/stl_numeric.h: Define doc group and add algos to it.
	* include/std/numeric (__is_random_access_iter): New internal trait.
	(reduce, transform_reduce, exclusive_scan, inclusive_scan)
	(transform_exclusive_scan, transform_inclusive_scan): Likewise.
	* testsuite/25_algorithms/for_each/for_each_n.cc: New test.
	* testsuite/26_numerics/exclusive_scan/1.cc: New test.
	* testsuite/26_numerics/inclusive_scan/1.cc: New test.
	* testsuite/26_numerics/reduce/1.cc: New test.
	* testsuite/26_numerics/transform_exclusive_scan/1.cc: New test.
	* testsuite/26_numerics/transform_inclusive_scan/1.cc: New test.
	* testsuite/26_numerics/transform_reduce/1.cc: New test.
	* testsuite/util/testsuite_iterators.h (test_container::size()): New
	member function.

From-SVN: r272459
2019-06-19 00:01:16 +01:00
Jonathan Wakely 0c65926ffa Avoid undefined behaviour in std::byte operators (LWG 2950)
* include/c_global/cstddef (std::byte): Perform arithmetic operations
	in unsigned int to avoid promotion (LWG 2950).

From-SVN: r272415
2019-06-18 12:39:43 +01:00
Jonathan Wakely 39f901e918 Fix AIX test failure due to replacement operator delete
On AIX the sized delete defined in the library will call the non-sized
delete defined in the library, not the replacement version defined in
the test file. By also replacing sized delete we make the test pass
everywhere.

	* testsuite/20_util/allocator/1.cc: Add sized delete, which fixes a
	failure on AIX.

From-SVN: r272391
2019-06-17 16:51:31 +01:00
Jonathan Wakely 360a758ec8 Add 'noexcept' to std::lerp
* include/c_global/cmath (__lerp, lerp): Add noexcept (LWG 3201).

From-SVN: r272386
2019-06-17 15:32:44 +01:00
Jonathan Wakely 26b1320ee5 PR libstdc++/90281 Fix string conversions for filesystem::path
Fix several bugs in the encoding conversions for filesystem::path that
prevent conversion of Unicode characters outside the Basic Multilingual
Plane, and prevent returning basic_string specializations with
alternative allocator types.

The std::codecvt_utf8 class template is not suitable for UTF-16
conversions because it uses UCS-2 instead. For conversions between UTF-8
and UTF-16 either std::codecvt<C, char, mbstate> or
codecvt_utf8_utf16<C> must be used.

The __str_codecvt_in and __str_codecvt_out utilities do not
return false on a partial conversion (e.g. for invalid or incomplete
Unicode input). Add new helpers that treat partial conversions as
errors, and use them for all filesystem::path conversions.

	PR libstdc++/90281 Fix string conversions for filesystem::path
	* include/bits/fs_path.h (u8path) [_GLIBCXX_FILESYSTEM_IS_WINDOWS]:
	Use codecvt_utf8_utf16 instead of codecvt_utf8. Use
	__str_codecvt_in_all to fail for partial conversions and throw on
	error.
	[!_GLIBCXX_FILESYSTEM_IS_WINDOWS && _GLIBCXX_USE_CHAR8_T]
	(path::_Cvt<char8_t>): Add explicit specialization.
	[_GLIBCXX_FILESYSTEM_IS_WINDOWS] (path::_Cvt::_S_wconvert): Remove
	overloads.
	[_GLIBCXX_FILESYSTEM_IS_WINDOWS] (path::_Cvt::_S_convert): Use
	if-constexpr instead of dispatching to _S_wconvert. Use codecvt
	instead of codecvt_utf8. Use __str_codecvt_in_all and
	__str_codecvt_out_all.
	[!_GLIBCXX_FILESYSTEM_IS_WINDOWS] (path::_Cvt::_S_convert): Use
	codecvt instead of codecvt_utf8. Use __str_codecvt_out_all.
	(path::_S_str_convert) [_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Use
	codecvt_utf8_utf16 instead of codecvt_utf8. Construct return values
	with allocator. Use __str_codecvt_out_all. Fallthrough to POSIX code
	after converting to UTF-8.
	(path::_S_str_convert): Use codecvt instead of codecvt_utf8. Use
	__str_codecvt_in_all.
	(path::string): Fix initialization of string types with different
	allocators.
	(path::u8string) [_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Use
	codecvt_utf8_utf16 instead of codecvt_utf8. Use __str_codecvt_out_all.
	* include/bits/locale_conv.h (__do_str_codecvt): Reorder static and
	runtime conditions.
	(__str_codecvt_out_all, __str_codecvt_in_all): New functions that
	return false for partial conversions.
	* include/experimental/bits/fs_path.h (u8path):
	[_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Implement correctly for mingw.
	[_GLIBCXX_FILESYSTEM_IS_WINDOWS] (path::_Cvt::_S_wconvert): Add
	missing handling for char8_t. Use codecvt and codecvt_utf8_utf16
	instead of codecvt_utf8. Use __str_codecvt_in_all and
	__str_codecvt_out_all.
	[!_GLIBCXX_FILESYSTEM_IS_WINDOWS] (path::_Cvt::_S_convert): Use
	codecvt instead of codecvt_utf8. Use __str_codecvt_out_all.
	(path::string) [_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Use
	codecvt_utf8_utf16 instead of codecvt_utf8. Construct return values
	with allocator. Use __str_codecvt_out_all and __str_codecvt_in_all.
	(path::string) [!_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Use
	__str_codecvt_in_all.
	(path::u8string) [_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Use
	codecvt_utf8_utf16 instead of codecvt_utf8. Use __str_codecvt_out_all.
	* src/c++17/fs_path.cc (path::_S_convert_loc): Use
	__str_codecvt_in_all.
	* src/filesystem/path.cc (path::_S_convert_loc): Likewise.
	* testsuite/27_io/filesystem/path/construct/90281.cc: New test.
	* testsuite/27_io/filesystem/path/factory/u8path.cc: New test.
	* testsuite/27_io/filesystem/path/native/string.cc: Test with empty
	strings and with Unicode characters outside the basic multilingual
	plane.
	* testsuite/27_io/filesystem/path/native/alloc.cc: New test.
	* testsuite/experimental/filesystem/path/construct/90281.cc: New test.
	* testsuite/experimental/filesystem/path/factory/u8path.cc: New test.
	* testsuite/experimental/filesystem/path/native/alloc.cc: New test.
	* testsuite/experimental/filesystem/path/native/string.cc: Test with
	empty strings and with Unicode characters outside the basic
	multilingual plane.

From-SVN: r272385
2019-06-17 15:19:04 +01:00
François Dumont b0c849fadb Simplify node ownership in _Hashtable members
Introduce an RAII type to manage nodes in unordered containers while
they are being inserted. If the caller always owns a node until it is
inserted, then the insertion functions don't need to deallocate on
failure. This allows a FIXME in the node re-insertion API to be removed.

Also change extract(const key_type&) to not call extract(const_iterator)
anymore.  This avoids looping through the bucket nodes again to find the
node before the one being extracted.

2019-06-17  François Dumont  <fdumont@gcc.gnu.org>
	    Jonathan Wakely  <jwakely@redhat.com>

	* include/bits/hashtable.h (struct _Hashtable::_Scoped_node): New type.
	(_Hashtable::_M_insert_unique_node): Add key_type parameter. Don't
	deallocate node if insertion fails.
	(_Hashtable::_M_insert_multi_node): Likewise.
	(_Hashtable::_M_reinsert_node): Pass additional key argument.
	(_Hashtable::_M_reinsert_node_multi): Likewise. Remove FIXME.
	(_Hashtable::_M_extract_node(size_t, __node_base*)): New function.
	(_Hashtable::extract(const_iterator)): Use _M_extract_node.
	(_Hashtable::extract(const _Key&)): Likewise.
	(_Hashtable::_M_merge_unique): Pass additional key argument.
	(_Hashtable::_M_emplace<Args>(true_type, Args&&...)): Likewise. Use
	_Scoped_node.
	(_Hashtable::_M_insert): Likewise.
	* include/bits/hashtable_policy.h (_Map_base::operator[]): Likewise.
	(_Hashtable_alloc): Add comments to functions with misleading names.

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

From-SVN: r272381
2019-06-17 11:25:04 +01:00
Jonathan Wakely 9a9c7a625d Fix tests that fail without PCH
The recent change to stop transitively including <string> broke some
tests, but only when the library is configured without PCH, because
otherwise the <string> header still gets included via the precompiled
<bits/stdc++.h> header.

	* testsuite/20_util/bad_function_call/what.cc: Include <string> header
	for std::string.
	* testsuite/20_util/shared_ptr/cons/weak_ptr_expired.cc: Likewise.
	* testsuite/20_util/tuple/cons/allocator_with_any.cc: Include <memory>
	header for std::allocator.
	* testsuite/23_containers/array/tuple_interface/tuple_element.cc: Add
	using-declaration for std::size_t.
	* testsuite/23_containers/array/tuple_interface/tuple_size.cc:
	Likewise.
	* testsuite/23_containers/deque/cons/55977.cc: Include <istream> for
	std::istream.
	* testsuite/23_containers/vector/cons/55977.cc: Likewise.
	* testsuite/experimental/map/erasure.cc: Include <string> for
	std::string.
	* testsuite/experimental/unordered_map/erasure.cc: Likewise.

From-SVN: r272376
2019-06-17 09:18:17 +01:00
Jonathan Wakely cc28d23496 Disable -Wctor-dtor-privacy warnings for some standard types
* include/experimental/type_traits (experimental::nonesuch): Use
	pragma to disable -Wctor-dtor-privacy warnings.
	* include/std/type_traits (__is_convertible_helper<From, To, false>)
	(__is_nt_convertible_helper<From, To, false>, __nonesuch): Likewise.

From-SVN: r272289
2019-06-14 15:03:20 +01:00
Jonathan Wakely c68c4c982d Add __cpp_lib_bind_front macro to <version> header
* include/std/version (__cpp_lib_bind_front): Add missing macro.

From-SVN: r272288
2019-06-14 15:03:16 +01:00
Jonathan Wakely 95b3d0fda3 Fix incorrect __cpp_lib_parallel_algorithm macro definitions
* include/std/algorithm (__cpp_lib_parallel_algorithm): Fix value.
	* include/std/memory (__cpp_lib_parallel_algorithm): Likewise.
	* include/std/numeric (__cpp_lib_parallel_algorithm): Likewise.
	* testsuite/25_algorithms/pstl/feature_test.cc: New test.

From-SVN: r272216
2019-06-12 21:16:03 +01:00
Jonathan Wakely 801b2266de Improve static_assert messages for std::variant
Also fix a warning with -Wunused-parameter -Wsystem-headers.

	* include/std/variant (get<T>, get<N>, get_if<N>, get_if<T>)
	(variant::emplace): Change static_assert messages from "should be"
	to "must be".
	(hash<monostate>::operator()): Remove name of unused parameter.

From-SVN: r272188
2019-06-12 15:52:09 +01:00
Jonathan Wakely ce657a7414 Simplify std::scoped_lock destructor
* include/std/mutex (scoped_lock::~scoped_lock()): Use fold
	expression.

From-SVN: r272187
2019-06-12 15:52:06 +01:00
Jonathan Wakely cd0b94e650 Replace std::to_string for integers with optimized version
The std::to_chars functions from C++17 can be used to implement
std::to_string with much better performance than calling snprintf. Only
the __detail::__to_chars_len and __detail::__to_chars_10 functions are
needed for to_string, because it always outputs base 10 representations.

The return type of __detail::__to_chars_10 should not be declared before
C++17, so the function body is extracted into a new function that can be
reused by to_string and __detail::__to_chars_10.

The existing tests for to_chars rely on to_string to check for correct
answers. Now that they use the same code that doesn't actually ensure
correctness, so add new tests for std::to_string that compare against
printf output.

	* include/Makefile.am: Add new <bits/charconv.h> header.
	* include/Makefile.in: Regenerate.
	* include/bits/basic_string.h (to_string(int), to_string(unsigned))
	(to_string(long), to_string(unsigned long), to_string(long long))
	(to_string(unsigned long long)): Rewrite to use __to_chars_10_impl.
	* include/bits/charconv.h: New header.
	(__detail::__to_chars_len): Move here from <charconv>.
	(__detail::__to_chars_10_impl): New function extracted from
	__detail::__to_chars_10.
	* include/std/charconv (__cpp_lib_to_chars): Add, but comment out.
	(__to_chars_unsigned_type): New class template that reuses
	__make_unsigned_selector_base::__select to pick a type.
	(__unsigned_least_t): Redefine as __to_chars_unsigned_type<T>::type.
	(__detail::__to_chars_len): Move to new header.
	(__detail::__to_chars_10): Add inline specifier. Move code doing the
	output to __detail::__to_chars_10_impl and call that.
	* include/std/version (__cpp_lib_to_chars): Add, but comment out.
	* testsuite/21_strings/basic_string/numeric_conversions/char/
	to_string.cc: Fix reference in comment. Remove unused variable.
	* testsuite/21_strings/basic_string/numeric_conversions/char/
	to_string_int.cc: New test.

From-SVN: r272186
2019-06-12 15:52:02 +01:00
Edward Smith-Rowland d37c29f942 Fix ConstexprIterator requirements tests - No constexpr algorithms!
2019-06-09  Edward Smith-Rowland  <3dw4rd@verizon.net>

	Fix ConstexprIterator requirements tests - No constexpr algorithms!
	* testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc:
	Replace copy with hand-rolled loop.
	* testsuite/23_containers/array/requirements/constexpr_iter.cc:
	Ditto.

From-SVN: r272159
2019-06-11 16:29:35 +00:00
Edward Smith-Rowland 79f31e3d18 Test for C++20 p0858 - ConstexprIterator requirements.
2019-06-08  Edward Smith-Rowland  <3dw4rd@verizon.net>

	Test for C++20 p0858 - ConstexprIterator requirements.
	* testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc:
	New test.
	* testsuite/23_containers/array/requirements/constexpr_iter.cc:
	New test.

From-SVN: r272085
2019-06-08 22:18:36 +00:00
Thomas Rodgers f32ee8a25e Synchronize libstdc++ PSTL with upstream LLVM PSTL
Rename PSTL macro's consistent with libstdc++ (and llvm upstream
	project) standards.
	* include/bits/c++config: Rename all macros of the form __PSTL* to
	_PSTL*.
	* include/std/algorithm: Likewise.
	* include/std/execution: Likewise.
	* include/std/numeric: Likewise.
	* include/std/memory: Likewise.
	* include/pstl/glue_memory_impl.h: Likewise.
	* include/pstl/numeric_impl.h: Likewise.
	* include/pstl/glue_memory_defs.h: Likewise.
	* include/pstl/execution_defs.h: Likewise.
	* include/pstl/utils.h: Likewise.
	* include/pstl/algorithm_fwd.h: Likewise.
	* include/pstl/unseq_backend_simd.h: Likewise.
	* include/pstl/glue_execution_defs.h: Likewise.
	* include/pstl/algorithm_impl.h: Likewise.
	* include/pstl/parallel_impl.h: Likewise.
	* include/pstl/memory_impl.h: Likewise.
	* include/pstl/glue_numeric_defs.h: Likewise.
	* include/pstl/parallel_backend_utils.h: Likewise.
	* include/pstl/glue_algorithm_defs.h: Likewise.
	* include/pstl/parallel_backend.h: Likewise.
	* include/pstl/glue_numeric_impl.h: Likewise.
	* include/pstl/parallel_backend_tbb.h: Likewise.
	* include/pstl/numeric_fwd.h: Likewise.
	* include/pstl/glue_algorithm_impl.h: Likewise.
	* include/pstl/execution_impl.h: Likewise.
	* include/pstl/pstl_config.h: Likewise.
	* testsuite/util/pstl/pstl_test_config.h: Likewise.
	* testsuite/util/pstl/test_utils.h: Likewise.
	* testsuite/20_util/specialized_algorithms/pstl/uninitialized_construct.cc:
	Likewise.
	* testsuite/20_util/specialized_algorithms/pstl/uninitialized_copy_move.cc:
	Likewise.
	* testsuite/26_numerics/pstl/numeric_ops/adjacent_difference.cc:
	Likewise.
	* testsuite/26_numerics/pstl/numeric_ops/scan.cc: Likewise.
	* testsuite/26_numerics/pstl/numeric_ops/transform_scan.cc: Likewise.
	* testsuite/26_numerics/pstl/numeric_ops/reduce.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/reverse.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_end.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_if.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/none_of.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/count.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/reverse_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/equal.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/search_n.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/all_of.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_first_of.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/is_heap.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/partial_sort.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/partial_sort_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/lexicographical_compare.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_merge/inplace_merge.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_merge/merge.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/unique_copy_equal.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/replace_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/is_partitioned.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/rotate_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/remove.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/copy_if.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/partition_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/partition.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/copy_move.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/unique.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/rotate.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/any_of.cc: Likewise.

	Rename header guards to be consistent with upstream project's
	conventions.
	* include/pstl/glue_memory_impl.h: Rename all macros of the form
	_PSTL_(.*)_H to _PSTL_\U\1_H.
	* include/pstl/numeric_impl.h: Likewise.
	* include/pstl/glue_memory_defs.h: Likewise.
	* include/pstl/execution_defs.h: Likewise.
	* include/pstl/utils.h: Likewise.
	* include/pstl/algorithm_fwd.h: Likewise.
	* include/pstl/unseq_backend_simd.h: Likewise.
	* include/pstl/glue_execution_defs.h: Likewise.
	* include/pstl/algorithm_impl.h: Likewise.
	* include/pstl/parallel_impl.h: Likewise.
	* include/pstl/memory_impl.h: Likewise.
	* include/pstl/glue_numeric_defs.h: Likewise.
	* include/pstl/parallel_backend_utils.h: Likewise.
	* include/pstl/glue_algorithm_defs.h: Likewise.
	* include/pstl/parallel_backend.h: Likewise.
	* include/pstl/glue_numeric_impl.h: Likewise.
	* include/pstl/parallel_backend_tbb.h: Likewise.
	* include/pstl/numeric_fwd.h: Likewise.
	* include/pstl/glue_algorithm_impl.h: Likewise.
	* include/pstl/execution_impl.h: Likewise.
	* include/pstl/pstl_config.h: Likewise.
	* testsuite/util/pstl/pstl_test_config.h: Likewise.

	Synchronize libstdc++ parallel algorithms with upstream
	project.
	* include/pstl/algorithm_fwd.h: Synchronize with
	upstream PSTL project.
	* include/pstl/algorithm_impl.h: Likewise.
	* include/pstl/execution_defs.h: Likewise.
	* include/pstl/execution_impl.h: Likewise.
	* include/pstl/glue_algorithm_impl.h: Likewise.
	* include/pstl/glue_execution_defs.h: Likewise.
	* include/pstl/numeric_fwd.h: Likewise.
	* include/pstl/numeric_impl.h: Likewise.
	* include/pstl/parallel_backend.h: Likewise.
	* include/pstl/pstl_config.h: Likewise.
	* include/pstl/unseq_backend_simd.h: Likewise.
	* include/pstl/parallel_backend_serial.h: New file.
	* include/Makefile.am (pstl_headers): Add
	parallel_backend_serial.h.
	* include/Makefile.in: Regenerate.

	Clean up non-conforming names
	* include/pstl/algorithm_impl.h (__parallel_set_union_op):
	Uglfiy copy_range1 and copy_range2
	(__pattern_walk2_n): Rename local n to __n
	* include/pstl/parallel_backend_tbb.h (struct __binary_no_op):
	Rename parameter _T to _Tp.

	Integrate non-TBB serial backend support
	* include/bits/c++config: Adjust TBB detection logic to select serial
	PSTL backend if no TBB present.
	* testsuite/utils/pstl/test_utils.h: Remove check for
	_PSTL_USE_PAR_POLICIES

From-SVN: r272056
2019-06-07 22:01:16 +00:00
Jonathan Wakely c1b4c4f491 Fix test that gets skipped as unsupported
* testsuite/24_iterators/container_access.cc: Move dg-options before
	dg-do directive so the target check uses the -std option.

From-SVN: r272051
2019-06-07 20:57:28 +01:00
Jonathan Wakely 2b32668568 PR libstdc++/90770 fix missing src/debug/Makefile
PR libstdc++/90770
	* configure: Regenerate.
	* src/Makefile.am (stamp-debug): Also test for missing makefile.
	* src/Makefile.in: Regenerate.

From-SVN: r272050
2019-06-07 20:57:19 +01:00
Jonathan Wakely beb0086f59 Avoid unnecessary inclusion of <stdexcept> header
This can greatly reduce the amount of preprocessed code that is included
by other headers, because <stdexcept> depends on <string> which is huge.

	* include/std/array: Do not include <stdexcept>.
	* include/std/optional: Include <exception> and
	<bits/exception_defines.h> instead of <stdexcept>.
	* testsuite/20_util/function_objects/searchers.cc: Include <cctype>
	for std::isalnum.
	* testsuite/20_util/tuple/cons/deduction.cc: Include <memory> for
	std::allocator.
	* testsuite/23_containers/map/erasure.cc: Include <string>.
	* testsuite/23_containers/unordered_map/erasure.cc: Likewise.

From-SVN: r272011
2019-06-06 16:34:56 +01:00
Jonathan Wakely ad60f42883 Fix more failing tests for C++98 mode
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Add
	dg-prune-output for different C++98 diagnostic.
	* testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc:
	Likewise.
	* testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc:
	Likewise.
	* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
	Likewise.
	* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
	Likewise.
	* testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc:
	Likewise.
	* testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc:
	Likewise.
	* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
	Likewise.
	* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
	Likewise.
	* testsuite/23_containers/vector/requirements/dr438/
	constructor_1_neg.cc: Likewise.
	* testsuite/23_containers/vector/requirements/dr438/
	constructor_2_neg.cc: Likewise.
	* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
	Likewise.
	* testsuite/libstdc++-prettyprinters/compat.cc: Do not run for C++98.

From-SVN: r272010
2019-06-06 16:34:51 +01:00
Jonathan Wakely d561a18ee6 Fix more tests that fail in C++2a mode
* testsuite/23_containers/unordered_map/requirements/debug_container.cc:
	Do not test allocator rebinding extension for C++2a.
	* testsuite/23_containers/unordered_set/allocator/ext_ptr.cc: Change
	dg-do directive for C++17 and C++2a.

From-SVN: r272009
2019-06-06 16:34:45 +01:00
Jonathan Wakely a2dbc0bf2a Fix tests that fail in C++2a mode
The GNU extension that allows using the wrong allocator type with a
container is disabled for C++2a mode, because the standard now requires
a diagnostic. Fix the tests that fail when -std=gnu++2a is used.

Also remove some reundant tests that are duplicates of another test
except for a target specifier of c++11. Those tests previously set
-std=gnu++11 explicitly but that was replaced globally with a target
specifier. These tests existed to verify that explicit instantiation
worked for both C++98 and C++11 modes, but now do nothing because both
copies of the test use -std=gnu++14 by default. Instead of duplicating
the test we should be regularly running the whole testsuite with
different -std options.

	* testsuite/23_containers/deque/requirements/explicit_instantiation/
	1_c++0x.cc: Remove redundant test.
	* testsuite/23_containers/deque/requirements/explicit_instantiation/
	2.cc: Use target selector instead of preprocessor condition.
	* testsuite/23_containers/deque/requirements/explicit_instantiation/
	3.cc: Do not run test for C++2a.
	* testsuite/23_containers/forward_list/requirements/
	explicit_instantiation/3.cc: Likewise.
	* testsuite/23_containers/forward_list/requirements/
	explicit_instantiation/5.cc: Do not test allocator rebinding extension
	for C++2a.
	* testsuite/23_containers/list/requirements/explicit_instantiation/
	1_c++0x.cc: Remove redundant test.
	* testsuite/23_containers/list/requirements/explicit_instantiation/
	2.cc: Use target selector instead of preprocessor condition.
	* testsuite/23_containers/list/requirements/explicit_instantiation/
	3.cc: Do not run test for C++2a.
	* testsuite/23_containers/list/requirements/explicit_instantiation/
	5.cc: Do not test allocator rebinding extension for C++2a.
	* testsuite/23_containers/map/requirements/explicit_instantiation/
	1_c++0x.cc: Remove redundant test.
	* testsuite/23_containers/map/requirements/explicit_instantiation/
	2.cc: Adjust comment.
	* testsuite/23_containers/map/requirements/explicit_instantiation/
	3.cc: Do not run test for C++2a.
	* testsuite/23_containers/map/requirements/explicit_instantiation/
	5.cc: Do not test allocator rebinding extension for C++2a.
	* testsuite/23_containers/multimap/requirements/explicit_instantiation/
	1_c++0x.cc: Remove redundant test.
	* testsuite/23_containers/multimap/requirements/explicit_instantiation/
	3.cc: Do not run test for C++2a.
	* testsuite/23_containers/multimap/requirements/explicit_instantiation/
	5.cc: Do not test allocator rebinding extension for C++2a.
	* testsuite/23_containers/multiset/requirements/explicit_instantiation/
	3.cc: Do not run test for C++2a.
	* testsuite/23_containers/multiset/requirements/explicit_instantiation/
	5.cc: Do not test allocator rebinding extension for C++2a.
	* testsuite/23_containers/set/requirements/explicit_instantiation/3.cc:
	Do not run test for C++2a.
	* testsuite/23_containers/set/requirements/explicit_instantiation/
	1_c++0x.cc: Remove redundant test.
	* testsuite/23_containers/set/requirements/explicit_instantiation/5.cc:
	Do not test allocator rebinding extension for C++2a.
	* testsuite/23_containers/unordered_map/requirements/
	explicit_instantiation/3.cc: Likewise.
	* testsuite/23_containers/unordered_map/requirements/
	explicit_instantiation/5.cc: Do not test allocator rebinding extension
	for C++2a.
	* testsuite/23_containers/unordered_multimap/requirements/
	explicit_instantiation/3.cc: Do not run test for C++2a.
	* testsuite/23_containers/unordered_multimap/requirements/
	explicit_instantiation/5.cc: Do not test allocator rebinding extension
	for C++2a.
	* testsuite/23_containers/unordered_multiset/requirements/
	explicit_instantiation/3.cc: Do not run test for C++2a.
	* testsuite/23_containers/unordered_multiset/requirements/
	explicit_instantiation/5.cc: Do not test allocator rebinding extension
	for C++2a.
	* testsuite/23_containers/unordered_set/requirements/
	explicit_instantiation/3.cc: Do not run test for C++2a.
	* testsuite/23_containers/unordered_set/requirements/
	explicit_instantiation/5.cc: Do not test allocator rebinding extension
	for C++2a.
	* testsuite/23_containers/vector/ext_pointer/explicit_instantiation/
	2.cc: Remove redundant test.
	* testsuite/23_containers/vector/ext_pointer/explicit_instantiation/
	3.cc: Do not run test for C++2a.
	* testsuite/23_containers/vector/requirements/explicit_instantiation/
	3.cc: Likewise.

From-SVN: r272001
2019-06-06 14:36:27 +01:00
Jonathan Wakely 209ee62421 Remove redundant static assertions in [meta.unary.prop] traits
The type property predicates that are implemented by a compiler builtin
already do the right checks in the compiler. The checks for complete
type or unbounded arrays were wrong for these types anyway.

	* include/std/type_traits (is_empty, is_polymorphic, is_final)
	(is_abstract, is_aggregate): Remove static_assert.
	* testsuite/20_util/is_abstract/incomplete_neg.cc: Check for error
	from builtin only.
	* testsuite/20_util/is_aggregate/incomplete_neg.cc: Likewise. Add
	missing -std=gnu++17 option.
	* testsuite/20_util/is_empty/incomplete_neg.cc: New test.
	* testsuite/20_util/is_final/incomplete_neg.cc: New test.
	* testsuite/20_util/is_polymorphic/incomplete_neg.cc: Check for error
	from builtin only.

From-SVN: r272000
2019-06-06 13:13:47 +01:00
Jonathan Wakely 061a745005 Fix tests that fail with -std=gnu++98 or -std=gnu++11
* testsuite/18_support/set_terminate.cc: Do not run for C++98 mode.
	* testsuite/18_support/set_unexpected.cc: Likewise.
	* testsuite/20_util/is_nothrow_invocable/value.cc: Test converting to
	void.
	* testsuite/20_util/is_nothrow_invocable/value_ext.cc: Fix constexpr
	function to be valid in C++11.
	* testsuite/26_numerics/complex/proj.cc: Do not run for C++98 mode.
	* testsuite/experimental/names.cc: Do not run for C++98 mode. Do not
	include Library Fundamentals or Networking headers in C++11 mode.
	* testsuite/ext/char8_t/atomic-1.cc: Do not run for C++98 mode.

From-SVN: r271999
2019-06-06 13:13:42 +01:00
Jonathan Wakely d355635e6b Refactor SFINAE constraints on std::tuple constructors
Replace the _TC class template with the better-named _TupleConstraints
one, which provides a different set of member functions. The new members
do not distinguish construction from lvalues and rvalues, but expects
the caller to do that by providing different template arguments. Within
the std::tuple primary template and std::tuple<T1, T2> partial
specialization the _TupleConstraints members are used via new alias
templates like _ImplicitCtor and _ExplicitCtor which makes the
constructor constraints less verbose and repetitive. For example, where
we previously had:

     template<typename... _UElements, typename
             enable_if<
                _TMC<_UElements...>::template
                   _MoveConstructibleTuple<_UElements...>()
                 && _TMC<_UElements...>::template
                   _ImplicitlyMoveConvertibleTuple<_UElements...>()
                 && (sizeof...(_Elements) >= 1),
       bool>::type=true>
       constexpr tuple(_UElements&&... __elements)

We now have:

     template<typename... _UElements,
             bool _Valid = __valid_args<_UElements...>(),
             _ImplicitCtor<_Valid, _UElements...> = true>
      constexpr
      tuple(_UElements&&... __elements)

There are two semantic changes as a result of the refactoring:

- The allocator-extended default constructor is now constrained.
- The rewritten constraints fix PR 90700.

	* include/std/tuple (_TC): Replace with _TupleConstraints.
	(_TupleConstraints): New helper for SFINAE constraints, with more
	expressive member functions to reduce duplication when used.
	(tuple::_TC2, tuple::_TMC, tuple::_TNTC): Remove.
	(tuple::_TCC): Replace dummy type parameter with bool non-type
	parameter that can be used to check the pack size.
	(tuple::_ImplicitDefaultCtor, tuple::_ExplicitDefaultCtor)
	(tuple::_ImplicitCtor, tuple::_ExplicitCtor): New alias templates for
	checking constraints in constructors.
	(tuple::__valid_args, tuple::_UseOtherCtor, tuple::__use_other_ctor):
	New SFINAE helpers.
	(tuple::tuple): Use new helpers to reduce repitition in constraints.
	(tuple::tuple(allocator_arg_t, const Alloc&)): Constrain.
	(tuple<T1, T2>::_TCC, tuple<T1, T2>::_ImplicitDefaultCtor)
	(tuple<T1, T2>::_ExplicitDefaultCtor, tuple<T1, T2>::_ImplicitCtor)
	(tuple<T1, T2>::_ExplicitCtor): New alias templates for checking
	constraints in constructors.
	(tuple::__is_alloc_arg()): New SFINAE helpers.
	(tuple<T1, T2>::tuple): Use new helpers to reduce repitition in
	constraints.
	(tuple<T1, T2>::tuple(allocator_arg_t, const Alloc&)): Constrain.
	* testsuite/20_util/tuple/cons/90700.cc: New test.
	* testsuite/20_util/tuple/cons/allocators.cc: Add default constructor
	to meet new constraint on allocator-extended default constructor.

From-SVN: r271998
2019-06-06 13:13:36 +01:00
Jonathan Wakely ffef1e30a7 Fix uses of static_assert not guarded by C++11 check
* include/bits/stl_map.h (map): Disable static assert for C++98 mode.
	* include/bits/stl_multimap.h (multimap): Likewise.

From-SVN: r271884
2019-06-03 23:18:31 +01:00
François Dumont 7cfe71d1d2 Rename variables and cleanup comments.
2019-06-03  François Dumont  <fdumont@gcc.gnu.org>

	Rename variables and cleanup comments.
	* include/bits/hashtable_policy.h
	* include/bits/hashtable.h

From-SVN: r271876
2019-06-03 17:08:34 +00:00
Jonathan Wakely bf5824f928 Corrections for C++2a library status table
* doc/xml/manual/status_cxx2020.xml: Add missing row for P0920R2.
	Fix bgcolor for P0340R3.
	* doc/html/*: Regenerate.

From-SVN: r271868
2019-06-03 14:32:17 +01:00
Jonathan Wakely 512a80ec49 PR libstdc++/90686 update C++2a library status docs
PR libstdc++/90686
	* doc/xml/manual/status_cxx2014.xml: Document what's missing from
	<experimental/memory_resource>.
	* doc/xml/manual/status_cxx2020.xml: Document status of P1285R0,
	P0339R6, P0340R3, P1164R1 and P1357R1.
	* doc/html/*: Regenerate.

From-SVN: r271867
2019-06-03 14:23:03 +01:00
Jonathan Wakely ebaf365963 Enforce allocator::value_type consistency for containers in C++2a
In previous standards it is undefined for a container and its allocator
to have a different value_type. Libstdc++ has traditionally allowed it
as an extension, automatically rebinding the allocator to the
container's value_type. Since GCC 8.1 that extension has been disabled
for C++11 and later when __STRICT_ANSI__ is defined (i.e. for
-std=c++11, -std=c++14, -std=c++17 and -std=c++2a).

Since the acceptance of P1463R1 into the C++2a draft an incorrect
allocator::value_type now requires a diagnostic. This patch implements
that by enabling the static_assert for -std=gnu++2a as well.

	* doc/xml/manual/status_cxx2020.xml: Document P1463R1 status.
	* include/bits/forward_list.h [__cplusplus > 201703]: Enable
	allocator::value_type assertion for C++2a.
	* include/bits/hashtable.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_set.h: Likewise.
	* include/bits/stl_vector.h: Likewise.
	* testsuite/23_containers/deque/48101-3_neg.cc: New test.
	* testsuite/23_containers/forward_list/48101-3_neg.cc: New test.
	* testsuite/23_containers/list/48101-3_neg.cc: New test.
	* testsuite/23_containers/map/48101-3_neg.cc: New test.
	* testsuite/23_containers/multimap/48101-3_neg.cc: New test.
	* testsuite/23_containers/multiset/48101-3_neg.cc: New test.
	* testsuite/23_containers/set/48101-3_neg.cc: New test.
	* testsuite/23_containers/unordered_map/48101-3_neg.cc: New test.
	* testsuite/23_containers/unordered_multimap/48101-3_neg.cc: New test.
	* testsuite/23_containers/unordered_multiset/48101-3_neg.cc: New test.
	* testsuite/23_containers/unordered_set/48101-3_neg.cc: New test.
	* testsuite/23_containers/vector/48101-3_neg.cc: New test.

From-SVN: r271866
2019-06-03 14:22:59 +01:00
Gerald Pfeifer d030d4c5a4 * doc/xml/manual/allocator.xml: Move hoard.org back to http.
From-SVN: r271827
2019-05-31 22:26:55 +00:00
Jonathan Wakely b1bb4869e2 Add noexcept to tuple<> and simplify tuple<T1,T2> noexcept-specifiers
* include/std/tuple (tuple<>): Add noexcept to allocator-extended
	constructors.
	(tuple<T1, T2>::__nothrow_default_constructible()): New helper
	function.
	(tuple<T1, T2>::tuple(), explicit tuple<T1, T2>::tuple()): Use helper.

From-SVN: r271814
2019-05-31 15:58:05 +01:00
Jonathan Wakely ff0b7e883d Fix breakage due to removing __gnu_cxx::size_t declaration
Restore the using-declaration but locally in the source file, not in the
header.

	* src/c++98/bitmap_allocator.cc: Add using-declaration for size_t.

From-SVN: r271812
2019-05-31 14:59:19 +01:00
Jonathan Wakely 3228289e1e PR libstdc++/90682 allow set_terminate(0) and set_unexpected(0)
Make these functions restore the default handlers when passed a null
pointer. This is consistent with std::pmr::set_default_resource(0), and
also matches the current behaviour of libc++.

In order to avoid duplicating the preprocessor condition from
eh_term_handler.cc more that into a new eh_term_handler.h header and
define a macro that can be used in both eh_term_handler.cc and
eh_terminate.cc.

	PR libstdc++/90682
	* libsupc++/eh_term_handler.cc: Include eh_term_handler.h to get
	definition of _GLIBCXX_DEFAULT_TERM_HANDLER.
	* libsupc++/eh_term_handler.h: New header defining
	_GLIBCXX_DEFAULT_TERM_HANDLER.
	* libsupc++/eh_terminate.cc: Include eh_term_handler.h.
	(set_terminate): Restore default handler when argument is null.
	(set_unexpected): Likewise.
	* testsuite/18_support/set_terminate.cc: New test.
	* testsuite/18_support/set_unexpected.cc: New test.

From-SVN: r271808
2019-05-31 11:35:11 +01:00
Jonathan Wakely 3263fb9c6b Remove using-declarations that add std names to __gnu_cxx
These using-declarations appear to have been added for simplicity when
moving the non-standard extensions from namespace std to namespace
__gnu_cxx. Dumping all these names into namespace __gnu_cxx allows
unportable uses like __gnu_cxx::size_t and __gnu_cxx::pair, which serve
no useful purpose.

This patch removes most of the using-declarations from namespace scope,
then either qualifies names as needed or adds using-declarations at
block scope or typedefs at class scope.

	* include/backward/hashtable.h (size_t, ptrdiff_t)
	(forward_iterator_tag, input_iterator_tag, _Construct, _Destroy)
	(distance, vector, pair, __iterator_category): Remove
	using-declarations that add these names to namespace __gnu_cxx.
	* include/ext/bitmap_allocator.h (size_t, ptrdiff_t): Likewise.
	* include/ext/debug_allocator.h (size_t): Likewise.
	* include/ext/functional (size_t, unary_function, binary_function)
	(mem_fun1_t, const_mem_fun1_t, mem_fun1_ref_t, const_mem_fun1_ref_t):
	Likewise.
	* include/ext/malloc_allocator.h (size_t, ptrdiff_t): Likewise.
	* include/ext/memory (ptrdiff_t, pair, __iterator_category): Likewise.
	* include/ext/mt_allocator.h (size_t, ptrdiff_t): Likewise.
	* include/ext/new_allocator.h (size_t, ptrdiff_t): Likewise.
	* include/ext/numeric (iota): Fix outdated comment.
	* include/ext/pool_allocator.h (size_t, ptrdiff_t): Likewise.
	* include/ext/rb_tree (_Rb_tree, allocator): Likewise.
	* include/ext/rope (size_t, ptrdiff_t, allocator, _Destroy): Likewise.
	* include/ext/ropeimpl.h (size_t, printf, basic_ostream)
	(__throw_length_error, _Destroy, std::__uninitialized_fill_n_a):
	Likewise.
	* include/ext/slist (size_t, ptrdiff_t, _Construct, _Destroy)
	(allocator, __true_type, __false_type): Likewise.

From-SVN: r271807
2019-05-31 11:35:07 +01:00
Antony Polukhin 608a080c3f PR libstdc++/71579 assert that type traits are not misused with incomplete types
This patch adds static asserts for type traits misuse with incomplete
classes and unions. This gives a nice readable error message instead
of an UB and odr-violations.

Some features of the patch:
* each type trait has it's own static_assert inside. This gives better
diagnostics than the approach with putting the assert into a helper
structure and using it in each trait.
* the result of completeness check is not memorized by the compiler.
This gives no false positive after the first failed check.
* some of the compiler builtins already implement the check. But not
all of them! So the asserts are in all the type_traits that may
benefit from the check. This also makes the behavior of libstdc++ more
consistent across different (non GCC) compilers.
* std::is_base_of does not have the assert as it works well in many
cases with incomplete types

2019-05-31  Antony Polukhin  <antoshkka@gmail.com>

	PR libstdc++/71579
	* include/std/type_traits __type_identity, __is_complete_or_unbounded):
	New helpers for checking preconditions in traits.
	(is_trivial, is_trivially_copyable, is_standard_layout, is_pod)
	(is_literal_type, is_empty, is_polymorphic, is_final, is_abstract)
	(is_destructible, is_nothrow_destructible, is_constructible)
	(is_default_constructible, is_copy_constructible)
	(is_move_constructible, is_nothrow_default_constructible)
	(is_nothrow_constructible, is_nothrow_copy_constructible)
	(is_nothrow_move_constructible, is_copy_assignable, is_move_assignable)
	(is_nothrow_assignable, is_nothrow_copy_assignable)
	(is_nothrow_move_assignable, is_trivially_constructible)
	(is_trivially_copy_constructible, is_trivially_move_constructible)
	is_trivially_assignable, is_trivially_copy_assignable)
	(is_trivially_move_assignable, is_trivially_destructible)
	(alignment_of, is_swappable, is_nothrow_swappable, is_invocable)
	(is_invocable_r, is_nothrow_invocable)
	(has_unique_object_representations, is_aggregate): Add static_asserts
	to make sure that type traits are not misused with incomplete types.
	(__is_constructible_impl, __is_nothrow_default_constructible_impl)
	(__is_nothrow_constructible_impl, __is_nothrow_assignable_impl): New
	base characteristics without assertions that can be reused in other
	traits.
	* testsuite/20_util/is_complete_or_unbounded/memoization.cc: New test.
	* testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc: New
	test.
	* testsuite/20_util/is_complete_or_unbounded/value.cc: New test.
	* testsuite/20_util/is_abstract/incomplete_neg.cc: New test.
	* testsuite/20_util/is_aggregate/incomplete_neg.cc: New test.
	* testsuite/20_util/is_class/value.cc: Check incomplete type.
	* testsuite/20_util/is_function/value.cc: Likewise.
	* testsuite/20_util/is_move_constructible/incomplete_neg.cc: New test.
	* testsuite/20_util/is_nothrow_move_assignable/incomplete_neg.cc: New
	test.
	* testsuite/20_util/is_polymorphic/incomplete_neg.cc: New test.
	* testsuite/20_util/is_reference/value.cc: Check incomplete types.
	* testsuite/20_util/is_unbounded_array/value.cc: Likewise.
	* testsuite/20_util/is_union/value.cc: Likewise.
	* testsuite/20_util/is_void/value.cc: Likewise.
	* testsuite/util/testsuite_tr1.h: Add incomplete union type.

From-SVN: r271806
2019-05-31 11:35:03 +01:00
Jonathan Wakely aeedf07705 Fix random_device to work with COW strings again
Instead of duplicating the initialization functions that take string,
add a new member taking a raw pointer that can be used to convert the
constructor token from the old string to the new.

Also fix "mt19337" typos in a testcase.

	* include/bits/random.h (random_device::_M_init(const char*, size_t)):
	Add new private member function.
	* src/c++11/cow-string-inst.cc (random_device::_M_init(const string&))
	(random_device::_M_init_pretr1(const string&)): Call new private
	member with string data.
	* src/c++11/random.cc (random_device::_M_init(const char*, size_t)):
	Define.
	* testsuite/26_numerics/random/random_device/cons/default-cow.cc: New
	test using COW strings.
	* testsuite/26_numerics/random/random_device/cons/default.cc: Generate
	a value from the device.
	* testsuite/26_numerics/random/random_device/cons/token.cc: Likewise.
	Fix typo in token string.

From-SVN: r271805
2019-05-31 11:34:53 +01:00
Nina Dinka Ranns 046af809f3 LWG2788 basic_string spurious use of a default constructible allocator
This only change the cxx11 basic_string, because COW strings don't
correctly propagate allocators anyway.

2019-05-30  Nina Dinka Ranns  <dinka.ranns@gmail.com>

	LWG2788 basic_string spurious use of a default constructible allocator
	* include/bits/basic_string.tcc [_GLIBCXX_USE_CXX11_ABI]
	(basic_string::_M_replace_dispatch): Construct temporary string with
	the current allocator.
	* testsuite/21_strings/basic_string/allocator/char/lwg2788.cc: New.
	* testsuite/21_strings/basic_string/allocator/wchar_t/lwg2788.cc: New.

From-SVN: r271789
2019-05-30 20:48:48 +01:00
Jonathan Wakely 01b3b9e39f Update libstdc++ documentation for Support and Diagnostics clauses
* doc/xml/manual/diagnostics.xml: Update list of headers that define
	exception classes.
	* doc/xml/manual/support.xml: Rewrite advice around NULL. Rewrite
	section about new/delete overloads. Improve section on verbose
	terminate handler.
	* doc/html/*: Regenerate.

From-SVN: r271782
2019-05-30 16:47:32 +01:00
Jonathan Wakely 62971f4644 Update C++20 status table
The status of P1353R0 was "Partial" because we don't define the
__cpp_lib_three_way_comparison macro, but that's because we don't
support the feature. So the paper can be marked as done.

	* doc/xml/manual/status_cxx2020.xml: Add feature-test macro for
	P0811R3. Change status of P1353R0.
	* doc/html/*: Regenerate.

From-SVN: r271774
2019-05-30 11:31:54 +01:00
Jonathan Wakely 37ad0fc942 Update documentation of implementation-defined library features
* doc/xml/manual/status_cxx2011.xml: Use <variablelist> for
	documentation of implementation-defined types for [thread.req.native].
	* doc/xml/manual/status_cxx2017.xml: Update documentation of
	implementation-defined strings for [variant.bad.access]. Fix typo in
	documentation of implementation-defined support for [fs.conform.9945].
	* doc/html/*: Regenerate.

From-SVN: r271773
2019-05-30 11:14:06 +01:00
Jonathan Wakely ea16f6acb0 PR libstdc++/85494 fix failing test
This test now fails on mingw-w64 because it's no longer always true that
the mt19937 engine is used when _GLIBCXX_USE_DEV_RANDOM is not defined.

Add tests for all the known tokens to ensure that at least one is
accepted.

	* testsuite/26_numerics/random/random_device/cons/token.cc: Fix test
	that fails on mingw-w64.

From-SVN: r271756
2019-05-29 23:00:57 +01:00
Jonathan Wakely 3cb929a32a PR libstdc++/88881 fix filesystem::symlink_status for Windows
The fix for PR 88881 only added a workaround to filesystem::status, but
filesystem::symlink_status is also affected by the _wstat bug and needs
the same workaround.

The recent change to optimize path::parent_path() means that the
workaround can be simplified to just use parent_path().

	PR libstdc++/88881
	* src/c++17/fs_ops.cc [_GLIBCXX_FILESYSTEM_IS_WINDOWS]
	(status(const path&, error_code&)): Use parent_path() to remove
	trailing slash.
	(symlink_status(const path&, error_code&)): Duplicate workaround for
	bug in _wstat for paths with trailing slash.
	* testsuite/27_io/filesystem/operations/remove_all.cc: Check path
	with trailing slash.
	* testsuite/27_io/filesystem/operations/status.cc: Likewise.
	* testsuite/27_io/filesystem/operations/symlink_status.cc: Likewise.

From-SVN: r271755
2019-05-29 23:00:53 +01:00
Jonathan Wakely e5ccb10ad0 Optimize filesystem::path::parent_path()
Parsing a complete string is more efficient than appending each
component one-by-one.

	* src/c++17/fs_path.cc (path::parent_path()): Create whole path at
	once instead of building it iteratively.

From-SVN: r271754
2019-05-29 23:00:45 +01:00
Jonathan Wakely 65539b1ef3 Avoid -Wunused-parameter warnings from testsuite utility
* testsuite/util/testsuite_api.h: Remove names of unused parameters.

From-SVN: r271741
2019-05-29 15:45:50 +01:00
Jonathan Wakely b0c0d878a8 PR libstdc++/85494 use rdseed and rand_s in std::random_device
Add support for additional sources of randomness to std::random_device,
to allow using RDSEED for Intel CPUs and rand_s for Windows. When
supported these can be selected using the tokens "rdseed" and "rand_s".
For *-w64-mingw32 targets the "default" token will now use rand_s, and
for other i?86-*-* and x86_64-*-* targets it will try to use "rdseed"
first, then "rdrand", and finally "/dev/urandom".

To simplify the declaration of std::random_device in <bits/random.h> the
constructors now unconditionally call _M_init instead of _M_init_pretr1,
and the function call operator now unconditionally calls _M_getval. The
library code now decides whether _M_init and _M_getval should use a real
source of randomness or the mt19937 engine.

Existing code compiled against old libstdc++ headers will still call
_M_init_pretr1 and _M_getval_pretr1, but those functions now forward to
_M_init and _M_getval if a real source of randomness is available. This
means existing code compiled for mingw-w64 will start to use rand_s just
by linking to a new libstdc++.dll.

	* acinclude.m4 (GLIBCXX_CHECK_X86_RDSEED): Define macro to check if
	the assembler supports rdseed.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Use GLIBCXX_CHECK_X86_RDSEED.
	* config/os/mingw32-w64/os_defines.h (_GLIBCXX_USE_CRT_RAND_S): Define.
	* doc/html/*: Regenerate.
	* doc/xml/manual/status_cxx2011.xml: Document new tokens.
	* include/bits/random.h (random_device::random_device()): Always call
	_M_init rather than _M_init_pretr1.
	(random_device::random_device(const string&)): Likewise.
	(random_device::operator()()): Always call _M_getval().
	(random_device::_M_file): Replace first member of union with an
	anonymous struct, with _M_file as its first member.
	* src/c++11/random.cc [_GLIBCXX_X86_RDRAND] (USE_RDRAND): Define.
	[_GLIBCXX_X86_RDSEED] (USE_RDSEED): Define.
	(USE_MT19937): Define if none of the above are defined.
	(USE_POSIX_FILE_IO): Define.
	(_M_strtoul): Remove.
	[USE_RDSEED] (__x86_rdseed): Define new function.
	[_GLIBCXX_USE_CRT_RAND_S] (__winxp_rand_s): Define new function.
	(random_device::_M_init(const string&)): Initialize new union members.
	Add support for "rdseed" and "rand_s" tokens. Decide what the
	"default" token does according to which USE_* macros are defined.
	[USE_POSIX_FILE_IO]: Store a file descriptor.
	[USE_MT19937]: Forward to _M_init_pretr1 instead.
	(random_device::_M_init_pretr1(const string&)) [USE_MT19937]: Inline
	code from _M_strtoul.
	[!USE_MT19937]: Call _M_init, transforming the old default token or
	numeric tokens to "default".
	(random_device::_M_fini()) [USE_POSIX_FILE_IO]: Use close not fclose.
	(random_device::_M_getval()): Use new union members to obtain a
	random number from the stored function pointer or file descriptor.
	[USE_MT19937]: Obtain a value from the mt19937 engine.
	(random_device::_M_getval_pretr1()): Call _M_getval().
	(random_device::_M_getentropy()) [USE_POSIX_FILE_IO]: Use _M_fd
	instead of fileno.
	[!USE_MT19937] (mersenne_twister): Do not instantiate when not needed.
	* testsuite/26_numerics/random/random_device/85494.cc: New test.

From-SVN: r271740
2019-05-29 15:45:35 +01:00
Jonathan Wakely 441ed45ca2 PR libstdc++/90634 reduce allocations in filesystem::path construction
PR libstdc++/90634
	* include/experimental/bits/fs_path.h (path::path(path&&)): Only call
	_M_split_cmpts() for a path with multiple components.
	(path::_S_is_dir_sep()): Add missing 'static' keyword to function.
	* src/filesystem/path.cc (path::_M_split_cmpts()): Count number of
	components and reserve space in vector. Return early when there is
	only one component.
	* testsuite/27_io/filesystem/path/construct/90634.cc: New test.
	* testsuite/experimental/filesystem/path/construct/90634.cc: New test.

From-SVN: r271717
2019-05-28 20:39:48 +01:00
Jonathan Wakely d9b401df8f Fix C++14-only code in testsuite utility
* testsuite/util/testsuite_fs.h (compare_paths): Use three-argument
	form of std::equals for C++11 compatibility.

From-SVN: r271716
2019-05-28 20:39:41 +01:00
Gerald Pfeifer 558f3941e9 appendix_contributing.xml: Update pointer to C++ standard at ansi.org.
* doc/xml/manual/appendix_contributing.xml: Update pointer to
	C++ standard at ansi.org.

From-SVN: r271635
2019-05-26 19:46:09 +00:00
Jonathan Wakely 09b4000c7c Fix std::midpoint(T*, T*) for reversed arguments
* include/std/numeric (midpoint(T*, T*)): Fix incorrect result.
	* testsuite/26_numerics/midpoint/pointer.cc: Change "compile" test
	to "run".

From-SVN: r271606
2019-05-24 16:39:35 +01:00
Jonathan Wakely 2fb1b29d37 Fix broken shared_ptr test
* testsuite/20_util/shared_ptr/cons/alias-rval.cc: Fix test.
	* testsuite/20_util/shared_ptr/cons/alias.cc: Remove unused function.

From-SVN: r271603
2019-05-24 14:00:26 +01:00
Jonathan Wakely 5f303216e5 Fix testsuite bugs
One of the static assertions in 20_util/function_objects/invoke/1.cc was
wrong, but didn't fail because by default it was compiled with
-std=gnu++14 which didn't use that static assertion. Split out the C++17
parts to a new file that always runs with -std=gnu++17, so those checks
are always done.

The 23_containers/unordered_set/allocator/ext_ptr.cc test is supposed to
be a run-time test but was unintentionally compile-only.

	* testsuite/20_util/function_objects/invoke/1.cc: Move C++17-specific
	tests to ...
	* testsuite/20_util/function_objects/invoke/3.cc: New test.
	* testsuite/23_containers/unordered_set/allocator/ext_ptr.cc: Change
	"compile" test to "run".

From-SVN: r271584
2019-05-23 22:41:08 +01:00
Jonathan Wakely fb3fc4bded LWG 2996 add rvalue overloads for shared_ptr aliasing and casting
* doc/xml/manual/intro.xml: Document LWG DR 2996 change.
	* doc/html/*: Regenerate.
	* include/bits/shared_ptr.h (shared_ptr(shared_ptr&&, T*)): Add
	rvalue aliasing constructor.
	(static_pointer_cast, const_pointer, dynamic_pointer_cast)
	(reinterpret_pointer_cast): Add overloads taking rvalues.
	* include/bits/shared_ptr_base.h (__shared_ptr(__shared_ptr&&, T*)):
	Add rvalue aliasing constructor.
	* testsuite/20_util/shared_ptr/casts/1.cc: Change "compile" test to
	"run" and check return values as well as types.
	* testsuite/20_util/shared_ptr/casts/reinterpret.cc: Likewise.
	* testsuite/20_util/shared_ptr/casts/rval.cc: New test.
	* testsuite/20_util/shared_ptr/cons/alias-rval.cc: New test.
	* testsuite/20_util/shared_ptr/cons/alias.cc: Remove unused return
	values.

From-SVN: r271583
2019-05-23 22:41:02 +01:00
Jonathan Wakely 9a0af7e3fb LWG 2921 remove packaged_task constructors taking allocators
* doc/xml/manual/evolution.xml: Document LWG DR 2921 change.
	* doc/xml/manual/intro.xml: Likewise.
	* include/std/future (__create_task_state): Add default arguments
	to make providing an allocator optional.
	(packaged_task::packaged_task(F&&)): Call __create_task_state directly
	instead of delegating to another constructor.
	(packaged_task::packaged_task(allocator_arg_t, const A&, ...)): Do not
	define allocator-extended constructors for C++17 and later.
	* testsuite/30_threads/packaged_task/cons/alloc.cc: Only run test for
	C++11 and C++14.
	* testsuite/30_threads/packaged_task/cons/alloc2.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/alloc_min.cc: Likewise.
	* testsuite/30_threads/packaged_task/uses_allocator.cc: Likewise.

From-SVN: r271582
2019-05-23 22:40:56 +01:00
Hans-Peter Nilsson 0ce91914ad From what I understand of the libstdc++/83237 thread at
<https://gcc.gnu.org/ml/gcc-patches/2017-12/msg00573.html>, the
high numbers are not arbitrary, so it seems wrong to try
lowering them, or we'd just waste cycles testing nothing, or
worse, ending up with a bogus error indication.  Better to just
plain disable this part of the test for simulator targets; I
assume the results should be the same on any IEEE-float target,
i.e. no target-specific things going on here that'd raise a need
to cover it everywhere.

With this part of the test disabled, I saw the test finishing in
(time) "124.74s user" where it was before "1120.26s user"
running the cris-elf-run simulator on a "i7-4770K CPU @ 3.50GHz"
host.  Most certainly that indidates that the remainder of the
test is still too much for *some* host+simulator combos, but I'm
happy with the runtime lowered to 1/5 of the timeout (10
minutes) on this particular combination, and I'd think this
fixes timeouts for many other simulator combos too.

This construct (disabling or lowering limits for simulators) is
used elsewhere in the libstdc++ test-suite and in particular the
SIMULATOR_TEST macro is used in the testsuite machinery (though
AFAICT not in testDiscreteDist).

        * testsuite/26_numerics/random/poisson_distribution/operators/values.cc:
        Don't run the libstdc++/83237 part on simulator targets.

From-SVN: r271574
2019-05-23 18:02:05 +00:00
Jonathan Wakely 1a4f7c1b05 Add missing feature test macro to C++17 status table
* doc/xml/manual/status_cxx2017.xml: Add feature test macro for
	P0040R3.
	* doc/html/*: Regenerate.

From-SVN: r271571
2019-05-23 17:01:18 +01:00
Jonathan Wakely aa573a6a3e Make any_cast compare typeinfo as well as function pointers
It's possible for the function pointer comparison to fail even though
the type is correct, because the function could be defined multiple
times with different addresses when shared libraries are in use.

Retain the function pointer check for the common case where the check
succeeds, but compare typeinfo (if RTTI is enabled) if the first check
fails.

	* include/experimental/any (__any_caster): Use RTTI if comparing
	addresses fails, to support non-unique addresses in shared libraries.
	* include/std/any (__any_caster): Likewise.

From-SVN: r271557
2019-05-23 15:13:18 +01:00
Jonathan Wakely 7dbab5dc84 PR libstdc++/90220 fix experimental::any_cast for non-object types
This corresponds to the fixes done for std::any_cast, but has to be done
without if-constexpr. The dummy specialization of _Manager_internal<_Op>
is used to avoid instantiating the real _Manager_internal<T>::_S_manage
function just to compare its address.

	PR libstdc++/90220
	* include/experimental/any (__any_caster): Constrain to only be
	callable for object types. Use remove_cv_t instead of decay_t.
	If the type decays or isn't copy constructible, compare the manager
	function to a dummy specialization.
	(__any_caster): Add overload constrained for non-object types.
	(any::_Manager_internal<_Op>): Add dummy specialization.
	* testsuite/experimental/any/misc/any_cast.cc: Test function types
	and array types.

From-SVN: r271556
2019-05-23 14:39:06 +01:00
Jonathan Wakely f9b22a0c24 PR libstdc++/90557 fix path assignment that alters source
PR libstdc++/90557
	* src/c++17/fs_path.cc (path::_List::operator=(const _List&)): Fix
	reversed arguments to uninitialized_copy_n.
	* testsuite/27_io/filesystem/path/assign/copy.cc: Check that source
	is unchanged by copy assignment.
	* testsuite/util/testsuite_fs.h (compare_paths): Use std::equal to
	compare path components.

From-SVN: r271527
2019-05-22 23:14:34 +01:00
Jonathan Wakely 52ea1caf28 PR libstdc++/77691 fix resource_adaptor failures due to max_align_t bugs
Remove the hardcoded whitelist of allocators expected to return memory
aligned to alignof(max_align_t), because that doesn't work when the
platform's malloc() and GCC's max_align_t do not agree what the largest
fundamental alignment is. It's also sub-optimal for user-defined
allocators that return memory suitable for any fundamental alignment.

Instead use a hardcoded list of alignments that are definitely supported
by the platform malloc, and use a copy of the allocator rebound to a POD
type with the requested alignment. Only allocate an oversized
buffer to use with std::align for alignments larger than any of the
hardcoded values.

For 32-bit Solaris x86 do not include alignof(max_align_t) in the
hardcoded values.

	PR libstdc++/77691
	* include/experimental/memory_resource: Add system header pragma.
	(__resource_adaptor_common::__guaranteed_alignment): Remove.
	(__resource_adaptor_common::_Types)
	(__resource_adaptor_common::__new_list)
	(__resource_adaptor_common::_New_list)
	(__resource_adaptor_common::_Alignments)
	(__resource_adaptor_common::_Fund_align_types): New utilities for
	creating a list of types with fundamental alignments.
	(__resource_adaptor_imp::do_allocate): Call new _M_allocate function.
	(__resource_adaptor_imp::do_deallocate): Call new _M_deallocate
	function.
	(__resource_adaptor_imp::_M_allocate): New function that first tries
	to use an allocator rebound to a type with a fundamental alignment.
	(__resource_adaptor_imp::_M_deallocate): Likewise for deallocation.
	* testsuite/experimental/memory_resource/new_delete_resource.cc:
	Adjust expected allocation sizes.
	* testsuite/experimental/memory_resource/resource_adaptor.cc: Remove
	xfail.

From-SVN: r271522
2019-05-22 21:29:39 +01:00
Thomas Rodgers 34d878c7bc LWG 3062 - Unnecessary decay_t in is_execution_policy_v
* include/pstl/execution_defs.h (__enable_if_execution_policy):
    Use std::__remove_cvref_t when building with GCC.

From-SVN: r271489
2019-05-21 22:15:00 +00:00
Jonathan Wakely f445f0f06c PR libstdc++/90252 fix effective-target check for TBB
PR libstdc++/90252
	* testsuite/lib/libstdc++.exp (check_effective_target_tbb-backend):
	Use "additional_flags" to pass -ltbb to v3_target_compile command.
	Use check_v3_target_prop_cached to cache the result of the test.

From-SVN: r271466
2019-05-21 14:50:41 +01:00
Jonathan Wakely 049f115abb Fix names of _Lock_policy constants in libstdc++ manual
* doc/xml/manual/shared_ptr.xml: Fix names of lock policy constants.

From-SVN: r271465
2019-05-21 14:50:35 +01:00
Thomas Rodgers 838373111f tbb-backend effective target should check ability to link TBB
PR libstdc++/90252
	    * testsuite/lib/libstdc++.exp (check_effective_target_tbb-backend):
	    Changed v3_target_compile check from preprocess to executable.
	    Added "-ltbb" to v3_target_compile flags.

From-SVN: r271451
2019-05-21 04:37:45 +00:00
Thomas Rodgers d748c543b6 Check TBB version in tbb-backed effective target check
* testsuite/lib/libstdc++.exp (check_effective_target_tbb-backend):
      Add check for Thread Building Blocks 2018 or later.

From-SVN: r271450
2019-05-21 01:06:32 +00:00
Jonathan Wakely 4c7399e992 Fix test failure due to Networking TS headers using mutexes
Only include the Networking headers for targets with Gthreads, so that
the uses of std::mutex and std::condition_variable don't cause errors.

	* testsuite/experimental/names.cc: Only include Networking TS headers
	on targets with the necessary Gthreads support.

From-SVN: r271437
2019-05-20 21:21:15 +01:00
Marek Polacek be9e458d8b CWG 2094 - volatile scalars are trivially copyable.
PR c++/85679
	* tree.c (trivially_copyable_p): Don't check CP_TYPE_VOLATILE_P for
	scalar types.

	* g++.dg/ext/is_trivially_constructible1.C: Change the expected result
	for volatile int.
	* g++.dg/ext/is_trivially_copyable.C: New test.

	* testsuite/20_util/is_trivially_copyable/value.cc: Change the expected
	result for volatile int.

From-SVN: r271435
2019-05-20 19:10:57 +00:00
Jonathan Wakely 7f67becc98 Fix failing tests for use of non-reserved names
Defining 'ptr' fails on Solaris because it's used in <netdb.h>.

Including the Filesystem TS header fails if the TS support wasn't
enabled by configure.

	* testsuite/17_intro/names.cc: Do not check 'ptr' on Solaris.
	* testsuite/experimental/names.cc: Include <experimental/filesystem>
	conditionally.

From-SVN: r271421
2019-05-20 15:38:21 +01:00
Jonathan Wakely 58487c21b6 PR c++/90532 Ensure __is_constructible(T[]) is false
An array of an unknown bound is an incomplete type, so no object of such
a type can be constructed. This means __is_constructible should always
be false for an array of unknown bound.

This patch also changes the std::is_default_constructible trait to use
std::is_constructible, which now gives the right answer for arrays of
unknown bound.

gcc/cp:

	PR c++/90532 Ensure __is_constructible(T[]) is false
	* method.c (is_xible_helper): Return error_mark_node for construction
	of an array of unknown bound.

gcc/testsuite:

	PR c++/90532 Ensure __is_constructible(T[]) is false
	* g++.dg/ext/90532.C: New test.

libstdc++-v3:

	PR c++/90532 Ensure __is_constructible(T[]) is false
	* include/std/type_traits (__do_is_default_constructible_impl)
	(__is_default_constructible_atom, __is_default_constructible_safe):
	Remove.
	(is_default_constructible): Use is_constructible.
	* testsuite/20_util/is_constructible/value.cc: Check int[] case.
	* testsuite/20_util/is_default_constructible/value.cc: Likewise.
	* testsuite/20_util/is_trivially_constructible/value.cc: Likewise.
	* testsuite/20_util/is_trivially_default_constructible/value.cc:
	Likewise.

From-SVN: r271412
2019-05-20 12:32:51 +01:00
Pádraig Brady e5178b986a std::allocator::deallocate support sized-deallocation
Pass the size to the allocator so that it may optimize deallocation.
This was seen to significantly reduce the work required in jemalloc,
with about 40% reduction in CPU cycles in the free path.

Note jemalloc >= 5.2 is required to fix a crash with 0 sizes.

2019-05-20  Pádraig Brady  <pbrady@fb.com>

	* libstdc++-v3/include/ext/new_allocator.h (deallocate): Pass the size
	to the deallocator with -fsized-deallocation.

From-SVN: r271409
2019-05-20 12:15:03 +01:00
Jonathan Wakely eb530cab9a Fix test bug with mismatched alignment in allocate/deallocate
* testsuite/experimental/memory_resource/new_delete_resource.cc: Fix
	test by passing correct alignment to deallocate function.

From-SVN: r271408
2019-05-20 12:14:56 +01:00
Jonathan Wakely 1a0a374429 PR libstdc++/90520 adjust Xmethod for recent unique_ptr changes
PR libstdc++/90520
	* python/libstdcxx/v6/printers.py (UniquePointerPrinter.__init__):
	Raise exception if unique_ptr tuple member has unknown structure.
	* python/libstdcxx/v6/xmethods.py (UniquePtrGetWorker.__call__):
	Adjust worker to support new __uniq_ptr_data base class. Do not
	assume field called _M_head_impl is the first tuple element.

From-SVN: r271363
2019-05-18 00:08:00 +01:00
Martin Sebor a9c697b883 trans.c (check_inlining_for_nested_subprog): Quote reserved names.
gcc/ada/ChangeLog:

        * gcc-interface/trans.c (check_inlining_for_nested_subprog): Quote
        reserved names.

gcc/brig/ChangeLog:

        * brigfrontend/brig-control-handler.cc
        (brig_directive_control_handler::operator): Remove trailing newline
        from a diagnostic.
        * brigfrontend/brig-module-handler.cc
        (brig_directive_module_handler::operator): Remove a duplicated space
        from a diagnostic.

gcc/c/ChangeLog:

        * c-decl.c (start_decl): Quote keywords, operators, and
        types in diagnostics.
        (finish_decl): Same.
        * c-parser.c (c_parser_asm_statement): Same.
        (c_parser_conditional_expression): Same.
        (c_parser_transaction_cancel): Same.
        * c-typeck.c (c_common_type): Same.
        (build_conditional_expr): Same.
        (digest_init): Same.
        (process_init_element): Same.
        (build_binary_op): Same.

gcc/c-family/ChangeLog:

        * c-attribs.c (handle_no_sanitize_attribute): Quote identifiers,
        keywords, operators, and types in diagnostics.
        (handle_scalar_storage_order_attribute): Same.
        (handle_mode_attribute): Same.
        (handle_visibility_attribute): Same.
        (handle_assume_aligned_attribute): Same.
        (handle_no_split_stack_attribute): Same.
        * c-common.c (shorten_compare): Same.
        (c_common_truthvalue_conversion): Same.
        (cb_get_source_date_epoch): Same.
        * c-lex.c (cb_def_pragma): Quote keywords, operators, and types
        in diagnostics.
        (interpret_float): Same.
        * c-omp.c (c_finish_omp_for): Same.
        * c-opts.c (c_common_post_options): Same.
        * c-pch.c (c_common_pch_pragma): Same.
        * c-pragma.c (pop_alignment): Same.
        (handle_pragma_pack): Same.
        (apply_pragma_weak): Same.
        (handle_pragma_weak): Same.
        (handle_pragma_scalar_storage_order): Same.
        (handle_pragma_redefine_extname): Same.
        (add_to_renaming_pragma_list): Same.
        (maybe_apply_renaming_pragma): Same.
        (push_visibility): Same.
        (handle_pragma_visibility): Same.
        (handle_pragma_optimize): Same.
        (handle_pragma_message): Same.
        * c-warn.c (warn_for_omitted_condop): Same.
        (lvalue_error): Same.

gcc/cp/ChangeLog:

        * call.c (print_z_candidate): Wrap diagnostic text in a gettext
        macro.  Adjust.
        (print_z_candidates): Same.
        (build_conditional_expr_1): Quote keywords, operators, and types
        in diagnostics.
        (build_op_delete_call): Same.
        (maybe_print_user_conv_context): Wrap diagnostic text in a gettext
        macro.
        (convert_like_real): Same.
        (convert_arg_to_ellipsis): Quote keywords, operators, and types
        in diagnostics.
        (build_over_call): Same.
        (joust): Break up an overlong line.  Wrap diagnostic text in a gettext
        macro.
        * constexpr.c (cxx_eval_check_shift_p): Spell out >= in English.
        (cxx_eval_constant_expression): Quote keywords, operators, and types
        in diagnostics.
        (potential_constant_expression_1): Same.
        * cp-gimplify.c (cp_genericize_r): Same.
        * cvt.c (maybe_warn_nodiscard): Quote keywords, operators, and types
        in diagnostics.
        (type_promotes_to): Same.
        * decl.c (check_previous_goto_1): Same.
        (check_goto): Same.
        (start_decl): Same.
        (cp_finish_decl): Avoid parenthesizing a sentence for consistency.
        (grok_op_properties): Quote keywords, operators, and types
        in diagnostics.
        * decl2.c (grokfield): Same.
        (coerce_delete_type): Same.
        * except.c (is_admissible_throw_operand_or_catch_parameter): Same.
        * friend.c (do_friend): Quote C++ tokens.
        * init.c (build_new_1): Quote keywords, operators, and types
        in diagnostics.
        (build_vec_delete_1): Same.
        (build_delete): Same.
        * lex.c (parse_strconst_pragma): Same.
        (handle_pragma_implementation): Same.
        (unqualified_fn_lookup_error): Same.
        * mangle.c (write_type): Same.
        * method.c (defaulted_late_check): Avoid two consecutive punctuators.
        * name-lookup.c (cp_binding_level_debug): Remove a trailing newline.
        (pop_everything): Same.
        * parser.c (cp_lexer_start_debugging): Quote a macro name.
        in a diagnostic
        (cp_lexer_stop_debugging): Same.
        (cp_parser_userdef_numeric_literal): Quote a C++ header name
        in a diagnostic.
        (cp_parser_nested_name_specifier_opt): Quote keywords, operators,
        and types in diagnostics.
        (cp_parser_question_colon_clause): Same.
        (cp_parser_asm_definition): Same.
        (cp_parser_init_declarator): Same.
        (cp_parser_template_declaration_after_parameters): Avoid capitalizing
        a sentence in a diagnostic.
        (cp_parser_omp_declare_reduction): Quote keywords, operators, and types
        in diagnostics.
        (cp_parser_transaction): Same.
        * pt.c (maybe_process_partial_specialization): Replace second call
        to permerror with inform for consistency with other uses.
        (expand_integer_pack): Quote keywords, operators, and types
        in diagnostics.
        * rtti.c (get_typeid): Quote keywords, operators, and types
        in diagnostics.
        (build_dynamic_cast_1): Same.
        * semantics.c (finish_asm_stmt): Same.
        (finish_label_decl): Same.
        (finish_bases): Same.
        (finish_offsetof): Same.
        (cp_check_omp_declare_reduction): Same.
        (finish_decltype_type): Same.
        * tree.c (handle_init_priority_attribute): Same.  Add detail
        to diagnostics.
        (maybe_warn_zero_as_null_pointer_constant): Same.
        * typeck.c (cp_build_binary_op): Quote keywords, operators, and types
        in diagnostics.
        (cp_build_unary_op): Same.
        (check_for_casting_away_constness): Same.
        (build_static_cast): Same.
        (build_const_cast_1): Same.
        (maybe_warn_about_returning_address_of_local): Same.
        (check_return_expr): Same.
        * typeck2.c (abstract_virtuals_error_sfinae): Same.
        (digest_init_r): Replace a tab with spaces in a diagnostic.
        (build_functional_cast): Quote keywords, operators, and types
        in diagnostics.

gcc/d/ChangeLog:

        * d-builtins.cc (d_init_builtins): Quote keywords, operators,
        and types in diagnostics.
        * d-codegen.cc (get_array_length): Same.  Replace can't with cannot.
        * d-convert.cc (convert_expr): Same.
        * d-frontend.cc (getTypeInfoType): Quote an option name in
        a diagnostic.
        * d-lang.cc (d_handle_option): Same.
        (d_parse_file): Same.
        * decl.cc: Remove a trailing period from a diagnostic.
        * expr.cc: Use a directive for an apostrophe.
        * toir.cc: Quote keywords, operators, and types in diagnostics.
        * typeinfo.cc (build_typeinfo): Quote an option name in a diagnostic.

gcc/fortran/ChangeLog:

	* gfortranspec.c (append_arg): Spell out the word "argument."

gcc/ChangeLog:

        * config/i386/i386-expand.c (get_element_number): Quote keywords
        and other internal names in diagnostics.  Adjust other diagnostic
        formatting issues noted by -Wformat-diag.
        * config/i386/i386-features.c
        (ix86_mangle_function_version_assembler_name): Same.
        * config/i386/i386-options.c (ix86_handle_abi_attribute): Same.
        * config/i386/i386.c (ix86_function_type_abi): Same.
        (ix86_function_ms_hook_prologue): Same.
        (classify_argument): Same.
        (ix86_expand_prologue): Same.
        (ix86_md_asm_adjust): Same.
        (ix86_memmodel_check): Same.

gcc/ChangeLog:

        * builtins.c (expand_builtin_atomic_always_lock_free): Quote
        identifiers, keywords, operators, and types in diagnostics.  Correct
        quoting, spelling, and sentence capitalization issues.
        (expand_builtin_atomic_is_lock_free): Same.
        (fold_builtin_next_arg): Same.
        * cfgexpand.c (expand_one_var): Same.
        (tree_conflicts_with_clobbers_p): Same.
        (expand_asm_stmt): Same.
        (verify_loop_structure): Same.
        * cgraphunit.c (process_function_and_variable_attributes): Same.
        * collect-utils.c (collect_execute): Same.
        * collect2.c (maybe_run_lto_and_relink): Same.
        (is_lto_object_file): Same.
        (scan_prog_file): Same.
        * convert.c (convert_to_real_1): Same.
        * dwarf2out.c (dwarf2out_begin_prologue): Same.
        * except.c (verify_eh_tree): Same.
        * gcc.c (execute): Same.
        (eval_spec_function): Same.
        (run_attempt): Same.
        (driver::set_up_specs): Same.
        (compare_debug_auxbase_opt_spec_function): Same.
        * gcov-tool.c (unlink_gcda_file): Same.
        (do_merge): Same.
        (do_rewrite): Same.
        * gcse.c (gcse_or_cprop_is_too_expensive): Same.
        * gimplify.c (gimplify_asm_expr): Same.
        (gimplify_adjust_omp_clauses): Same.
        * hsa-gen.c (gen_hsa_addr_insns): Same.
        (gen_hsa_insns_for_load): Same.
        (gen_hsa_cmp_insn_from_gimple): Same.
        (gen_hsa_insns_for_operation_assignment): Same.
        (gen_get_level): Same.
        (gen_hsa_alloca): Same.
        (omp_simple_builtin::generate): Same.
        (gen_hsa_atomic_for_builtin): Same.
        (gen_hsa_insns_for_call): Same.
        * input.c (dump_location_info): Same.
        * ipa-devirt.c (compare_virtual_tables): Same.
        * ira.c (ira_setup_eliminable_regset): Same.
        * lra-assigns.c (lra_assign): Same.
        * lra-constraints.c (lra_constraints): Same.
        * lto-streamer-in.c (lto_input_mode_table): Same.
        * lto-wrapper.c (get_options_from_collect_gcc_options): Same.
        (merge_and_complain): Same.
        (compile_offload_image): Same.
        (compile_images_for_offload_targets): Same.
        (debug_objcopy): Same.
        (run_gcc): Same.
        (main): Same.
        * opts.c (print_specific_help): Same.
        (parse_no_sanitize_attribute): Same.
        (print_help): Same.
        (handle_param): Same.
        * plugin.c (add_new_plugin): Same.
        (parse_plugin_arg_opt): Same.
        (try_init_one_plugin): Same.
        * print-rtl.c (debug_bb_n_slim): Quote identifiers, keywords,
        operators, and types in diagnostics.  Correct quoting and spelling
        issues.
        * read-rtl-function.c (parse_edge_flag_token): Same.
        (function_reader::parse_enum_value): Same.
        * reg-stack.c (check_asm_stack_operands): Same.
        * regcprop.c (validate_value_data): Same.
        * sched-rgn.c (make_pass_sched_fusion): Same.
        * stmt.c (check_unique_operand_names): Same.
        * targhooks.c (default_target_option_pragma_parse): Same.
        * tlink.c (recompile_files): Same.
        * toplev.c (process_options): Same.
        (do_compile): Same.
        * trans-mem.c (diagnose_tm_1): Same.
        (ipa_tm_scan_irr_block): Same.
        (ipa_tm_diagnose_transaction): Same.
        * tree-cfg.c (verify_address): Same.  Use get_tree_code_name to
        format a tree code name in a diagnostic.
        (verify_types_in_gimple_min_lval): Same.
        (verify_types_in_gimple_reference): Same.
        (verify_gimple_call): Same.
        (verify_gimple_assign_unary): Same.
        (verify_gimple_assign_binary): Same.
        (verify_gimple_assign_ternary): Same.
        (verify_gimple_assign_single): Same.
        (verify_gimple_switch): Same.
        (verify_gimple_label): Same.
        (verify_gimple_phi): Same.
        (verify_gimple_in_seq): Same.
        (verify_eh_throw_stmt_node): Same.
        (collect_subblocks): Same.
        (gimple_verify_flow_info): Same.
        (do_warn_unused_result): Same.
        * tree-inline.c (expand_call_inline): Same.
        * tree-into-ssa.c (update_ssa): Same.
        * tree.c (tree_int_cst_elt_check_failed): Same.
        (tree_vec_elt_check_failed): Same.
        (omp_clause_operand_check_failed): Same.
        (verify_type_variant): Same.
        (verify_type): Same.
        * value-prof.c (verify_histograms): Same.
        * varasm.c (assemble_start_function): Same.

gcc/lto/ChangeLog:

        * lto-dump.c (lto_main): Same.
        * lto.c (stream_out): Same.

gcc/objc/ChangeLog:

        * objc-act.c (objc_begin_catch_clause): Quote keywords and options
        in diagnostics.
        (objc_build_throw_stmt): Same.
        (objc_finish_message_expr): Same.
        (get_super_receiver): Same.
        * objc-next-runtime-abi-01.c (objc_next_runtime_abi_01_init): Spell
        out "less than" in English./
        * objc-next-runtime-abi-02.c (objc_next_runtime_abi_02_init): Spell
        out "greater" in English.

gcc/testsuite/ChangeLog:

        * c-c++-common/Wbool-operation-1.c: Adjust text of expected diagnostics.
        * c-c++-common/Wvarargs-2.c: Same.
        * c-c++-common/Wvarargs.c: Same.
        * c-c++-common/pr51768.c: Same.
        * c-c++-common/tm/inline-asm.c: Same.
        * c-c++-common/tm/safe-1.c: Same.
        * g++.dg/asm-qual-1.C: Same.
        * g++.dg/asm-qual-3.C: Same.
        * g++.dg/conversion/dynamic1.C: Same.
        * g++.dg/cpp0x/constexpr-89599.C: Same.
        * g++.dg/cpp0x/constexpr-cast.C: Same.
        * g++.dg/cpp0x/constexpr-shift1.C: Same.
        * g++.dg/cpp0x/lambda/lambda-conv11.C: Same.
        * g++.dg/cpp0x/nullptr04.C: Same.
        * g++.dg/cpp0x/static_assert12.C: Same.
        * g++.dg/cpp0x/static_assert8.C: Same.
        * g++.dg/cpp1y/lambda-conv1.C: Same.
        * g++.dg/cpp1y/pr79393-3.C: Same.
        * g++.dg/cpp1y/static_assert1.C: Same.
        * g++.dg/cpp1z/constexpr-if4.C: Same.
        * g++.dg/cpp1z/constexpr-if5.C: Same.
        * g++.dg/cpp1z/constexpr-if9.C: Same.
        * g++.dg/eh/goto2.C: Same.
        * g++.dg/eh/goto3.C: Same.
        * g++.dg/expr/static_cast8.C: Same.
        * g++.dg/ext/flexary5.C: Same.
        * g++.dg/ext/utf-array-short-wchar.C: Same.
        * g++.dg/ext/utf-array.C: Same.
        * g++.dg/ext/utf8-2.C: Same.
        * g++.dg/gomp/loop-4.C: Same.
        * g++.dg/gomp/macro-4.C: Same.
        * g++.dg/gomp/udr-1.C: Same.
        * g++.dg/init/initializer-string-too-long.C: Same.
        * g++.dg/other/offsetof9.C: Same.
        * g++.dg/ubsan/pr63956.C: Same.
        * g++.dg/warn/Wbool-operation-1.C: Same.
        * g++.dg/warn/Wtype-limits-Wextra.C: Same.
        * g++.dg/warn/Wtype-limits.C: Same.
        * g++.dg/wrappers/pr88680.C: Same.
        * g++.old-deja/g++.mike/eh55.C: Same.
        * gcc.dg/Wsign-compare-1.c: Same.
        * gcc.dg/Wtype-limits-Wextra.c: Same.
        * gcc.dg/Wtype-limits.c: Same.
        * gcc.dg/Wunknownprag.c: Same.
        * gcc.dg/Wunsuffixed-float-constants-1.c: Same.
        * gcc.dg/asm-6.c: Same.
        * gcc.dg/asm-qual-1.c: Same.
        * gcc.dg/cast-1.c: Same.
        * gcc.dg/cast-2.c: Same.
        * gcc.dg/cast-3.c: Same.
        * gcc.dg/cpp/source_date_epoch-2.c: Same.
        * gcc.dg/debug/pr85252.c: Same.
        * gcc.dg/dfp/cast-bad.c: Same.
        * gcc.dg/format/gcc_diag-1.c: Same.
        * gcc.dg/format/gcc_diag-11.c: Same.New test.
        * gcc.dg/gcc_diag-11.c: Same.New test.
        * gcc.dg/gnu-cond-expr-2.c: Same.
        * gcc.dg/gnu-cond-expr-3.c: Same.
        * gcc.dg/gomp/macro-4.c: Same.
        * gcc.dg/init-bad-1.c: Same.
        * gcc.dg/init-bad-2.c: Same.
        * gcc.dg/init-bad-3.c: Same.
        * gcc.dg/pr27528.c: Same.
        * gcc.dg/pr48552-1.c: Same.
        * gcc.dg/pr48552-2.c: Same.
        * gcc.dg/pr59846.c: Same.
        * gcc.dg/pr61096-1.c: Same.
        * gcc.dg/pr8788-1.c: Same.
        * gcc.dg/pr90082.c: Same.
        * gcc.dg/simd-2.c: Same.
        * gcc.dg/spellcheck-params-2.c: Same.
        * gcc.dg/spellcheck-params.c: Same.
        * gcc.dg/strlenopt-49.c: Same.
        * gcc.dg/tm/pr52141.c: Same.
        * gcc.dg/torture/pr51106-1.c: Same.
        * gcc.dg/torture/pr51106-2.c: Same.
        * gcc.dg/utf-array-short-wchar.c: Same.
        * gcc.dg/utf-array.c: Same.
        * gcc.dg/utf8-2.c: Same.
        * gcc.dg/warn-sprintf-no-nul.c: Same.
        * gcc.target/i386/asm-flag-0.c: Same.
        * gcc.target/i386/inline_error.c: Same.
        * gcc.target/i386/pr30848.c: Same.
        * gcc.target/i386/pr39082-1.c: Same.
        * gcc.target/i386/pr39678.c: Same.
        * gcc.target/i386/pr57756.c: Same.
        * gcc.target/i386/pr68843-1.c: Same.
        * gcc.target/i386/pr79804.c: Same.
        * gcc.target/i386/pr82673.c: Same.
        * obj-c++.dg/class-protocol-1.mm: Same.
        * obj-c++.dg/exceptions-3.mm: Same.
        * obj-c++.dg/exceptions-4.mm: Same.
        * obj-c++.dg/exceptions-5.mm: Same.
        * obj-c++.dg/exceptions-6.mm: Same.
        * obj-c++.dg/method-12.mm: Same.
        * obj-c++.dg/method-13.mm: Same.
        * obj-c++.dg/method-6.mm: Same.
        * obj-c++.dg/method-7.mm: Same.
        * obj-c++.dg/method-9.mm: Same.
        * obj-c++.dg/method-lookup-1.mm: Same.
        * obj-c++.dg/proto-lossage-4.mm: Same.
        * obj-c++.dg/protocol-qualifier-2.mm: Same.
        * objc.dg/call-super-2.m: Same.
        * objc.dg/class-protocol-1.m: Same.
        * objc.dg/desig-init-1.m: Same.
        * objc.dg/exceptions-3.m: Same.
        * objc.dg/exceptions-4.m: Same.
        * objc.dg/exceptions-5.m: Same.
        * objc.dg/exceptions-6.m: Same.
        * objc.dg/method-19.m: Same.
        * objc.dg/method-2.m: Same.
        * objc.dg/method-5.m: Same.
        * objc.dg/method-6.m: Same.
        * objc.dg/method-7.m: Same.
        * objc.dg/method-lookup-1.m: Same.
        * objc.dg/proto-hier-1.m: Same.
        * objc.dg/proto-lossage-4.m: Same.

From-SVN: r271338
2019-05-17 11:55:43 -06:00
François Dumont 6f1becb660 2019-05-17 François Dumont <fdumont@gcc.gnu.org>
* include/bits/stl_deque.h
	(_Deque_iterator<>::__ptr_to): Remove, use std::__ptr_rebind.
	(_Deque_base(_Deque_base&&, const allocator_type&)): New.
	(_Deque_base::_Deque_impl_data): New.
	(_Deque_base::_Deque_impl): Inherit latter.
	(_Deque_base::_Deque_impl::_M_swap_data): Move...
	(_Deque_base::_Deque_impl_data::_M_swap_data): ... here.
	(_Deque_base::_Deque_impl()): Add noexcept qualification.
	(_Deque_base::_Deque_impl(_Deque_impl&&, _Tp_alloc_type&&)): New.
	(_Deque_base::_Deque_impl::_M_get_Tp_allocator()): Remove static_cast.
	(deque<>::deque()): Default.
	(deque<>::deque(deque&&)): Default.
	(deque<>::deque(deque&&, const allocator_type&, false_type)): New.
	(deque<>::deque(deque&&, const allocator_type&, true_type)): New.
	(deque<>::deque(deque&&, const allocator_type&)): Delegate to latters.
	(deque<>::deque<_It>(_It, _It, const allocator_type&)): Use
	_M_range_initialize.
	(deque<>::assign<_It>(_It, _It)): Use _M_assign_aux.
	(deque<>::resize(size_type, const value_type&)): Share a single
	implementation.
	(deque<>::insert<_It>(const_iterator, _It, _It)): Use
	_M_range_insert_aux.
	[__cplusplus >= 201103L](_M_initialize_dispatch): Remove.
	[__cplusplus >= 201103L](_M_assign_dispatch): Remove.
	[__cplusplus >= 201103L](_M_insert_dispatch): Remove.
	* testsuite/23_containers/deque/allocator/default_init.cc: New.

From-SVN: r271330
2019-05-17 16:27:54 +00:00
Jonathan Wakely c43c3af2c5 PR libstdc++/90246 Improve text of std::variant exceptions and assertions
PR libstdc++/90246
	* include/std/variant (holds_alternative, get, get_if): Improve
	static assertion messages.
	(bad_variant_access::bad_variant_access()): Change default message.
	(__throw_bad_variant_access(bool)): New overload.
	(get): Use new overload.
	(visit, visit<R>): Improve exception message.

From-SVN: r271326
2019-05-17 15:36:37 +01:00
Jonathan Wakely ac781bc880 Fix std::variant test for ILP32 targets
* testsuite/20_util/variant/compile.cc: Fix narrowing test for ILP32
	targets. Add more cases from P0608R3.
	* testsuite/20_util/variant/run.cc: Add more cases from P0608R3.

From-SVN: r271325
2019-05-17 15:13:43 +01:00
Jonathan Wakely 593cda3e61 Fix uses of non-reserved names for template parameters
* include/bits/random.h (seed_seq::param): Fix non-reserved name.
	* include/experimental/type_traits (is_detected_exact)
	(is_detected_exact_v): Likewise.
	* include/pstl/execution_defs.h (is_execution_policy)
	(is_execution_policy_v, __enable_if_execution_policy): Likewise.
	* include/pstl/execution_impl.h (__policy_traits): Likewise.
	* testsuite/17_intro/names.cc: Check for more non-reserved names.
	* testsuite/experimental/names.cc: New test.

From-SVN: r271324
2019-05-17 15:13:40 +01:00
Jonathan Wakely e625ccc21a PR libstdc++/85965 move is_invocable assertions again
This is another attempt to reduce how often the assertions are
evaluated, so that code which doesn't try to use the function objects
doesn't need them to be invocable.

For _Rb_tree we access the _M_key_compare object directly, so can't put
the assertions in an accessor function for it. However, every invocation
of _M_key_compare is accompanied by a use of _S_key, so the assertions
can be put in there.  For _Hashtable there are member functions that are
consistently used to obtain a hash code or test for equality, so the
assertions can go in those members.

	PR libstdc++/85965
	* include/bits/hashtable.h (_Hashtable::~_Hashtable()): Remove static
	assertions from the destructor.
	* include/bits/hashtable_policy.h (_Hash_code_base::_M_hash_code):
	Move static_assert for hash function to here.
	(_Hash_table_base::_M_equals): Move static_assert for equality
	predicate to here.
	* include/bits/stl_tree.h (_Rb_tree::_S_value(_Const_Link_type)):
	Remove.
	(_Rb_tree::_S_key(_Const_Link_type)): Move assertions here. Access
	the value directly instead of calling _S_value.
	(_Rb_tree::_S_value(_Const_Base_ptr)): Remove.
	(_Rb_tree::_S_key(_Const_Base_ptr)): Do downcast and forward to
	_S_key(_Const_Link_type).
	* testsuite/23_containers/set/85965.cc: Check construction,
	destruction, assignment and size() do not trigger the assertions.
	* testsuite/23_containers/unordered_set/85965.cc: Likewise.
	* testsuite/23_containers/map/48101_neg.cc: Call find and adjust
	expected errors.
	* testsuite/23_containers/multimap/48101_neg.cc: Likewise.
	* testsuite/23_containers/multiset/48101_neg.cc: Likewise.
	* testsuite/23_containers/set/48101_neg.cc: Likewise.
	* testsuite/23_containers/unordered_map/48101_neg.cc: Likewise.
	* testsuite/23_containers/unordered_multimap/48101_neg.cc: Likewise.
	* testsuite/23_containers/unordered_multiset/48101_neg.cc: Likewise.
	* testsuite/23_containers/unordered_set/48101_neg.cc: Likewise.

From-SVN: r271323
2019-05-17 15:13:32 +01:00
Jonathan Wakely c471fb2f94 Fix __invoke_r<void> to be valid in C++11
* include/bits/invoke.h [__cplusplus < 201703L] (__invoke_r<void>):
	Use _GLIBCXX14_CONSTEXPR because void functions cannot be constexpr
	in C++11.

From-SVN: r271317
2019-05-17 10:28:17 +01:00
Jonathan Wakely 32a1aa7095 Add missing piece of P0777R1 and update C++20 status docs
* doc/xml/manual/status_cxx2020.xml: Update P0608R3, P0777R1, and
	P1165R1 entries.
	* doc/html/*: Regenerate.
	* include/std/tuple (make_from_tuple): Use remove_reference_t instead
	of decay_t (P0777R1).

From-SVN: r271316
2019-05-17 10:28:13 +01:00
François Dumont 935469daaa Move from state of allocators (LWG2593)
2019-05-17  François Dumont  <fdumont@gcc.gnu.org>

	Move from state of allocators (LWG2593)
	* include/bits/stl_deque.h
	(_Deque_base(_Deque_base&&, false_type)): Remove.
	(_Deque_base(_Deque_base&&, true_type)): Remove.
	(_Deque_base(_Deque_base&&)): Adapt.
	(_Deque_base::_M_move_impl()): Remove.
	* testsuite/util/testsuite_allocator.h
	(propagating_allocator(propagating_allocator&&)): Preserve move from
	state.
	* testsuite/23_containers/deque/allocator/move_assign.cc (test02):
	Adapt.
	* testsuite/23_containers/forward_list/allocator/move_assign.cc (test02):
	Adapt.
	* testsuite/23_containers/list/allocator/move_assign.cc (test02): Adapt.
	* testsuite/23_containers/map/allocator/move_assign.cc (test02): Adapt.
	* testsuite/23_containers/multimap/allocator/move_assign.cc (test02):
	Adapt.
	* testsuite/23_containers/multiset/allocator/move_assign.cc (test02):
	Adapt.
	* testsuite/23_containers/set/allocator/move_assign.cc (test02): Adapt.
	* testsuite/23_containers/unordered_map/allocator/move_assign.cc
	(test02): Adapt.
	* testsuite/23_containers/unordered_multimap/allocator/move_assign.cc
	(test02): Adapt.
	* testsuite/23_containers/unordered_multiset/allocator/move_assign.cc
	(test02): Adapt.
	* testsuite/23_containers/unordered_set/allocator/move_assign.cc
	(test02): Adapt.
	* testsuite/23_containers/vector/allocator/move_assign.cc (test02):
	Adapt.
	* testsuite/23_containers/vector/bool/allocator/move_assign.cc (test02):
	Adapt.
	* testsuite/21_strings/basic_string/allocator/char/move_assign.cc
	(test02): Adapt.
	* testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc
	(test02): Adapt.

From-SVN: r271309
2019-05-17 04:55:37 +00:00
Jonathan Wakely 7110128236 Remove incorrect assertion from filesystem::absolute
The assertion is wrong, it should be *s.end() == 0, but that's not
allowed. Just remove it, but keep the comment.

	* src/c++17/fs_ops.cc (absolute(const path&, error_code&))
	[_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Remove bogus assertion.

From-SVN: r271300
2019-05-16 23:52:10 +01:00
Jonathan Wakely d069df01ed Implement sane variant converting constructor (P0608R3)
* include/std/variant (__overload_set): Remove.
	(_Arr): New helper.
	(_Build_FUN): New class template to define a single FUN overload,
	with specializations to prevent unwanted conversions, as per P0608R3.
	(_Build_FUNs): New class template to build an overload set of FUN.
	(_FUN_type): New alias template to perform overload resolution.
	(__accepted_type): Use integer_constant base for failure case. Use
	_FUN_type for successful case.
	(variant::__accepted_index): Use _Tp instead of _Tp&&.
	(variant::variant(_Tp&&)): Likewise.
	(variant::operator=(_Tp&&)): Likewise.

From-SVN: r271296
2019-05-16 21:30:35 +01:00
Jonathan Wakely b62dcd16aa Changes to std::variant to reduce code size
* include/std/variant (_Variant_storage<false, _Types...>::_M_reset):
	Replace raw visitation with a runtime check for the valueless state
	and a non-raw visitor.
	(_Variant_storage<false, _Types...>::_M_reset_impl): Remove.
	(variant::index()): Remove branch.
	(variant::swap(variant&)): Use valueless_by_exception() instead of
	comparing the index to variant_npos, and add likelihood attribute.

From-SVN: r271295
2019-05-16 21:30:27 +01:00
Jonathan Wakely eba20412b4 Replace _Equal_helper with simpler class template
By defining the new helper inside _Hashtable_base it doesn't need all
the template parameters to be provided, and by making it only
responsible for checking a possibly-cached hash code it only has to do
one thing.  The caller can use the equality predicate itself instead of
duplicating that in the helper template.

	* include/bits/hashtable_policy.h (_Equal_helper): Remove.
	(_Hashtable_base::_Equal_hash_code): Define new class template.
	(_Hashtable_base::_M_equals): Use _Equal_hash_code instead of
	_Equal_helper.

From-SVN: r271291
2019-05-16 15:18:50 +01:00
Jonathan Wakely 1f6ea96860 Change EBO accessors from static to non-static member functions
* include/bits/hashtable_policy.h (_Hashtable_ebo_helper::_S_get):
	Replace with _M_get non-static member function.
	(_Hashtable_ebo_helper::_S_cget): Replace with _M_cget non-static
	member function.
	(_Hash_code_base, _Local_iterator_base, _Hashtable_base):
	(_Hashtable_alloc): Adjust to use non-static members of EBO helper.

From-SVN: r271290
2019-05-16 15:18:45 +01:00
Jonathan Wakely 0bc229dbbe Remove unnecessary non-const accessors in hash table bases
The const accessors are OK (and arguably more correct) for most callers
to use. The _M_swap functions that use the non-const overloads can just
directly use the _S_get members of the EBO helpers.

	* include/bits/hashtable_policy.h (_Hash_code_base::_M_swap): Use
	_S_get accessors for members in EBO helpers.
	(_Hash_code_base::_M_extract(), _Hash_code_base::_M_ranged_hash())
	(_Hash_code_base::_M_h1(), _Hash_code_base::_M_h2()): Remove non-const
	overloads.
	(_Hashtable_base::_M_swap): Use _S_get accessors for members in EBO
	helpers.
	(_Hashtable_base::_M_eq()): Remove non-const overload.

From-SVN: r271286
2019-05-16 11:04:50 +01:00
Jonathan Wakely e5d7010bb3 Qualify calls in std::visit and std::visit<R>
* include/std/variant (visit, visit<R>): Qualify calls to __do_visit.

From-SVN: r271268
2019-05-15 22:19:39 +01:00
Jonathan Wakely ff8b2a0acb Fix NullablePointer test utility
* testsuite/util/testsuite_allocator.h (NullablePointer::operator bool):
	Fix return value.

From-SVN: r271189
2019-05-14 21:01:28 +01:00
Rainer Orth ccd1242eec Remove obsolete Solaris 10 support
libstdc++-v3:
	* config/os/solaris/solaris2.10: Move to ...
	* config/os/solaris: ... this.
	* configure.host (os_include_dir): Adapt.
	(abi_baseline_pair): Remove Solaris 10 handling.
	* config/abi/post/i386-solaris2.10: Remove.
	* config/abi/post/sparc-solaris2.10: Remove.
	* config/abi/post/i386-solaris2.11: Rename to ...
	* config/abi/post/i386-solaris: ... this.
	* config/abi/post/sparc-solaris2.11: Rename to ...
	* config/abi/post/sparc-solaris: ... this.

	* libsupc++/new_opa.cc [_GLIBCXX_HAVE_MEMALIGN] [__sun]: Remove
	workaround.

	* testsuite/ext/enc_filebuf/char/13598.cc: Remove *-*-solaris2.10
	xfail.

	libsanitizer:
	* configure.ac (have_dl_iterate_phdr): Remove *-*-solaris2.10*
	handling.
	* configure: Regenerate.

	libgcc:
	* config.host: Simplify various *-*-solaris2.1[0-9]* to
	*-*-solaris2*.
	* configure.ac: Likewise.
	* configure: Regenerate.

	* config/i386/sol2-unwind.h (x86_fallback_frame_state): Remove
	Solaris 10 and Solaris 11 < snv_125 handling.

	libbacktrace:
	* configure.ac (have_dl_iterate_phdr): Remove *-*-solaris2.10*
	handling.
	* configure: Regenerate.

	gcc/testsuite:
	* gcc.dg/atomic/c11-atomic-exec-4.c: Simplify triplet to
	*-*-solaris2*.
	* gcc.dg/atomic/c11-atomic-exec-5.c: Likewise.
	* gcc.dg/c99-math-double-1.c: Likewise.
	* gcc.dg/c99-math-float-1.c: Likewise.
	* gcc.dg/c99-math-long-double-1.c: Likewise.
	* gcc.misc-tests/linkage.exp: Simplify triplet to
	x86_64-*-solaris2*.

	* gcc.target/i386/mcount_pic.c: Remove *-*-solaris2.10* && !gld
	xfail.
	* gcc.target/i386/pr63620.c: Likewise.

	* lib/target-supports.exp (check_sse_os_support_available): Remove
	Solaris 9/x86 workaround.

	gcc:
	* config.gcc: Move *-*-solaris2.10* from obsolete configurations
	to unsupported ones.
	Simplify x86_64-*-solaris2.1[0-9]* to x86_64-*-solaris2*.
	* config.host: Likewise.
	* config/i386/sol2.h (ASM_COMMENT_START): Remove.
	* config/sparc/driver-sparc.c (host_detect_local_cpu) [__sun__ &&
	__svr4__]: Remove "brand" fallback.
	[!KSTAT_DATA_STRING]: Remove.
	* configure.ac (gcc_cv_ld_hidden): Simplify *-*-solaris2.1[0-9]*
	to *-*-solaris2*.
	(comdat_group): Likewise.
	(set_have_as_tls): Likewise.
	(gcc_cv_target_dl_iterate_phdr): Likewise.
	(gcc_cv_as_shf_merge): Remove Solaris 10/x86 workaround.
	(gcc_cv_ld_aligned_shf_merge): Remove Solaris 10/SPARC workaround.
	* configure: Regenerate.
	* doc/install.texi: Simplify Solaris target triplets.
	(Specific, i?86-*-solaris2*): Remove Solaris 10 references.
	(Specific, *-*-solaris2*): Document Solaris 10 removal.
	Remove Solaris 10 references.
	Remove obsolete Solaris bug reference.
	(Specific, sparc-sun-solaris2.10): Remove.

From-SVN: r271183
2019-05-14 17:17:23 +00:00
Jonathan Wakely 956a62aaa2 Add __raw_visit and __raw_idx_visit, use INVOKE<R>
This change simplifies visitation for variants, by using INVOKE<R> for
the visit<R> form, and explicitly specifying the tag types for raw
visitation, instead of inferring them from the return types of the
lambda functions used as visitors.

	* include/std/variant (__visit_with_index): Remove typedef.
	(__deduce_visit_result): New tag type.
	(__raw_visit, __raw_idx_visit): New helper functions for "raw"
	visitation of possibly-valueless variants, forwarding to __do_visit
	with the relevant tag type.
	(_Variant_storage<false, _Types...>::_M_reset_impl): Use __raw_visit
	and make lambda return void.
	(__variant_construct): Likewise.
	(_Copy_assign_base::operator=, _Move_assign_base::operator=): Use
	__raw_idx_visit and make lambda return void.
	(_Multi_array::__untag_result): Add metafunction to check the function
	pointer type for a tag type that dictates the kind of visitation.
	(_Multi_array<_Ret(*)(_Visitor, _Variants...), __first, __rest...>):
	Use decltype(auto) instead of tagged function pointer type.
	(__gen_vtable_impl): Remove bool non-type parameter and unused
	_Variant_tuple parameter.
	(__gen_vtable_impl::__visit_invoke_impl): Remove.
	(__gen_vtable_impl::__do_visit_invoke): Remove.
	(__gen_vtable_impl::__do_visit_invoke_r): Remove.
	(__gen_vtable_impl::__visit_invoke): Use if-constexpr and __invoke_r
	for the visit<R> case, rather than dispatching to separate functions.
	(_VARIANT_RELATION_FUNCTION_TEMPLATE): Use __raw_idx_visit and make
	lambda return void.
	(variant::swap): Likewise.
	(__do_visit): Replace two non-type template parameters with a single
	type parameter, so that the caller must specify the visitor's return
	type (or one of the tag types).
	(visit): Deduce a return type from the visitor and use the
	__deduce_visit_result tag to enforce that all overloads return the
	same type.
	(visit<R>): Call __do_visit<R> with explicit result type.
	(__variant_hash_call_base_impl::operator()): Use __raw_visit and make
	lambda return void.

From-SVN: r271182
2019-05-14 17:46:07 +01:00
Nina Dinka Ranns a73d2fa852 nonesuch is insufficiently useless (lwg2996)
2019-05-14  Nina Dinka Ranns  <dinka.ranns@gmail.com>

	nonesuch is insufficiently useless (lwg2996)
	* include/std/type_traits (struct __nonesuch): Added private base
	class to make __nonesuch not an aggregate and removed deleted default
	constructor.
	* include/bits/stl_pair.h (struct __nonesuch_no_braces): Removed.
	(operator=(const pair&)): Use __nonesuch instead of
	__nonesuch_no_braces.
	(operator=(pair&&)): Likewise
	* include/std/tuple (operator=(const tuple&)): Use __nonesuch instead
	of __nonesuch_no_braces.
	(operator=(tuple&&)): Likewise
	* include/experimental/type_traits (struct nonesuch): Added private
	base class to make nonesuch not an aggregate and removed deleted
	default constructor.
	* testsuite/20_util/nonesuch/nonesuch.cc: New.
	* testsuite/experimental/type_traits/nonesuch.cc: New.

From-SVN: r271175
2019-05-14 16:48:27 +01:00
Jonathan Wakely 330b17474c Use INVOKE<R> in std::function, std::bind and std::packaged_task
As well as simpifying the code by removing duplication, this means that
we only need to touch std::__invoke_r if we need to implement changes to
INVOKE<R>, such as those in P0932R0.

	* include/bits/std_function.h (_Simple_type_wrapper): Remove.
	(_Function_handler): Remove partial specializations for void return
	types and pointers to member.
	(_Function_handler::_M_manager): Adapt to removal of
	_Simple_type_wrapper.
	(_Function_handler::_M_invoke): Use __invoke_r instead of __invoke.
	* include/std/functional (_Bind_result::__enable_if_void)
	(_Bind_result::__disable_if_void): Remove sfinae helpers.
	(_Bind_result::__call): Use __invoke_r and remove overloads for void
	return types.
	* include/std/future (__future_base::_Task_state::_M_run)
	(__future_base::_Task_state::_M_run_delayed): Use __invoke_r and
	change return type of lambda expressions.

From-SVN: r271174
2019-05-14 16:25:08 +01:00
Jonathan Wakely 78c2855df6 Define std::__invoke_r for INVOKE<R>
* include/bits/invoke.h (__invoke_r): Define new function implementing
	the INVOKE<R> pseudo-function.
	* testsuite/20_util/function_objects/invoke/1.cc: Add more tests.
	* testsuite/20_util/function_objects/invoke/2.cc: New test.

From-SVN: r271173
2019-05-14 16:25:01 +01:00
Jonathan Wakely ce9f305e44 Add __is_nothrow_convertible to fix std::is_nothrow_invocable_r
The definition of is_nothrow_invocable in terms of is_convertible and
is_nothrow_constructible is incorrect, because a type could have an
explicit constructor that means is_nothrow_constructible is true, but
implicit conversions could use a different constructor that is
potentially-throwing.

Fix it by adding a C++11 version of C++20's is_nothrow_convertible that
only considers implicit conversions.

	* include/std/type_traits (__is_nt_convertible_helper): Define it
	unconditionally, not only for C++20.
	(__is_nothrow_convertible): Define internal trait for use in C++11.
	(__is_nt_invocable_impl: Fix by using __is_nothrow_convertible.
	(is_invocable_r_v, is_nothrow_invocable_r_v): Add missing parameter.
	* testsuite/20_util/is_nothrow_convertible/value_ext.cc: New test.
	* testsuite/20_util/is_nothrow_convertible/value.cc: Check with type
	that has nothrow explicit conversion but potentially-throwing implicit
	conversion.
	* testsuite/20_util/is_nothrow_invocable/value.cc: Likewise.
	* testsuite/20_util/is_nothrow_invocable/value_ext.cc: Fix helper
	function to only consider implicit conversions.
	* testsuite/20_util/tuple/cons/noexcept_specs.cc: Add comment.

From-SVN: r271171
2019-05-14 15:39:58 +01:00
Jonathan Wakely 22b6a9c1cd Reduce header dependencies in <iterator>
* include/std/iterator: Include <iosfwd> instead of <istream> and
	<ostream>.

From-SVN: r271169
2019-05-14 13:47:39 +01:00
Jonathan Wakely 7198e982e9 Removing unused, non-standard function in _Rb_tree
* include/bits/stl_tree.h (_Rb_tree::erase(const Key*, const Key*)):
	Remove unused, non-standard function.

From-SVN: r271168
2019-05-14 13:19:10 +01:00
Jonathan Wakely 0b3c00ff3c Make std::match_results::_M_resize more useful
As both callers of match_results::_M_resize(unsigned) immediately follow
it with a loop to update the value of each sub_match, that behaviour can
be moved into _M_resize itself. The first caller fills the container
with unmatched subs, which can be done with vector::assign, and the
second caller clears the container to establish a specific state, which
can be provided by a new member function specific to that purpose.

Tangentially, I also noticed that match_results::max_size() doesn't
account for the three special sub_match objects that are always present
in a fully established result state. This patch also fixes that.

	* include/bits/regex.h (match_results::max_size()): Adjust return
	value to account for prefix/suffix/unmatched subs.
	(match_results::_M_resize(unsigned int)): Use _Base_type::assign to
	reset the contained sub matches.
	(match_results::_M_establish_failed_match(_Bi_iter)): Add new member
	function to set result state following a failed match.
	* include/bits/regex.tcc (__regex_algo_impl): Remove loop to set
	sub_match states after _M_resize. Use _M_establish_failed_match.

From-SVN: r271167
2019-05-14 13:19:05 +01:00
Jonathan Wakely 8db7a05fd7 PR libstdc++/69724 avoid temporary in std::thread construction
The std::thread constructor creates (and then moves) an unnecessary
temporary copy of each argument. Optimize it to only make the one copy
that is required.

	PR libstdc++/69724
	* include/std/thread (thread::_State_impl, thread::_S_make_state):
	Replace single _Callable parameter with variadic _Args pack, to
	forward them directly to the tuple of decayed copies.
	* testsuite/30_threads/thread/cons/69724.cc: New test.

From-SVN: r271166
2019-05-14 13:01:15 +01:00