Commit Graph

4261 Commits

Author SHA1 Message Date
Jonathan Wakely 9cadd6bd4d Fix typo in effective-target check
* testsuite/lib/libstdc++.exp (check_v3_target_parallel_mode): Fix
	typo.

From-SVN: r270259
2019-04-10 15:46:03 +01:00
Jonathan Wakely 4a3f7992d2 PR libstdc++/89851 Add testcase for std::variant equality
Add a test for the regression introduced with r269422 and fixed with
r270056.

	PR libstdc++/89851
	* testsuite/20_util/variant/89851.cc: New test.

From-SVN: r270249
2019-04-10 11:43:39 +01:00
Jonathan Wakely 9d89b73c06 Add comments and style fixes to <variant>
* include/std/variant: Adjust whitespace. Add comments.
	(_Multi_array): Leave primary template undefined.
	(_Multi_array<_Tp>): Define partial specialization for base case of
	recursion.
	(__gen_vtable_impl, __gen_vtable): Remove redundant && from type
	which is always a reference.
	(__gen_vtable::_S_apply()): Remove function, inline body into
	default member initializer.
	* testsuite/20_util/variant/visit.cc: Test with noncopyable types.

From-SVN: r270238
2019-04-09 19:50:48 +01:00
Jonathan Wakely 8701cb5e0d Fix std::visit to support arbitrary callables
The __visitor_result_type helper didn't use std::invoke and so didn't
compile when the visitor was a pointer-to-member rather than a function
object. Use std::invoke_result instead.

	* include/std/variant (__variant_idx_cookie): Add member type.
	(__visitor_result_type): Remove.
	(__do_visit): Use invoke_result instead of __visitor_result_type.
	* testsuite/20_util/variant/visit.cc: New test.

From-SVN: r270237
2019-04-09 19:50:43 +01:00
Jonathan Wakely bc203bf0da PR libstdc++/90008 remove unused capture from variant rel ops
PR libstdc++/90008
	* include/std/variant (_VARIANT_RELATION_FUNCTION_TEMPLATE): Remove
	unused capture.
	* testsuite/20_util/variant/90008.cc: New test.

From-SVN: r270236
2019-04-09 19:50:39 +01:00
Ville Voutilainen 3d01c7c2f2 Fix visit<R> for variant.
* include/std/variant (__do_visit): Add a template parameter
for enforcing same return types for visit.
(__gen_vtable_impl): Likewise.
(_S_apply_single_alt): Adjust.
(__visit_invoke_impl): New. Handle casting to void.
(__do_visit_invoke): New. Enforces same return types.
(__do_visit_invoke_r): New. Converts return types.
(__visit_invoke): Adjust.
(__gen_vtable):  Add a template parameter for enforcing
same return types for visit.
* testsuite/20_util/variant/visit_r.cc: Add a test for a visitor with
different return types.
* testsuite/20_util/variant/visit_neg.cc: New. Ensures that
visitors with different return types don't accidentally
compile with regular visitation.

From-SVN: r270216
2019-04-08 22:45:48 +03:00
Christophe Lyon 66d8ee9ce0 [testsuite,libstdc++-v3] Fix 27_io/filesystem/iterators/caching.cc
2019-04-08  Christophe Lyon  <christophe.lyon@linaro.org>

	* testsuite/27_io/filesystem/iterators/caching.cc: Add
	dg-require-filesystem-ts.

From-SVN: r270199
2019-04-08 09:17:30 +02:00
Jonathan Wakely 199b20e3cb Implement std::visit<R> for C++2a (P0655R1)
* doc/xml/manual/status_cxx2020.xml: Update status.
	* include/std/variant (visit<R>): Define for C++2a (P0655R1).
	* testsuite/20_util/variant/visit_r.cc: New test.

From-SVN: r270176
2019-04-05 19:06:02 +01:00
Jonathan Wakely 67087c7e53 PR libstdc++/89986 export directory_iterator::increment
PR libstdc++/89986
	* config/abi/pre/gnu.ver: Add missing exports.
	* testsuite/27_io/filesystem/iterators/directory_iterator.cc: Test
	increment member.

From-SVN: r270174
2019-04-05 17:56:27 +01:00
Jonathan Wakely c7dde4a90a Share all recursive_directory_iterator state [LWG 2708]
Implement the proposed resolution of LWG 2708 by moving the _M_options
and _M_pending members out of the recursive_directory_iterator into the
shared _Dir_stack object. Because _Dir_stack is an opaque type, the
member functions that access the _M_options and _M_pending variables
cannot be inline. Move them into the library.

As a drive-by fix, add noexcept to the non-throwing member functions of
recursive_directory_iterator.

	* config/abi/pre/gnu.ver: Export new symbols.
	* include/bits/fs_dir.h (recursive_directory_iterator::options())
	(recursive_directory_iterator::recursion_pending())
	(recursive_directory_iterator::disable_recursion_pending()): Remove
	inline definitions. Make noexcept.
	(recursive_directory_iterator::depth())
	(recursive_directory_iterator::operator*())
	(recursive_directory_iterator::operator->()): Make noexcept.
	(recursive_directory_iterator::_M_options)
	(recursive_directory_iterator::_M_pending): Remove data members.
	* src/c++17/fs_path.cc (_Dir_stack): Add constructor and data members.
	(recursive_directory_iterator::recursive_directory_iterator): Remove
	ctor-initializer. Use new constructor for _Dir_stack.
	(recursive_directory_iterator::options())
	(recursive_directory_iterator::recursion_pending())
	(recursive_directory_iterator::disable_recursion_pending()): Add
	non-inline definitions.
	(recursive_directory_iterator::depth()): Make noexcept.
	(recursive_directory_iterator::increment(error_code&))
	(recursive_directory_iterator::pop(error_code&)): Adjust to new
	location of options and recursion_pending members.
	* testsuite/27_io/filesystem/iterators/recursion_pending.cc: New test.
	* testsuite/util/testsuite_fs.h (__gnu_test::scoped_file): Add
	user-declared move constructor and assignment operator, to make the
	type move-only.

From-SVN: r270173
2019-04-05 17:56:23 +01:00
Jonathan Wakely 5ed5c0da8b Fix directory_iterator handling of DT_UNKNOWN
We need to handle DT_UNKNOWN earlier, not only during directory
recursion, so that the cached file_type value in the directory_entry
won't be used.

	* src/c++17/fs_dir.cc (_Dir::advance(bool, error_code&)): Handle
	d_type == DT_UNKNOWN immediately.
	(_Dir::should_recurse(bool, error_code&)): Remove file_type::unknown
	handling here.
	* testsuite/27_io/filesystem/iterators/caching.cc: New test.

From-SVN: r270172
2019-04-05 17:56:18 +01:00
Jonathan Wakely d96f11a272 Make filesystem::path safe for self assignment
The standard says "If *this and p are the same object, has no effect."
Previously we ended up clearing the path.

	* include/bits/fs_path.h (path::operator=(path&&)): Check for self
	assignment.
	* src/c++17/fs_path.cc (path::operator=(const path&)): Likewise.
	* testsuite/27_io/filesystem/path/assign/copy.cc: Test self
	assignment.

From-SVN: r270171
2019-04-05 17:56:14 +01:00
Jonathan Wakely 10f26de915 PR libstdc++/87431 re-adjust never-valueless optimizations
Avoid creating arbitrarily large objects on the stack when emplacing
trivially copyable objects into a variant. Currently we provide the
strong exception-safety guarantee for all trivially copyable types, by
constructing a second variant and then doing a non-throwing move
assignment from the temporary. This patch restricts that behaviour to
trivially copyable types that are no larger than 256 bytes. For larger
types the object will be emplaced directly into the variant, and if its
initialization throws then the variant becomes valueless.

Also implement Antony Polukhin's suggestion to whitelist specific types
that are not trivially copyable but can be efficiently move-assigned.
Emplacing those types will never cause a variant to become valueless.
The whitelisted types are: std::shared_ptr, std::weak_ptr,
std::unique_ptr, std::function, and std::any. Additionally,
std::basic_string, std::vector, and __gnu_debug::vector are whitelisted
if their allocator traits give them a non-throwing move assignment
operator. Specifically, this means std::string is whitelisted, but
std::pmr::string is not.

As part of this patch, additional if-constexpr branches are added for
the cases where the initialization is known to be non-throwing (so the
overhead of the try-catch block can be avoided) and where a scalar is
being produced by a potentially-throwing conversion operator (so that
the overhead of constructing and move-assigning a variant is avoided).
These changes should have no semantic effect, just better codegen.

	PR libstdc++/87431 (again)
	* include/bits/basic_string.h (__variant::_Never_valueless_alt):
	Define partial specialization for basic_string.
	* include/bits/shared_ptr.h (_Never_valueless_alt): Likewise for
	shared_ptr and weak_ptr.
	* include/bits/std_function.h (_Never_valueless_alt): Likewise for
	function.
	* include/bits/stl_vector.h (_Never_valueless_alt): Likewise for
	vector.
	* include/bits/unique_ptr.h (_Never_valueless_alt): Likewise for
	unique_ptr.
	* include/debug/vector (_Never_valueless_alt): Likewise for debug
	vector.
	* include/std/any (_Never_valueless_alt): Define explicit
	specialization for any.
	* include/std/variant (_Never_valueless_alt): Define primary template.
	(__never_valueless): Use _Never_valueless_alt instead of
	is_trivially_copyable.
	(variant::emplace<N>(Args&&...)): Add special case for non-throwing
	initializations to avoid try-catch overhead. Add special case for
	scalars produced by potentially-throwing conversions. Use
	_Never_valueless_alt instead of is_trivially_copyable for the
	remaining strong exception-safety cases.
	(variant::emplace<N>(initializer_list<U>, Args&&...)): Likewise.
	* testsuite/20_util/variant/87431.cc: Run both test functions.
	* testsuite/20_util/variant/exception_safety.cc: New test.
	* testsuite/20_util/variant/run.cc: Use pmr::string instead of string,
	so the variant becomes valueless.

From-SVN: r270170
2019-04-05 17:56:09 +01:00
Jonathan Wakely 0cb78ef4bc Define std::hash specializations for C++17 PMR strings
These hash specializations should have been added when the pmr::string
and related typedefs were added.

	* include/std/string (__hash_string_base): New class template defining
	operator() for hashing strings.
	(hash<pmr::string>, hash<pmr::u8string>, hash<pmr::u16string>)
	(hash<pmr::u32string>, hash<pmr::wstring>): Define for C++17.
	* testsuite/21_strings/basic_string/hash/hash.cc: New test.
	* testsuite/21_strings/basic_string/hash/hash_char8_t.cc: New test.

From-SVN: r270116
2019-04-03 10:47:47 +01:00
Jonathan Wakely 7ac205673c PR libstdc++/85965 delay static assertions until types are complete
The static assertions added for PR libstdc++/48101 were at class scope
and so were evaluated too eagerly, when it might not be possible to
determine whether the function objects are invocable with the key types.
The problematic cases are where the key type is not known to be
convertible to the argument type(s) of the function object until later,
after a type has been completed. Specifically, if the key type is a
pointer to a derived class and the function object's argument type is a
pointer to a base class, then the derived-to-base conversion is only
valid once the derived type is complete.

By moving the static assertions to the destructor they will only be
evaluated when the destructor is instantiated, at which point whether
the key type can be passed to the function object should be knowable.
The ideal place to do the checks would be only when the function objects
are actually invoked, but that would mean adding the checks in numerous
places, so the destructor is used instead.

The tests need to be adjusted because the "required from here" line is
now the location of the destructor, not the point of instantiation in
the test file. For the map and multimap tests which check two
specializations, the dg-error matching the assertion text matches both
cases. Also check the diagnostic output for the template arguments, to
ensure both specializations trigger the assertion.

	PR libstdc++/85965
	* include/bits/hashtable.h (_Hashtable): Move static assertions to
	destructor so they are not evaluated until the _Key type is complete.
	* include/bits/stl_tree.h (_Rb_tree): Likewise.
	* testsuite/23_containers/set/85965.cc: New test.
	* testsuite/23_containers/unordered_set/85965.cc: New test.
	* testsuite/23_containers/map/48101_neg.cc: Replace "here" errors
	with regexp matching the corresponding _Rb_tree specialization.
	* testsuite/23_containers/multimap/48101_neg.cc: Likewise.
	* testsuite/23_containers/multiset/48101_neg.cc: Remove "here" error.
	* 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: r269949
2019-03-26 15:28:48 +00:00
Thomas Rodgers 061f457868 Integrate C++17 parallel algorithms
This is the Intel implementation of the C++17 parallel
algorithms, which has been donated to both GCC and LLVM. The upstream
project is at -

	https://reviews.llvm.org/source/pstl/

The new files in the include/pstl sub-directory are covered by the
LICENSE.txt in that sub-directory, as are the tests in
testsuite/**/pstl/*

	* include/Makefile.am (std_header): Add ${std_srcdir}/execution.
	(pstl_srcdir, pstl_builddir, pstl_headers): New variables.
	(allstamped): Add stamp-pstl.
	(install-headers): Add ptsl_builddir.
	* include/Makefile.in: Regenerate.
	* include/bits/c++config: Add pstl configuration.
	* include/pstl/LICENSE.txt: New file.
	* include/pstl/algorithm_fwd.h: New file.
	* include/pstl/algorithm_impl.h: New file.
	* include/pstl/execution_defs.h: New file.
	* include/pstl/execution_impl.h: New file.
	* include/pstl/glue_algorithm_defs.h: New file.
	* include/pstl/glue_algorithm_impl.h: New file.
	* include/pstl/glue_execution_defs.h: New file.
	* include/pstl/glue_memory_defs.h: New file.
	* include/pstl/glue_memory_impl.h: New file.
	* include/pstl/glue_numeric_defs.h: New file.
	* include/pstl/glue_numeric_impl.h: New file.
	* include/pstl/memory_impl.h: New file.
	* include/pstl/numeric_fwd.h: New file.
	* include/pstl/numeric_impl.h: New file.
	* include/pstl/parallel_backend.h: New file.
	* include/pstl/parallel_backend_tbb.h: New file.
	* include/pstl/parallel_backend_utils.h: New file.
	* include/pstl/parallel_impl.h: New file.
	* include/pstl/pstl_config.h: New file.
	* include/pstl/unseq_backend_simd.h: New file.
	* include/pstl/utils.h: New file.
	* include/std/algorithm: Include parallel algorithm implementations.
	* include/std/execution: New file.
	* include/std/memory: Include parallel algorithm implementations.
	* include/std/numeric: Include parallel algorithm implementations.
	* include/std/version: Add parallel algorithms feature test macro.
	* testsuite/util/pstl/pstl_test_config.h: New file.
	* testsuite/util/pstl/test_utils.h: New file.
	* testsuite/20_util/specialized_algorithms/pstl/uninitialized_construct.cc: New file.
	* testsuite/20_util/specialized_algorithms/pstl/uninitialized_copy_move.cc: New file.
	* testsuite/20_util/specialized_algorithms/pstl/uninitialized_fill_destroy.cc: New file.
	* testsuite/25_algorithms/pstl/alg_merge/inplace_merge.cc: New file.
	* testsuite/25_algorithms/pstl/alg_merge/merge.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/copy_if.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/copy_move.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/fill.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/generate.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/is_partitioned.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/partition.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/partition_copy.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/remove.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/remove_copy.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/replace.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/replace_copy.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/rotate.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/rotate_copy.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/swap_ranges.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/transform_binary.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/transform_unary.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/unique.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/unique_copy_equal.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/adjacent_find.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/all_of.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/any_of.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/count.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/equal.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_end.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_first_of.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_if.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/for_each.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/mismatch.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/none_of.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/reverse.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/reverse_copy.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/search_n.cc: New file.
	* testsuite/25_algorithms/pstl/alg_sorting/includes.cc: New file.
	* testsuite/25_algorithms/pstl/alg_sorting/is_heap.cc: New file.
	* testsuite/25_algorithms/pstl/alg_sorting/is_sorted.cc: New file.
	* testsuite/25_algorithms/pstl/alg_sorting/lexicographical_compare.cc: New file.
	* testsuite/25_algorithms/pstl/alg_sorting/minmax_element.cc: New file.
	* testsuite/25_algorithms/pstl/alg_sorting/partial_sort.cc: New file.
	* testsuite/25_algorithms/pstl/alg_sorting/partial_sort_copy.cc: New file.
	* testsuite/25_algorithms/pstl/alg_sorting/set.cc: New file.
	* testsuite/25_algorithms/pstl/alg_sorting/sort.cc: New file.
	* testsuite/26_numerics/pstl/numeric_ops/adjacent_difference.cc: New file.
	* testsuite/26_numerics/pstl/numeric_ops/reduce.cc: New file.
	* testsuite/26_numerics/pstl/numeric_ops/scan.cc: New file.
	* testsuite/26_numerics/pstl/numeric_ops/transform_reduce.cc: New file.
	* testsuite/26_numerics/pstl/numeric_ops/transform_scan.cc: New file.
	* testsuite/testsuite/20_util/specialized_algorithms/pstl/uninitialized_construct.cc: New file.
	* testsuite/testsuite/20_util/specialized_algorithms/pstl/uninitialized_copy_move.cc: New file.
	* testsuite/testsuite/20_util/specialized_algorithms/pstl/uninitialized_fill_destroy.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_merge/inplace_merge.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_merge/merge.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/copy_if.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/copy_move.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/fill.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/generate.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/is_partitioned.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/partition.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/partition_copy.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/remove.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/remove_copy.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/replace.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/replace_copy.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/rotate.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/rotate_copy.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/swap_ranges.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/transform_binary.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/transform_unary.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/unique.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/unique_copy_equal.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/adjacent_find.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/all_of.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/any_of.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/count.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/equal.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/find.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/find_end.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/find_first_of.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/find_if.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/for_each.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/mismatch.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/none_of.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/reverse.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/reverse_copy.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/search_n.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_sorting/includes.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_sorting/is_heap.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_sorting/is_sorted.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_sorting/lexicographical_compare.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_sorting/minmax_element.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_sorting/partial_sort.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_sorting/partial_sort_copy.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_sorting/set.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_sorting/sort.cc: New file.
	* testsuite/testsuite/26_numerics/pstl/numeric_ops/adjacent_difference.cc: New file.
	* testsuite/testsuite/26_numerics/pstl/numeric_ops/reduce.cc: New file.
	* testsuite/testsuite/26_numerics/pstl/numeric_ops/scan.cc: New file.
	* testsuite/testsuite/26_numerics/pstl/numeric_ops/transform_reduce.cc: New file.
	* testsuite/testsuite/26_numerics/pstl/numeric_ops/transform_scan.cc: New file.

From-SVN: r269863
2019-03-21 23:48:49 +00:00
Jonathan Wakely e2186cd88e In C++17 <math.h> should not put special functions in global namespace
IS 29124 8.2 [sf.mathh] says that <math.h> should add the names of the
special functions to the global namespace.  However, C++17 Annex D
[depr.c.headers] excludes those functions explicitly, so they should not
be placed in the global namespace unconditionally for C++17.

Only add them to the global namespace when IS 29124 is explicitly
requested via the __STDCPP_WANT_MATH_SPEC_FUNCS__ macro.

	* include/c_compatibility/math.h [!__STDCPP_WANT_MATH_SPEC_FUNCS__]
	(assoc_laguerre, assoc_laguerref, assoc_laguerrel, assoc_legendre)
	(assoc_legendref, assoc_legendrel, beta, betaf, betal, comp_ellint_1)
	(comp_ellint_1f, comp_ellint_1l, comp_ellint_2, comp_ellint_2f)
	(comp_ellint_2l, comp_ellint_3, comp_ellint_3f, comp_ellint_3l)
	(cyl_bessel_i, cyl_bessel_if, cyl_bessel_il, cyl_bessel_j)
	(cyl_bessel_jf, cyl_bessel_jl, cyl_bessel_k, cyl_bessel_kf)
	(cyl_bessel_kl, cyl_neumann, cyl_neumannf, cyl_neumannl, ellint_1)
	(ellint_1f, ellint_1l, ellint_2, ellint_2f, ellint_2l, ellint_3)
	(ellint_3f, ellint_3l, expint, expintf, expintl, hermite, hermitef)
	(hermitel, laguerre, laguerref, laguerrel, legendre, legendref)
	(legendrel, riemann_zeta, riemann_zetaf, riemann_zetal, sph_bessel)
	(sph_besself, sph_bessell, sph_legendre, sph_legendref, sph_legendrel)
	(sph_neumann, sph_neumannf, sph_neumannl): Only add using-declarations
	when the special functions IS is enabled, not for C++17.
	* testsuite/26_numerics/headers/cmath/functions_global_c++17.cc:
	Replace with ...
	* testsuite/26_numerics/headers/cmath/functions_global.cc: New test,
	without checks for special functions in C++17.
	* testsuite/26_numerics/headers/cmath/special_functions_global.cc:
	New test.

From-SVN: r269837
2019-03-21 14:03:56 +00:00
John David Anglin 2ff656f421 re PR libstdc++/89461 (FAIL: experimental/net/timer/waitable/cons.cc)
PR libstdc++/89461
	* testsuite/lib/libstdc++.exp: Locate libatomic.
	* testsuite/lib/dg-options.exp (add_options_for_libatomic): New.
	* testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc: Add
	libatomic options.
	* testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc: Likewise.
	* testsuite/experimental/net/timer/waitable/cons.cc: Likewise.
	* testsuite/experimental/net/timer/waitable/dest.cc: Likewise.
	* testsuite/experimental/net/timer/waitable/ops.cc: Likewise.

From-SVN: r269628
2019-03-12 23:13:36 +00:00
Jason Merrill c7e936dbc7 PR c++/86521 - wrong overload resolution with ref-qualifiers.
Here we were wrongly treating binding a const lvalue ref to an xvalue as
direct binding, which is wrong under [dcl.init.ref] and [over.match.ref].

	* call.c (build_user_type_conversion_1): Don't use a conversion to a
	reference of the wrong rvalueness for direct binding.

From-SVN: r269602
2019-03-11 23:19:22 -04:00
Jonathan Wakely 355d4eb36a Change test to use const variables instead of macros
This is C++ so there's no reason to use macros here.

	* testsuite/29_atomics/atomic_flag/test_and_set/explicit-hle.cc: Use
	const variables instead of macros.

From-SVN: r269585
2019-03-11 13:46:09 +00:00
Jonathan Wakely 1a823c9ae9 PR libstdc++/89629 fix _Hash_bytes for lengths > INT_MAX
PR libstdc++/89629
	* libsupc++/hash_bytes.cc [__SIZEOF_SIZE_T__ == 8] (_Hash_bytes):
	Use correct type for len_aligned.
	* testsuite/20_util/hash/89629.cc: New test.

From-SVN: r269584
2019-03-11 13:46:05 +00:00
François Dumont 20a4550ce0 re PR libstdc++/89608 (Undetected iterator invalidations on unordered containers in debug mode)
2019-03-08  François Dumont  <fdumont@gcc.gnu.org>

	PR libstdc++/89608
	* include/debug/unordered_map (unordered_map<>::_M_check_rehashed):
	Invalidate all iterators in case of rehash.
	(unordered_multimap<>::_M_check_rehashed): Likewise.
	* include/debug/unordered_set
	(unordered_set<>::_M_check_rehashed): Likewise.
	(unordered_multiset<>::_M_check_rehashed): Likewise.
	* testsuite/23_containers/unordered_set/debug/89608_neg.cc: New.

From-SVN: r269478
2019-03-08 05:37:50 +00:00
Jonathan Wakely e0f7051e44 Fix new test to run as well as compile
* testsuite/20_util/function_objects/bind_front/1.cc: Change from
	compile test to run. Fix typo.

From-SVN: r269457
2019-03-07 14:35:22 +00:00
Jonathan Wakely 9ae2a7c399 P0356R5 Simplified partial function application
* include/std/functional [C++20] (_Bind_front, _Bind_front_t): Define
	helpers for bind_front.
	(bind_front, __cpp_lib_bind_front): Define.
	* testsuite/20_util/function_objects/bind_front/1.cc: New test.

From-SVN: r269455
2019-03-07 14:15:53 +00:00
Jonathan Wakely 4661094069 Add feature test macro for bounded array traits
* include/std/type_traits (__cpp_lib_bounded_array_traits): Define.
	* include/std/version (__cpp_lib_bounded_array_traits): Likewise.
	* testsuite/20_util/is_bounded_array/value.cc: Check for macro.
	* testsuite/20_util/is_unbounded_array/value.cc: Likewise.

From-SVN: r269426
2019-03-06 15:31:06 +00:00
Edward Smith-Rowland f29a1ef2d8 PR libstdc++/86655 - std::assoc_legendre should not constrain
2019-03-06  Edward Smith-Rowland  <3dw4rd@verizon.net>

	PR libstdc++/86655 - std::assoc_legendre should not constrain
	the value of m (or x).
	* include/tr1/legendre_function.tcc (__assoc_legendre_p,
	__sph_legendre): If degree > order Don't throw, return 0.
	(__legendre_p, __assoc_legendre_p): Don't constrain x either.
	* testsuite/special_functions/02_assoc_legendre/pr86655.cc: New test.
	* testsuite/special_functions/20_sph_legendre/pr86655.cc: New test.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	02_assoc_legendre/pr86655.cc: New test.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	22_sph_legendre/pr86655.cc: New test.

From-SVN: r269423
2019-03-06 13:38:32 +00:00
Ville Voutilainen 669a6fdcb4 Rewrite variant, also PR libstdc++/85517
* include/std/variant (__do_visit): New.
(__variant_cast): Likewise.
(__variant_cookie): Likewise.
(__erased_*): Remove.
(_Variant_storage::_S_vtable): Likewise.
(_Variant_storage::__M_reset_impl): Adjust to use __do_visit.
(_Variant_storage::__M_reset): Adjust.
(__variant_construct): New.
(_Copy_ctor_base(const _Copy_ctor_base&)): Adjust to use
__variant_construct.
(_Move_ctor_base(_Move_ctor_base&&)): Likewise.
(_Move_ctor_base::__M_destructive_copy): New.
(_Move_ctor_base::__M_destructive_move): Adjust to use
__variant_construct.
(_Copy_assign_base::operator=): Adjust to use __do_visit.
(_Copy_assign_alias): Adjust to check both copy assignment
and copy construction for triviality.
(_Move_assign_base::operator=): Adjust to use __do_visit.
(_Multi_array): Add support for visitors that accept and return
a __variant_cookie.
(__gen_vtable_impl::_S_apply_all_alts): Likewise.
(__gen_vtable_impl::_S_apply_single_alt): Likewise.
(__gen_vtable_impl::__element_by_index_or_cookie): New. Generate
a __variant_cookie temporary for a variant that is valueless and..
(__gen_vtable_impl::__visit_invoke): ..adjust here.
(__gen_vtable::_Array_type): Conditionally make space for
the __variant_cookie visitor case.
(__variant_construct_by_index): New.
(get_if): Adjust to use std::addressof.
(relops): Adjust to use __do_visit.
(variant): Add __variant_cast and __variant_construct_by_index
as friends.
(variant::emplace): Use _M_reset() and __variant_construct_by_index
instead of self-destruction.
(variant::swap): Adjust to use __do_visit.
(visit): Reimplement in terms of __do_visit.
(__variant_hash_call_base_impl::operator()): Adjust to use __do_visit.
* testsuite/20_util/variant/compile.cc: Adjust.
* testsuite/20_util/variant/run.cc: Likewise.

From-SVN: r269422
2019-03-06 14:56:05 +02:00
Jonathan Wakely 99447f700d Add L suffix to __cpp_lib_char8_t value
* include/bits/c++config.h (_cpp_lib_char8_t): Add L suffix to
	constant.
	* testsuite/experimental/feat-char8_t.cc: Likewise.

From-SVN: r269421
2019-03-06 12:13:19 +00:00
Jonathan Wakely 28d85efbfb Add C++20 Traits for [Un]bounded Arrays (P1357R1)
* include/std/type_traits [C++20] (is_bounded_array)
	 (is_unbounded_array, is_bounded_array_v, is_unbounded_array_v):
	 Define.
	 * testsuite/20_util/is_bounded_array/requirements/
	 explicit_instantiation.cc: New test.
	 * testsuite/20_util/is_bounded_array/requirements/typedefs.cc: New
	 test.
	 * testsuite/20_util/is_bounded_array/value.cc: New test.
	 * testsuite/20_util/is_unbounded_array/requirements/
	 explicit_instantiation.cc: New test.
	 * testsuite/20_util/is_unbounded_array/requirements/typedefs.cc: New
	 * test.
	 * testsuite/20_util/is_unbounded_array/value.cc: New test.

From-SVN: r269420
2019-03-06 12:13:14 +00:00
Jonathan Wakely d80f04d61e Constexpr in std::pointer_traits (P1006R1)
* include/bits/ptr_traits.h [C++20] (pointer_traits<T*>::pointer_to):
	Add constexpr.
	* testsuite/20_util/pointer_traits/pointer_to_constexpr.cc: New test.

From-SVN: r269418
2019-03-06 11:32:42 +00:00
Jonathan Wakely 243874426d Define midpoint and lerp functions for C++20 (P0811R3)
The implementation of midpoint used for integral types is due to Howard
Hinnant and avoids a branch for int and larger types (but not for chars
and shorts).

The midpoint and lerp functions for floating point types come straight
from the P0811R3 proposal, with no attempt at optimization.

	* include/c_compatibility/math.h [C++20] (lerp): Add using
	declaration.
	* include/c_global/cmath [C++20] (__cpp_lib_interpolate): Define.
	(__lerp): Define function template to implement lerp.
	(lerp(float, float, float), lerp(double, double, double))
	(lerp(long double, long double, long double)): Define for C++20.
	* include/std/numeric [C++20] (__cpp_lib_interpolate): Define.
	(midpoint(T, T), midpoint(T*, T*)): Define.
	* include/std::version [C++20] (__cpp_lib_interpolate): Define.
	* testsuite/26_numerics/lerp.cc: New test.
	* testsuite/26_numerics/midpoint/floating.cc: New test.
	* testsuite/26_numerics/midpoint/integral.cc: New test.
	* testsuite/26_numerics/midpoint/pointer.cc: New test.

From-SVN: r269398
2019-03-05 18:37:24 +00:00
Edward Smith-Rowland 94014ee95b PR libstdc++/88996 Implement P0439R0
2019-03-04  Edward Smith-Rowland  <3dw4rd@verizon.net>

	PR libstdc++/88996 Implement P0439R0
	Make std::memory_order a scoped enumeration.
	* include/bits/atomic_base.h: For C++20 make memory_order a scoped enum,
	add variables for the old enumerators.  Adjust calls.
	* testsuite/29_atomics/headers/atomic/types_std_c++2a.cc: New test.
	* testsuite/29_atomics/headers/atomic/types_std_c++2a_neg.cc: New test.

From-SVN: r269372
2019-03-04 20:11:14 +00:00
Jonathan Wakely 7ac40f3d27 Remove redundant dg-do directive from test
* testsuite/26_numerics/bit/bitops.rot/rotl.cc: Remove bogus dg-do
	directive.

From-SVN: r269365
2019-03-04 13:18:47 +00:00
Jonathan Wakely 0e31827300 Implement polymorphic_allocator<byte> for C++20 (P0339R6)
* include/std/memory_resource (polymorphic_allocator): Add default
	template argument for C++20.
	(polymorphic_allocator::allocate_bytes)
	(polymorphic_allocator::deallocate_bytes)
	(polymorphic_allocator::allocate_object)
	(polymorphic_allocator::deallocate_object)
	(polymorphic_allocator::new_object)
	(polymorphic_allocator::delete_object): New member functions for
	C++20.
	* testsuite/20_util/polymorphic_allocator/allocate_object.cc: New
	test.

From-SVN: r269362
2019-03-04 12:21:06 +00:00
Jonathan Wakely c5effe9673 Fix test memory_resource to work without sized deallocation
The checking memory_resource in the testsuite assumes sized deallocation
is supported, which might not be true for other compilers.

	* testsuite/util/testsuite_allocator.h (__gnu_test::memory_resource)
	[!__cpp_sized_deallocation]: Do not pass size to operator delete.

From-SVN: r269312
2019-03-01 13:50:41 +00:00
Jonathan Wakely 987bbe48bb C++2a Utility functions to implement uses-allocator construction (P0591R4)
* include/std/memory (uses_allocator_construction_args): New set of
	overloaded functions.
	(make_obj_using_allocator, uninitialized_construct_using_allocator):
	New functions.
	* include/std/memory_resource (polymorphic_allocator::construct)
	[__cplusplus > 201703l]: Replace all overloads with a single function
	using uses_allocator_construction_args.
	* testsuite/20_util/polymorphic_allocator/construct_c++2a.cc: New
	test.
	* testsuite/20_util/uses_allocator/make_obj.cc: New test.

From-SVN: r269311
2019-03-01 13:50:36 +00:00
Jonathan Wakely a4395a846a PR libstdc++/89466 avoid slow xsltproc command in configure
Certain broken versions of xsltproc ignore the --nonet option and will
attempt to fetch the docbook stylesheet from the WWW when it isn't in
the local XML catalog.

This patch checks for the local stylesheet directory first, and doesn't
use xsltproc if no local stylesheets are found. Checking for the local
directory is done using xmlcatalog if available, only checking the
hardcoded list of directories if xmlcatalog fails. The right directory
for Suse is added to the hardcoded list.

This should avoid doing an xsltproc check that would need to download
the stylesheet, so no network connection is made even if a broken
xsltproc is present.

	PR libstdc++/89466
	* acinclude.m4 (GLIBCXX_CONFIGURE_DOCBOOK): Reorder check for local
	stylesheet directories before check for xsltproc. Try to use
	xmlcatalog to find local stylesheet directory before trying hardcoded
	paths. Add path used by suse to hardcoded paths. Adjust xsltproc
	check to look for the same stylesheet as doc/Makefile.am uses. Don't
	use xsltproc if xmlcatalog fails to find a local stylesheet.
	* configure.ac: Check for xmlcatalog.
	* Makefile.in: Regenerate.
	* configure: Likewise.
	* doc/Makefile.in: Likewise.
	* include/Makefile.in: Likewise.
	* libsupc++/Makefile.in: Likewise.
	* po/Makefile.in: Likewise.
	* python/Makefile.in: Likewise.
	* src/Makefile.in: Likewise.
	* src/c++11/Makefile.in: Likewise.
	* src/c++17/Makefile.in: Likewise.
	* src/c++98/Makefile.in: Likewise.
	* src/filesystem/Makefile.in: Likewise.
	* testsuite/Makefile.in: Likewise.

From-SVN: r269249
2019-02-27 11:25:44 +00:00
Jonathan Wakely 08abbddaaa PR libstdc++/89477 constrain deduction guides for maps and sets
The Compare, Hash, and Pred template parameters should be constrained in
the C++17 deduction guides for associative and unordered containers.

The deduction guides for stack, queue and priority_queue are already
constrained, but this patch makes them use the _RequireNotAllocator
helper instead of reproducing the logic each time.

	PR libstdc++/89477
	* include/bits/alloc_traits.h (_RequireNotAllocator): New helper for
	container deduction guides.
	* include/bits/hashtable.h (_RequireNotAllocatorOrIntegral): Likewise.
	* include/bits/stl_map.h (map): Use _RequireNotAllocator to constrain
	parameters in deduction guides.
	* include/bits/stl_multimap.h (multimap): Likewise.
	* include/bits/stl_multiset.h (multiset): Likewise.
	* include/bits/stl_queue.h (queue, priority_queue): Likewise.
	* include/bits/stl_set.h (set): Likewise.
	* include/bits/stl_stack.h (stack): Likewise.
	* include/bits/unordered_map.h (unordered_map, unordered_multimap):
	use _RequireNotAllocator and _RequireNotAllocatorOrIntegral to
	constrain parameters in deduction guides.
	* include/bits/unordered_set.h (unordered_set, unordered_multiset):
	Likewise.
	* testsuite/23_containers/map/cons/deduction.cc: Test additional
	deduction cases.
	* testsuite/23_containers/multiset/cons/deduction.cc: Likewise.
	* testsuite/23_containers/set/cons/deduction.cc: Likewise.
	* testsuite/23_containers/unordered_map/cons/deduction.cc: Likewise.
	* testsuite/23_containers/unordered_multimap/cons/deduction.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/cons/deduction.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/cons/deduction.cc: Likewise.

From-SVN: r269234
2019-02-26 23:12:44 +00:00
Jonathan Wakely 3c26b7598c P0340R2 Making std::underlying_type SFINAE-friendly
* include/std/type_traits (__underlying_type_impl): New helper to
	make underlying_type SFINAE-friendly.
	(underlying_type): Derive from __underlying_type_impl.
	* testsuite/20_util/underlying_type/requirements/typedefs-3.cc: New
	test.

From-SVN: r269168
2019-02-23 21:19:00 +00:00
Jonathan Wakely ace857f95d PR libstdc++/89446 fix null pointer dereference in char_traits
PR libstdc++/89446
	* include/bits/char_traits.h (__constant_char_array): Check index is
	in range before dereferencing.
	(char_traits<char>::compare, char_traits<char>::find)
	(char_traits<char8_t>::compare, char_traits<char8_t>::find): Return
	immediately if n is zero.
	(char_traits<wchar_t>::compare, char_traits<wchar_t>::find): Likewise.
	Remove workarounds for PR 67026.
	* testsuite/21_strings/basic_string_view/operators/char/89446.cc:
	New test.
	* testsuite/21_strings/basic_string_view/operators/wchar_t/89446.cc:
	New test.

From-SVN: r269148
2019-02-23 03:01:59 +00:00
Jonathan Wakely 148864cb8c Add tests for C++2a content of <atomic> header
* testsuite/29_atomics/headers/atomic/types_std_c++20.cc: New test.
	* testsuite/29_atomics/headers/atomic/types_std_c++20_neg.cc: New
	test.

From-SVN: r269091
2019-02-22 01:16:15 +00:00
Tom Honermann 59019b4223 P0482R5 char8_t: Updates to existing standard library tests
This patch augments existing tests to validate behavior for char8_t.  In
all cases, added test cases are cloned from existing tests for wchar_t
or char16_t.

A few tests required updates to line numbers for diagnostic messages.

2019-02-22  Tom Honermann  <tom@honermann.net>

	* testsuite/18_support/byte/ops.cc: Validate
	std::to_integer<char8_t>, std::to_integer<char16_t>, and
	std::to_integer<char32_t>.
	* testsuite/18_support/numeric_limits/dr559.cc: Validate
	std::numeric_limits<char8_t>.
	* testsuite/18_support/numeric_limits/lowest.cc: Validate
	std::numeric_limits<char8_t>::lowest().
	* testsuite/18_support/numeric_limits/max_digits10.cc: Validate
	std::numeric_limits<char8_t>::max_digits10.
	* testsuite/18_support/type_info/fundamental.cc: Validate
	typeinfo for char8_t.
	* testsuite/20_util/from_chars/1_c++20_neg.cc: New test, validating
	std::from_chars with char8_t.
	* testsuite/20_util/hash/requirements/explicit_instantiation.cc:
	Validate explicit instantiation of std::hash<char8_t>.
	* testsuite/20_util/is_integral/value.cc: Validate
	std::is_integral<char8_t>.
	* testsuite/20_util/make_signed/requirements/typedefs-4.cc:
	Validate std::make_signed<char8_t>.
	* testsuite/21_strings/basic_string/cons/char/deduction.cc:
	Validate u8string construction from char8_t sources.
	* testsuite/21_strings/basic_string/types/pmr_typedefs.cc: Validate
	std::pmr::u8string.
	* testsuite/21_strings/basic_string_view/operations/compare/
	char/70483.cc: Validate substr operations on u8string_view.
	* testsuite/21_strings/basic_string_view/typedefs.cc: Validate that
	the u8string_view typedef is defined.
	* testsuite/21_strings/char_traits/requirements/
	constexpr_functions.cc: Validate char_traits<char8_t> constexpr
	member functions.
	* testsuite/21_strings/char_traits/requirements/
	constexpr_functions_c++17.cc: Validate char_traits<char8_t> C++17
	constexpr member functions.
	* testsuite/21_strings/headers/string/types_std_c++0x.cc: Validate
	that the u8string typedef is defined.
	* testsuite/22_locale/locale/cons/unicode.cc: Validate the presence
	of the std::codecvt<char16_t, char8_t, std::mbstate_t> and
	std::codecvt<char32_t, char8_t, std::mbstate_t> facets.
	* testsuite/29_atomics/atomic/cons/assign_neg.cc: Update line
	numbers.
	* testsuite/29_atomics/atomic/cons/copy_neg.cc: Likewise.
	* testsuite/29_atomics/atomic_integral/cons/assign_neg.cc:
	Likewise.
	* testsuite/29_atomics/atomic_integral/cons/copy_neg.cc: Likewise.
	* testsuite/29_atomics/atomic_integral/is_always_lock_free.cc:
	Validate std::atomic<char8_t>::is_always_lock_free
	* testsuite/29_atomics/atomic_integral/operators/bitwise_neg.cc:
	Update line numbers.
	* testsuite/29_atomics/atomic_integral/operators/decrement_neg.cc:
	Likewise.
	* testsuite/29_atomics/atomic_integral/operators/increment_neg.cc:
	Likewise.
	* testsuite/experimental/polymorphic_allocator/pmr_typedefs_string.cc:
	Validate std::experimental::pmr::u8string.
	* testsuite/experimental/string_view/typedefs.cc: Validate that the
	u8string_view typedef is defined.
	* testsuite/util/testsuite_common_types.h: Add char8_t, char16_t and
	char32_t to the typelists.

From-SVN: r269089
2019-02-22 01:16:08 +00:00
Jonathan Wakely d331c5f10d PR libstdc++/89416 fix __is_move_insertable trait
The common base class for __is_move_insertable and __is_copy_insertable
instantiates both the copy and move tests, when only one is needed. The
unneeded one might cause errors outside the immediate context.

The solution used in this patch is to replace them with alias templates,
which will only be instantiated as needed.

	PR libstdc++/89416
	* include/bits/alloc_traits.h (__is_alloc_insertable_impl): Replace
	class template with class. Replace move and copy member types with
	member alias templates, so they are only instantiated when needed.
	(__is_copy_insertable, __is_move_insertable): Adjust base class.
	* testsuite/23_containers/vector/modifiers/push_back/89130.cc: Enable
	test for C++11/14/17 as well.
	* testsuite/23_containers/vector/modifiers/push_back/89416.cc: New
	test.

From-SVN: r269075
2019-02-21 20:47:43 +00:00
Jonathan Wakely 102a4fe17e Adjust C++11/C++14 tests to work with -fchar8_t
* testsuite/21_strings/basic_string/literals/types.cc
	[_GLIBCXX_USE_CHAR8_T]: Adjust expected string type for u8 literal.
	* testsuite/21_strings/basic_string/literals/values.cc
	[_GLIBCXX_USE_CHAR8_T]: Likewise.
	* testsuite/22_locale/codecvt/char16_t.cc: Adjust for u8 literals
	potentially having different type.
	* testsuite/22_locale/codecvt/char32_t.cc: Likewise.
	* testsuite/22_locale/codecvt/codecvt_utf8/79980.cc: Cast u8 literal
	to char.
	* testsuite/22_locale/codecvt/codecvt_utf8/wchar_t/1.cc: Likewise.
	* testsuite/22_locale/codecvt/utf8.cc: Likewise.
	* testsuite/22_locale/conversions/string/2.cc: Remove u8 prefix from
	string literals only using basic character set.
	* testsuite/22_locale/conversions/string/3.cc: Likewise. Cast other
	u8 literals to char.
	* testsuite/29_atomics/headers/atomic/macros.cc [_GLIBCXX_USE_CHAR8_T]:
	Test ATOMIC_CHAR8_T_LOCK_FREE.
	Add missing #error to ATOMIC_CHAR16_T_LOCK_FREE test.
	* testsuite/29_atomics/headers/atomic/types_std_c++0x.cc
	[_GLIBCXX_USE_CHAR8_T]: Check for std::atomic_char8_t.
	* testsuite/experimental/string_view/literals/types.cc
	[_GLIBCXX_USE_CHAR8_T]: Adjust expected string_view type for u8
	literal.
	* testsuite/experimental/string_view/literals/values.cc
	[_GLIBCXX_USE_CHAR8_T]: Likewise.

From-SVN: r269006
2019-02-19 02:55:12 +00:00
Tom Honermann 46ca1dd73c P0482R5 char8_t: New standard library tests
2019-02-19  Tom Honermann  <tom@honermann.net>

	* testsuite/18_support/numeric_limits/char8_t.cc: New test cloned
	from char16_32_t.cc; validates numeric_limits<char8_t>.
	* testsuite/21_strings/basic_string/literals/types-char8_t.cc: New
	test cloned from types.cc; validates operator""s for char8_t
	returns u8string.
	* testsuite/21_strings/basic_string/literals/values-char8_t.cc: New
	test cloned from values.cc; validates construction and comparison
	of u8string values.
	* testsuite/21_strings/basic_string/requirements/
	/explicit_instantiation/char8_t/1.cc: New test cloned from
	char16_t/1.cc; validates explicit instantiation of
	basic_string<char8_t>.
	* testsuite/21_strings/basic_string_view/literals/types-char8_t.cc:
	New test cloned from types.cc; validates operator""sv for char8_t
	returns u8string_view.
	* testsuite/21_strings/basic_string_view/literals/
	values-char8_t.cc: New test cloned from values.cc; validates
	construction and comparison of u8string_view values.
	* testsuite/21_strings/basic_string_view/requirements/
	explicit_instantiation/char8_t/1.cc: New test cloned from
	char16_t/1.cc; validates explicit instantiation of
	basic_string_view<char8_t>.
	* testsuite/21_strings/char_traits/requirements/char8_t/65049.cc:
	New test cloned from char16_t/65049.cc; validates that
	char_traits<char8_t> is not vulnerable to the concerns in PR65049.
	* testsuite/21_strings/char_traits/requirements/char8_t/
	typedefs.cc: New test cloned from char16_t/typedefs.cc; validates
	that char_traits<char8_t> member typedefs are present and correct.
	* testsuite/21_strings/char_traits/requirements/
	explicit_instantiation/char8_t/1.cc: New test cloned from
	char16_t/1.cc; validates explicit instantiation of
	char_traits<char8_t>.
	* testsuite/22_locale/codecvt/char16_t-char8_t.cc: New test cloned
	from char16_t.cc: validates
	codecvt<char16_t, char8_t, mbstate_t>.
	* testsuite/22_locale/codecvt/char32_t-char8_t.cc: New test cloned
	from char32_t.cc: validates
	codecvt<char32_t, char8_t, mbstate_t>.
	* testsuite/22_locale/codecvt/utf8-char8_t.cc: New test cloned from
	utf8.cc; validates codecvt<char16_t, char8_t, std::mbstate_t> and
	codecvt<char32_t, char8_t, std::mbstate_t>.
	* testsuite/27_io/filesystem/path/native/string-char8_t.cc: New
	test cloned from string.cc; validates filesystem::path construction
	from char8_t input.
	* testsuite/experimental/feat-char8_t.cc: New test; validates that
	the __cpp_lib_char8_t feature test macro is defined with the
	correct value.
	* testsuite/experimental/filesystem/path/native/string-char8_t.cc:
	New test cloned from string.cc; validates filesystem::path
	construction from char8_t input.
	* testsuite/experimental/string_view/literals/types-char8_t.cc: New
	test cloned from types.cc; validates operator""sv for char8_t
	returns u8string_view.
	* testsuite/experimental/string_view/literals/values-char8_t.cc:
	New test cloned from values.cc; validates construction and
	comparison of u8string_view values.
	* testsuite/experimental/string_view/requirements/
	explicit_instantiation/char8_t/1.cc: New test cloned from
	char16_t/1.cc; validates explicit instantiation of
	basic_string_view<char8_t>.
	* testsuite/ext/char8_t/atomic-1.cc: New test; validates that
	ATOMIC_CHAR8_T_LOCK_FREE is not defined if char8_t support is not
	enabled.

From-SVN: r269005
2019-02-19 02:55:05 +00:00
Tom Honermann c124af936b P0482R5 char8_t: Standard library support
gcc/cp:

2019-02-19  Tom Honermann  <tom@honermann.net>

	* name-lookup.c (get_std_name_hint): Added u8string as a name hint.

libstdc++:

2019-02-19  Tom Honermann  <tom@honermann.net>

	P0482R5 char8_t: Standard library support
	* config/abi/pre/gnu-versioned-namespace.ver (CXXABI_2.0): Add
	typeinfo symbols for char8_t.
	* config/abi/pre/gnu.ver: Add CXXABI_1.3.12.
	(GLIBCXX_3.4.26): Add symbols for specializations of
	numeric_limits and codecvt that involve char8_t.
	(CXXABI_1.3.12): Add typeinfo symbols for char8_t.
	* include/bits/atomic_base.h: Add atomic_char8_t.
	* include/bits/basic_string.h: Add std::hash<u8string> and
	operator""s(const char8_t*, size_t).
	* include/bits/c++config: Define _GLIBCXX_USE_CHAR8_T and
	__cpp_lib_char8_t.
	* include/bits/char_traits.h: Add char_traits<char8_t>.
	* include/bits/codecvt.h: Add
	codecvt<char16_t, char8_t, mbstate_t>,
	codecvt<char32_t, char8_t, mbstate_t>,
	codecvt_byname<char16_t, char8_t, mbstate_t>, and
	codecvt_byname<char32_t, char8_t, mbstate_t>.
	* include/bits/cpp_type_traits.h: Add __is_integer<char8_t> to
	recognize char8_t as an integral type.
	* include/bits/fs_path.h: (path::__is_encoded_char): Recognize
	char8_t.
	(path::u8string): Return std::u8string when char8_t support is
	enabled.
	(path::generic_u8string): Likewise.
	(path::_S_convert): Handle conversion from char8_t input.
	(path::_S_str_convert): Likewise.
	* include/bits/functional_hash.h: Add hash<char8_t>.
	* include/bits/locale_conv.h (__str_codecvt_out): Add overloads for
	char8_t.
	* include/bits/locale_facets.h (_GLIBCXX_NUM_UNICODE_FACETS): Bump
	for new char8_t specializations.
	* include/bits/localefwd.h: Add missing declarations of
	codecvt<char16_t, char, mbstate_t> and
	codecvt<char32_t, char, mbstate_t>.  Add char8_t declarations
	codecvt<char16_t, char8_t, mbstate_t> and
	codecvt<char32_t, char8_t, mbstate_t>.
	* include/bits/postypes.h: Add u8streampos
	* include/bits/stringfwd.h: Add declarations of
	char_traits<char8_t> and u8string.
	* include/c_global/cstddef: Add __byte_operand<char8_t>.
	* include/experimental/bits/fs_path.h (path::__is_encoded_char):
	Recognize char8_t.
	(path::u8string): Return std::u8string when char8_t support is
	enabled.
	(path::generic_u8string): Likewise.
	(path::_S_convert): Handle conversion from char8_t input.
	(path::_S_str_convert): Likewise.
	* include/experimental/string: Add u8string.
	* include/experimental/string_view: Add u8string_view,
	hash<experimental::u8string_view>, and
	operator""sv(const char8_t*, size_t).
	* include/std/atomic: Add atomic<char8_t> and atomic_char8_t.
	* include/std/charconv (__is_int_to_chars_type): Recognize char8_t
	as a character type.
	* include/std/limits: Add numeric_limits<char8_t>.
	* include/std/string_view: Add u8string_view,
	hash<experimental::u8string_view>, and
	operator""sv(const char8_t*, size_t).
	* include/std/type_traits: Add __is_integral_helper<char8_t>,
	__make_unsigned<char8_t>, and __make_signed<char8_t>.
	* libsupc++/atomic_lockfree_defines.h: Define
	ATOMIC_CHAR8_T_LOCK_FREE.
	* src/c++11/Makefile.am: Compile with -fchar8_t when compiling
	codecvt.cc and limits.cc so that char8_t specializations of
	numeric_limits and codecvt and emitted.
	* src/c++11/Makefile.in: Likewise.
	* src/c++11/codecvt.cc: Define members of
	codecvt<char16_t, char8_t, mbstate_t>,
	codecvt<char32_t, char8_t, mbstate_t>,
	codecvt_byname<char16_t, char8_t, mbstate_t>, and
	codecvt_byname<char32_t, char8_t, mbstate_t>.
	* src/c++11/limits.cc: Define members of
	numeric_limits<char8_t>.
	* src/c++98/Makefile.am: Compile with -fchar8_t when compiling
	locale_init.cc and localename.cc.
	* src/c++98/Makefile.in: Likewise.
	* src/c++98/locale_init.cc: Add initialization for the
	codecvt<char16_t, char8_t, mbstate_t> and
	codecvt<char32_t, char8_t, mbstate_t> facets.
	* src/c++98/localename.cc: Likewise.
	* testsuite/util/testsuite_abi.cc: Validate ABI bump.

From-SVN: r269004
2019-02-19 02:54:42 +00:00
Wilco Dijkstra eb8c4926c5 Fix libstdc++ filesystem tests
Some recently added libstdc++ filesystem tests are missing a
dg-require-filesystem-ts.

Committed as obvious.

    libstdc++/testsuite/
	* 27_io/filesystem/operations/all.cc: Add dg-require-filesystem-ts.
	* 27_io/filesystem/operations/resize_file.cc: Likewise.
	* 27_io/filesystem/path/generation/normal2.cc: Likewise.

From-SVN: r268989
2019-02-18 14:09:17 +00:00
Jonathan Wakely b7dbc6723a DR 2586 fix value category in uses-allocator checks
Because uses-allocator construction is invariably done with a const
lvalue the __uses_alloc helper should use a const lvalue for the
is_constructible checks. Otherwise, it can detect that the type can be
constructed from an rvalue, and then an error happens when a const
lvalue is passed to the constructor instead.

Prior to LWG DR 2586 scoped_allocator_adaptor incorrectly used an rvalue
type in the is_constructible check and then used a non-const lvalue for
the actual construction. The other components using uses-allocator
construction (tuple and polymorphic_allocator) have always done so with
a const lvalue allocator, although the use of __use_alloc in our
implementation meant they behaved the same as scoped_allocator_adaptor
and incorrectly used rvalues for the is_constructible checks.

In C++20 the P0591R4 changes mean that all uses-allocator construction
is defined in terms of the new uses_allocator_construction_args
functions, which always use a const lvalue allocator.

The changes in this patch ensure that the __use_alloc helper correctly
matches the requirements in the standard, consistently using a const
lvalue allocator for the is_constructible checks and the actual
constructor arguments.

	* doc/xml/manual/intro.xml: Document LWG 2586 status.
	* include/bits/uses_allocator.h (__uses_alloc): Use const lvalue
	allocator type in is_constructible checks.
	* testsuite/20_util/scoped_allocator/69293_neg.cc: Adjust dg-error.
	* testsuite/20_util/scoped_allocator/dr2586.cc: New test.
	* testsuite/20_util/tuple/cons/allocators.cc: Add test using
	problematic type from LWG 2586 discussion.
	* testsuite/20_util/uses_allocator/69293_neg.cc: Adjust dg-error.
	* testsuite/20_util/uses_allocator/cons_neg.cc: Likewise.

From-SVN: r268882
2019-02-14 15:08:33 +00:00
Jonathan Wakely 1f4dcbf7cd LWG 2537 fix priority_queue constructors to establish invariant
This change is safe to make now (in stage 4), because the constructors
are currently incorrect and unusable (unless the supplied container
already contains a heap, in which case the new make_heap calls are
redundant but harmless).

	* doc/xml/manual/intro.xml: Document LWG 2537 status.
	* include/bits/stl_queue.h
	(priority_queue(const Compare&, const Container&, const Alloc&))
	(priority_queue(const Compare&, Container&&, const Alloc&)): Call
	make_heap.
	* testsuite/23_containers/priority_queue/dr2537.cc: New test.

From-SVN: r268878
2019-02-14 14:10:19 +00:00
Jonathan Wakely 133342f061 PR middle-end/89303 add testcase for std::enable_shared_from_this
* testsuite/20_util/enable_shared_from_this/89303.cc: New test.

From-SVN: r268869
2019-02-14 09:40:02 +00:00