Commit Graph

313 Commits

Author SHA1 Message Date
Jonathan Wakely 3c21913415 libstdc++: Optimise GCD algorithms
The current std::gcd and std::chrono::duration::_S_gcd algorithms are
both recursive. This is potentially expensive to evaluate in constant
expressions, because each level of recursion makes a new copy of the
function to evaluate. The maximum number of steps is bounded
(proportional to the number of decimal digits in the smaller value) and
so unlikely to exceed the limit for constexpr nesting, but the memory
usage is still suboptimal. By using an iterative algorithm we avoid
that compile-time cost. Because looping in constexpr functions is not
allowed until C++14, we need to keep the recursive implementation in
duration::_S_gcd for C++11 mode.

For std::gcd we can also optimise runtime performance by using the
binary GCD algorithm.

libstdc++-v3/ChangeLog:

	* include/std/chrono (duration::_S_gcd): Use iterative algorithm
	for C++14 and later.
	* include/std/numeric (__detail::__gcd): Replace recursive
	Euclidean algorithm with iterative version of binary GCD algorithm.
	* testsuite/26_numerics/gcd/1.cc: Test additional inputs.
	* testsuite/26_numerics/gcd/gcd_neg.cc: Adjust dg-error lines.
	* testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.
	* testsuite/experimental/numeric/gcd.cc: Test additional inputs.
	* testsuite/26_numerics/gcd/2.cc: New test.
2020-09-03 12:46:13 +01:00
Jonathan Wakely 0789600c59 libstdc++: Fix deleted overload of __absu(bool)
libstdc++-v3/ChangeLog:

	* include/std/numeric (__detail::__absu(bool)): Make deleted
	function a function template, so it will be chosen for calls
	with an explicit template argument list.
	* testsuite/26_numerics/gcd/gcd_neg.cc: Add dg-prune-output.
	* testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.
2020-08-29 18:24:08 +01:00
Jonathan Wakely 82db1a42e9 libstdc++: Fix std::gcd and std::lcm for unsigned integers [PR 92978]
This fixes a bug with mixed signed and unsigned types, where converting
a negative value to the unsigned result type alters the value. The
solution is to obtain the absolute values of the arguments immediately
and to perform the actual GCD or LCM algorithm on two arguments of the
same type.

In order to operate on the most negative number without overflow when
taking its absolute, use an unsigned type for the result of the abs
operation. For example, -INT_MIN will overflow, but -(unsigned)INT_MIN
is (unsigned)INT_MAX+1U which is the correct value.

libstdc++-v3/ChangeLog:

	PR libstdc++/92978
	* include/std/numeric (__abs_integral): Replace with ...
	(__detail::__absu): New function template that returns an
	unsigned type, guaranteeing it can represent the most
	negative signed value.
	(__detail::__gcd, __detail::__lcm): Require arguments to
	be unsigned and therefore already non-negative.
	(gcd, lcm): Convert arguments to absolute value as unsigned
	type before calling __detail::__gcd or __detail::__lcm.
	* include/experimental/numeric (gcd, lcm): Likewise.
	* testsuite/26_numerics/gcd/gcd_neg.cc: Adjust expected
	errors.
	* testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.
	* testsuite/26_numerics/gcd/92978.cc: New test.
	* testsuite/26_numerics/lcm/92978.cc: New test.
	* testsuite/experimental/numeric/92978.cc: New test.
2020-08-28 23:03:28 +01:00
Jonathan Wakely dc8c00966e libstdc++: Avoid using __float128 in strict modes
libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/numbers/float128.cc: Check
	__STRICT_ANSI__ before using __float128.
	* testsuite/std/concepts/concepts.lang/concept.arithmetic/floating_point.cc:
	Likewise.
2020-07-31 19:58:03 +01:00
Jonathan Wakely 566f422734 libstdc++: Use c++NN_only effective target to tests
Some tests really are only intended for a specific -std mode, so add a
target selector to make that explicit.

Also reorder the dg-do directives to come after the dg-options ones, so
that the target selector in the dg-do directive is applied after the
dg-options that sets the -std option.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/reference_wrapper/83427.cc: Adjust
	effective-target to specific language mode only.
	* testsuite/24_iterators/headers/iterator/range_access_c++11.cc:
	Likewise.
	* testsuite/24_iterators/headers/iterator/range_access_c++14.cc:
	Likewise.
	* testsuite/24_iterators/headers/iterator/synopsis_c++11.cc:
	Likewise.
	* testsuite/24_iterators/headers/iterator/synopsis_c++14.cc:
	Likewise.
	* testsuite/26_numerics/valarray/69116.cc:
	Likewise.
	* testsuite/30_threads/headers/condition_variable/std_c++0x_neg.cc:
	Remove whitespace at end of file.
	* testsuite/30_threads/headers/future/std_c++0x_neg.cc:
	Likewise.
2020-07-31 19:58:02 +01:00
Jonathan Wakely 6458742a15 libstdc++: Ensure c++NN effective target present in all C++17 tests
Also reorder some directives so that the dg-options setting -std=gnu++17
comes before the dg-do that requires c++17.

libstdc++-v3/ChangeLog:

	* testsuite/17_intro/headers/c++2017/all_attributes.cc: Add
	c++17 effective-target.
	* testsuite/17_intro/headers/c++2017/all_no_exceptions.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2017/all_no_rtti.cc: Likewise.
	* testsuite/17_intro/headers/c++2017/all_pedantic_errors.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2017/operator_names.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2017/stdc++.cc: Likewise.
	* testsuite/17_intro/headers/c++2017/stdc++_multiple_inclusion.cc:
	Likewise.
	* testsuite/18_support/uncaught_exceptions/uncaught_exceptions.cc:
	Likewise.
	* testsuite/19_diagnostics/error_code/is_error_code_v.cc:
	Likewise.
	* testsuite/20_util/any/assign/1.cc: Likewise.
	* testsuite/20_util/any/assign/2.cc: Likewise.
	* testsuite/20_util/any/assign/emplace.cc: Likewise.
	* testsuite/20_util/any/assign/exception.cc: Likewise.
	* testsuite/20_util/any/assign/self.cc: Likewise.
	* testsuite/20_util/any/cons/1.cc: Likewise.
	* testsuite/20_util/any/cons/2.cc: Likewise.
	* testsuite/20_util/any/cons/aligned.cc: Likewise.
	* testsuite/20_util/any/cons/explicit.cc: Likewise.
	* testsuite/20_util/any/cons/in_place.cc: Likewise.
	* testsuite/20_util/any/cons/nontrivial.cc: Likewise.
	* testsuite/20_util/any/make_any.cc: Likewise.
	* testsuite/20_util/any/misc/any_cast.cc: Likewise.
	* testsuite/20_util/any/misc/any_cast_no_rtti.cc: Likewise.
	* testsuite/20_util/any/misc/swap.cc: Likewise.
	* testsuite/20_util/any/modifiers/1.cc: Likewise.
	* testsuite/20_util/any/observers/type.cc: Likewise.
	* testsuite/20_util/any/requirements.cc: Likewise.
	* testsuite/20_util/any/typedefs.cc: Likewise.
	* testsuite/20_util/as_const/1.cc: Likewise.
	* testsuite/20_util/as_const/rvalue_neg.cc: Likewise.
	* testsuite/20_util/bind/is_placeholder_v.cc: Likewise.
	* testsuite/20_util/bool_constant/requirements.cc: Likewise.
	* testsuite/20_util/duration/requirements/treat_as_floating_point_v.cc:
	Likewise.
	* testsuite/20_util/duration_cast/rounding.cc: Likewise.
	* testsuite/20_util/enable_shared_from_this/members/weak_from_this.cc:
	Likewise.
	* testsuite/20_util/function_objects/invoke/59768.cc: Likewise.
	* testsuite/20_util/function_objects/not_fn/1.cc: Likewise.
	* testsuite/20_util/function_objects/searchers.cc: Likewise.
	* testsuite/20_util/in_place/requirements.cc: Likewise.
	* testsuite/20_util/is_invocable/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_invocable/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_invocable/value.cc: Likewise.
	* testsuite/20_util/is_nothrow_invocable/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_invocable/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_swappable/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_swappable/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_swappable/value.cc: Likewise.
	* testsuite/20_util/is_nothrow_swappable_with/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_swappable_with/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_swappable_with/value.cc:
	Likewise.
	* testsuite/20_util/is_swappable/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_swappable/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_swappable/value.cc: Likewise.
	* testsuite/20_util/is_swappable_with/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_swappable_with/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_swappable_with/value.cc: Likewise.
	* testsuite/20_util/logical_traits/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/logical_traits/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/logical_traits/value.cc: Likewise.
	* testsuite/20_util/optional/constexpr/make_optional.cc: Likewise.
	* testsuite/20_util/optional/constexpr/observers/2.cc: Likewise.
	* testsuite/20_util/optional/constexpr/observers/3.cc: Likewise.
	* testsuite/20_util/optional/hash.cc: Likewise.
	* testsuite/20_util/pair/swap_cxx17.cc: Likewise.
	* testsuite/20_util/ratio/requirements/ratio_equal_v.cc: Likewise.
	* testsuite/20_util/shared_ptr/requirements/weak_type.cc:
	Likewise.
	* testsuite/20_util/specialized_algorithms/memory_management_tools/1.cc:
	Likewise.
	* testsuite/20_util/tuple/apply/1.cc: Likewise.
	* testsuite/20_util/tuple/make_from_tuple/1.cc: Likewise.
	* testsuite/20_util/tuple/swap_cxx17.cc: Likewise.
	* testsuite/20_util/tuple/tuple_size_v.cc: Likewise.
	* testsuite/20_util/unique_ptr/specialized_algorithms/swap_cxx17.cc:
	Likewise.
	* testsuite/20_util/uses_allocator/requirements/uses_allocator_v.cc:
	Likewise.
	* testsuite/20_util/variant/any.cc: Likewise.
	* testsuite/20_util/variant/compile.cc: Likewise.
	* testsuite/20_util/variant/hash.cc: Likewise.
	* testsuite/20_util/variant/index_type.cc: Likewise.
	* testsuite/20_util/variant/run.cc: Likewise.
	* testsuite/20_util/void_t/1.cc: Likewise.
	* testsuite/21_strings/basic_string/79162.cc: Likewise.
	* testsuite/21_strings/basic_string/cons/char/7.cc: Likewise.
	* testsuite/21_strings/basic_string/cons/wchar_t/7.cc: Likewise.
	* testsuite/21_strings/basic_string/lwg2758.cc: Likewise.
	* testsuite/21_strings/basic_string/lwg2946.cc: Likewise.
	* testsuite/21_strings/basic_string/modifiers/append/char/4.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/append/wchar_t/4.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/assign/char/4.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/assign/wchar_t/4.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/insert/char/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/insert/wchar_t/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/replace/char/7.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/replace/wchar_t/7.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/compare/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/compare/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/data/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/data/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/find/char/5.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/find/wchar_t/5.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operators/char/5.cc: Likewise.
	* testsuite/21_strings/basic_string/operators/wchar_t/5.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/capacity/1.cc: Likewise.
	* testsuite/21_strings/basic_string_view/cons/char/1.cc: Likewise.
	* testsuite/21_strings/basic_string_view/cons/char/2.cc: Likewise.
	* testsuite/21_strings/basic_string_view/cons/char/3.cc: Likewise.
	* testsuite/21_strings/basic_string_view/cons/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/cons/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/cons/wchar_t/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/empty.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/front_back.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/empty.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/front_back.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/include.cc: Likewise.
	* testsuite/21_strings/basic_string_view/inserters/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/char/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/pod/10081-out.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/wchar_t/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/literals/types-char8_t.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/literals/types.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/literals/values-char8_t.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/literals/values.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/compare/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/compare/char/13650.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/compare/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/compare/wchar_t/13650.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/copy/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/copy/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/data/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/data/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/char/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/char/4.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/wchar_t/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/wchar_t/4.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/char/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/wchar_t/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/string_conversion/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/substr/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/substr/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/range_access/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/range_access/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char8_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/typedefs.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/typedefs.cc: Likewise.
	* testsuite/21_strings/basic_string_view/types/1.cc: Likewise.
	* testsuite/23_containers/array/specialized_algorithms/swap_cxx17.cc:
	Likewise.
	* testsuite/23_containers/map/modifiers/extract.cc: Likewise.
	* testsuite/23_containers/map/modifiers/insert_or_assign/1.cc:
	Likewise.
	* testsuite/23_containers/map/modifiers/merge.cc: Likewise.
	* testsuite/23_containers/map/modifiers/try_emplace/1.cc: Likewise.
	* testsuite/23_containers/multimap/modifiers/extract.cc: Likewise.
	* testsuite/23_containers/multimap/modifiers/merge.cc: Likewise.
	* testsuite/23_containers/multiset/modifiers/extract.cc: Likewise.
	* testsuite/23_containers/multiset/modifiers/merge.cc: Likewise.
	* testsuite/23_containers/set/modifiers/extract.cc: Likewise.
	* testsuite/23_containers/set/modifiers/merge.cc: Likewise.
	* testsuite/23_containers/unordered_map/modifiers/extract.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/modifiers/insert_or_assign.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/modifiers/merge.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/modifiers/try_emplace.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/modifiers/extract.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/modifiers/merge.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/modifiers/extract.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/modifiers/merge.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/modifiers/extract.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/modifiers/merge.cc:
	Likewise.
	* testsuite/24_iterators/headers/iterator/range_access_c++17.cc:
	Likewise.
	* testsuite/24_iterators/headers/iterator/synopsis_c++17.cc:
	Likewise.
	* testsuite/25_algorithms/clamp/1.cc: Likewise.
	* testsuite/25_algorithms/clamp/2.cc: Likewise.
	* testsuite/25_algorithms/clamp/constexpr.cc: Likewise.
	* testsuite/25_algorithms/clamp/requirements/explicit_instantiation/1.cc:
	Likewise.
	* testsuite/25_algorithms/clamp/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/26_numerics/headers/cmath/functions_std_c++17.cc:
	Likewise.
	* testsuite/26_numerics/headers/cmath/special_functions_global.cc:
	Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/char/lwg2221.cc:
	Likewise.
	* testsuite/29_atomics/atomic/is_always_lock_free.cc: Likewise.
	* testsuite/29_atomics/atomic_integral/is_always_lock_free.cc:
	Likewise.
	* testsuite/30_threads/shared_lock/70766.cc: Likewise.
	* testsuite/30_threads/shared_mutex/cons/1.cc: Likewise.
	* testsuite/30_threads/shared_mutex/cons/assign_neg.cc:
	Likewise.
	* testsuite/30_threads/shared_mutex/cons/copy_neg.cc:
	Likewise.
	* testsuite/30_threads/shared_mutex/requirements/standard_layout.cc:
	Likewise.
	* testsuite/30_threads/shared_mutex/try_lock/1.cc: Likewise.
	* testsuite/30_threads/shared_mutex/try_lock/2.cc: Likewise.
	* testsuite/30_threads/shared_mutex/unlock/1.cc: Likewise.
2020-07-31 19:58:02 +01:00
Jonathan Wakely b857b17977 libstdc++: Require c++98_only effective target for some tests
These tests verify that including C++11 headers fails to compile in
C++98 mode. They use { dg-options "-std=gnu++98" } so that they are
explicitly run in C++98 mode. This change also adds a target selector so
that the tests will be skipped even if the dg-options directive is
filtered out or overridden. This is in preparation for a desired future
change where tests do not use -std options, so that they can be tested
with e.g. --target_board=unix\"{-std=gnu++17,-std=gnu++20}\"

In some cases the dg-options and dg-do directives need to be reordered,
so that the -std=gnu++98 option is already added to the options before
the target selector is checked.

libstdc++-v3/ChangeLog:

	* testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc: Add
	c++98_only target selector.
	* testsuite/18_support/headers/cstdbool/std_c++0x_neg.cc:
	Likewise.
	* testsuite/18_support/headers/cstdint/std_c++0x_neg.cc:
	Likewise.
	* testsuite/18_support/headers/new/synopsis_cxx98.cc: Likewise.
	* testsuite/19_diagnostics/headers/system_error/std_c++0x_neg.cc:
	Likewise.
	* testsuite/20_util/headers/type_traits/std_c++0x_neg.cc:
	Likewise.
	* testsuite/23_containers/headers/array/std_c++0x_neg.cc:
	Likewise.
	* testsuite/23_containers/headers/tuple/std_c++0x_neg.cc:
	Likewise.
	* testsuite/23_containers/headers/unordered_map/std_c++0x_neg.cc:
	Likewise.
	* testsuite/23_containers/headers/unordered_set/std_c++0x_neg.cc:
	Likewise.
	* testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc:
	Likewise.
	* testsuite/26_numerics/headers/cfenv/std_c++0x_neg.cc:
	Likewise.
	* testsuite/26_numerics/headers/cmath/c99_classification_macros_c++98.cc:
	Likewise.
	* testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc:
	Likewise.
	* testsuite/26_numerics/headers/random/std_c++0x_neg.cc:
	Likewise.
	* testsuite/27_io/headers/cinttypes/std_c++0x_neg.cc: Likewise.
	* testsuite/28_regex/headers/regex/std_c++0x_neg.cc: Likewise.
	* testsuite/29_atomics/headers/atomic/std_c++0x_neg.cc:
	Likewise.
	* testsuite/30_threads/headers/condition_variable/std_c++0x_neg.cc:
	Likewise.
	* testsuite/30_threads/headers/future/std_c++0x_neg.cc:
	Likewise.
	* testsuite/30_threads/headers/mutex/std_c++0x_neg.cc: Likewise.
	* testsuite/30_threads/headers/thread/std_c++0x_neg.cc:
	Likewise.
2020-07-02 21:27:12 +01:00
Jonathan Wakely a2d196e75c libstdc++: Use RDRAND as fallback if RDSEED keeps failing (PR 94087)
It's not difficult for multiple threads to drain the entropy available
to the RDSEED instruction, at which point we throw an exception. This
change will try to use RDRAND after RDSEED fails repeatedly, and only
throw if RDRAND also fails repeatedly. This doesn't guarantee a random
value can always be read, but reduces the likelihood of failure when
using the RDSEED instruction.

	PR libstdc++/94087
	* src/c++11/random.cc (__x86_rdseed): Allow fallback function to be
	passed in.
	(__x86_rdseed_rdrand): New function that uses rdseed with rdrand
	fallback.
	(random_device::_M_init): Use __x86_rdseed_rdrand when both
	instructions are available.
	* testsuite/26_numerics/random/random_device/94087.cc: New test.
2020-05-19 23:04:45 +01:00
Jonathan Wakely ef389dadd4 libstdc++: Add comparison operators to types from Numerics clause
Some more C++20 changes from P1614R2, "The Mothership has Landed".

	* include/bits/slice_array.h (operator==(const slice&, const slice&)):
	Define for C++20.
	* include/std/complex (operator==(const T&, const complex<T>&))
	(operator!=(const complex<T>&, const complex<T>&))
	(operator!=(const complex<T>&, const T&))
	(operator!=(const T&, const complex<T>&)): Do not declare for C++20.
	* testsuite/26_numerics/slice/compare.cc: New test.
2020-04-08 16:51:59 +01:00
Patrick Palka 799270b430 libstdc++: Update the <numeric> synopsis test to latest standard
Tested with

  make check RUNTESTFLAGS="conformance.exp=*numeric*synopsis* --target_board=unix/-std=$std"

for std in {c++98, c++11, c++17, c++2a}.

libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/headers/numeric/synopsis.cc: Add signatures for
	functions introduced in C++11, C++17 and C++2a.  Add 'constexpr' to
	existing signatures for C++2a.
2020-02-28 15:08:14 -05:00
Patrick Palka fd33598558 libstdc++: P1645R1 constexpr for <numeric> algorithms
This adds constexpr to 11 algorithms defined in <numeric> as per P1645R1.

libstdc++-v3/ChangeLog:

	P1645R1 constexpr for <numeric> algorithms
	* include/bits/stl_numeric.h (iota, accumulate, inner_product,
	partial_sum, adjacent_difference): Make conditionally constexpr for
	C++20.
	* include/std/numeric (__cpp_lib_constexpr_numeric): Define this feature
	test macro.
	(reduce, transform_reduce, exclusive_scan, inclusive_scan,
	transform_exclusive_scan, transform_inclusive_scan): Make conditionally
	constexpr for C++20.
	* include/std/version (__cpp_lib_constexpr_numeric): Define.
	* testsuite/26_numerics/accumulate/constexpr.cc: New test.
	* testsuite/26_numerics/adjacent_difference/constexpr.cc: Likewise.
	* testsuite/26_numerics/exclusive_scan/constexpr.cc: Likewise.
	* testsuite/26_numerics/inclusive_scan/constexpr.cc: Likewise.
	* testsuite/26_numerics/inner_product/constexpr.cc: Likewise.
	* testsuite/26_numerics/iota/constexpr.cc: Likewise.
	* testsuite/26_numerics/partial_sum/constexpr.cc: Likewise.
	* testsuite/26_numerics/reduce/constexpr.cc: Likewise.
	* testsuite/26_numerics/transform_exclusive_scan/constexpr.cc: Likewise.
	* testsuite/26_numerics/transform_inclusive_scan/constexpr.cc: Likewise.
	* testsuite/26_numerics/transform_reduce/constexpr.cc: Likewise.
2020-02-26 10:23:17 -05:00
Jonathan Wakely 5f031f9747 libstdc++: midpoint should not constrain T is complete (LWG 3200)
* include/std/numeric (midpoint(T8, T*)): Do not check for complete
	type during overload resolution, use static assert instead (LWG 3200).
	* testsuite/26_numerics/midpoint/pointer.cc: Do not test with
	incomplete type.
	* testsuite/26_numerics/midpoint/pointer_neg.cc: New test.
2020-02-19 15:28:45 +00:00
Jonathan Wakely 9866abe31e libstdc++ P1956R1 On the names of low-level bit manipulation functions
Implement this change for C++20 that was just approved in Prague.

	P1956R1 On the names of low-level bit manipulation functions
	* include/bits/hashtable_policy.h: Update comment.
	* include/std/bit (__ispow2, __ceil2, __floor2, __log2p1): Rename.
	(ispow2, ceil2, floor2, log2p1): Likewise.
	(__cpp_lib_int_pow2): Add feature test macro.
	* include/std/charconv (__to_chars_len_2): Adjust use of __log2p1.
	* include/std/memory (assume_aligned): Adjust use of ispow2.
	* include/std/version (__cpp_lib_int_pow2): Add.
	* libsupc++/new_opa.cc: Adjust use of __ispow2.
	* src/c++17/memory_resource.cc: Likewise, and for __ceil2 and __log2p1.
	* testsuite/17_intro/freestanding.cc: Adjust use of ispow2.
	* testsuite/26_numerics/bit/bit.pow.two/ceil2.cc: Rename to ...
	* testsuite/26_numerics/bit/bit.pow.two/bit_ceil.cc: ... here.
	* testsuite/26_numerics/bit/bit.pow.two/ceil2_neg.cc: Rename to ...
	* testsuite/26_numerics/bit/bit.pow.two/bit_ceil_neg.cc: ... here.
	* testsuite/26_numerics/bit/bit.pow.two/floor2.cc: Rename to ...
	* testsuite/26_numerics/bit/bit.pow.two/bit_floor.cc: ... here.
	* testsuite/26_numerics/bit/bit.pow.two/log2p1.cc: Rename to ...
	* testsuite/26_numerics/bit/bit.pow.two/bit_width.cc: ... here.
	* testsuite/26_numerics/bit/bit.pow.two/ispow2.cc: Rename to ...
	* testsuite/26_numerics/bit/bit.pow.two/has_single_bit.cc: ... here.
2020-02-17 17:09:18 +00:00
Jonathan Wakely 9cd4eeefcc libstdc++: Reduce header dependencies for C++20 (PR 92546)
In C++20 <memory> depends on <bits/ranges_unitialized.h> which
depends on <bits/random.h> just for a single concept. Including
<bits/random.h> also requires including <cmath>, which is huge due to
the C++17 special functions.

This change moves the concept to the <bits/uniform_int_dist.h> internal
header that exists so that <bits/stl_algobase.h> doesn't need to include
<bits/random.h>.

	PR libstdc++/92546 (partial)
	* include/bits/random.h (uniform_random_bit_generator): Move definition
	to <bits/uniform_int_dist.h>.
	* include/bits/ranges_algo.h: Include <bits/uniform_int_dist.h> instead
	of <bits/random.h>.
	* include/bits/ranges_algobase.h: Do not include <cmath>.
	* include/bits/uniform_int_dist.h (uniform_random_bit_generator):
	Move here.
	* include/std/ranges: Do not include <limits>.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error lineno.
2020-02-17 15:43:43 +00:00
Jonathan Wakely c03b53da91 libstdc++: Add lightweight replacement for std::numeric_limits (PR 92546)
Many uses of std::numeric_limits in C++17 and C++20 features only really
need the min(), max() and digits constants for integral types. By adding
__detail::__int_limits we can avoid including the whole <limits> header.

The <limits> header isn't especially large, but avoiding it still gives
small savings in compilation time and memory usage for the compiler.

There are also C++11 features that could benefit from this change (e.g.
<bits/hashtable_policy.h> and <bits/uniform_int_dist.h>) but I won't
change those until stage 1.

The implementation of __int_limits assumes two's complement integers,
which is true for all targets supported by GCC.

	PR libstdc++/92546 (partial)
	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/int_limits.h: New header.
	* include/bits/parse_numbers.h (__select_int::_Select_int): Replace
	numeric_limits with __detail::__int_limits.
	* include/std/bit (__rotl, __rotr, __countl_zero, __countl_one)
	(__countr_zero, __countr_one, __popcount, __ceil2, __floor2, __log2p1):
	Likewise.
	* include/std/charconv (__to_chars_8, __from_chars_binary)
	(__from_chars_alpha_to_num, from_chars): Likewise.
	* include/std/memory_resource (polymorphic_allocator::allocate)
	(polymorphic_allocator::allocate_object): Likewise.
	* include/std/string_view (basic_string_view::_S_compare): Likewise.
	* include/std/utility (in_range): Likewise.
	* testsuite/20_util/integer_comparisons/in_range_neg.cc: Adjust for
	extra error about incomplete type __int_limits<bool>.
	* testsuite/26_numerics/bit/bit.count/countl_one.cc: Include <limits>.
	* testsuite/26_numerics/bit/bit.count/countl_zero.cc: Likewise.
	* testsuite/26_numerics/bit/bit.count/countr_one.cc: Likewise.
	* testsuite/26_numerics/bit/bit.count/countr_zero.cc: Likewise.
	* testsuite/26_numerics/bit/bit.count/popcount.cc: Likewise.
	* testsuite/26_numerics/bit/bit.pow.two/ceil2_neg.cc: Likewise.
	* testsuite/26_numerics/bit/bit.pow.two/ceil2.cc: Likewise.
	* testsuite/26_numerics/bit/bit.pow.two/floor2.cc: Likewise.
	* testsuite/26_numerics/bit/bit.pow.two/ispow2.cc: Likewise.
	* testsuite/26_numerics/bit/bit.pow.two/log2p1.cc: Likewise.
	* testsuite/26_numerics/bit/bit.rotate/rotl.cc: Likewise.
	* testsuite/26_numerics/bit/bit.rotate/rotr.cc: Likewise.
2020-02-17 15:11:04 +00:00
Jonathan Wakely 5b1d588509 libstdc++: Implement LWG 3150 for std::uniform_random_bit_generator
* include/bits/random.h (uniform_random_bit_generator): Require min()
	and max() to be constant expressions and min() to be less than max().
	* testsuite/26_numerics/random/concept.cc: Check additional cases.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error lineno.
2020-02-15 10:24:57 +00:00
Jonathan Wakely 160e95dc3d libstdc++: Fix undefined behaviour in random dist serialization (PR93205)
The deserialization functions for random number distributions fail to
check the stream state before using the extracted values. In some cases
this leads to using indeterminate values to resize a vector, and then
filling that vector with indeterminate values.

No values that affect control flow should be used without checking that a
good value was read from the stream.

Additionally, where reasonable to do so, defer modifying any state in
the distribution until all values have been successfully read, to avoid
modifying some of the distribution's parameters and leaving others
unchanged.

	PR libstdc++/93205
	* include/bits/random.h (operator>>): Check stream operation succeeds.
	* include/bits/random.tcc (operator<<): Remove redundant __ostream_type
	typedefs.
	(operator>>): Remove redundant __istream_type typedefs. Check stream
	operations succeed.
	(__extract_params): New function to fill a vector from a stream.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error line.

From-SVN: r280061
2020-01-09 16:50:51 +00:00
Jakub Jelinek 8d9254fc8a Update copyright years.
From-SVN: r279813
2020-01-01 12:51:42 +01:00
Jonathan Wakely 393283b8ef libstdc++: Define __cpp_lib_constexpr_complex macro
This is LWG issue 3349.

	* include/std/complex (__cpp_lib_constexpr_complex): Define.
	* include/std/version (__cpp_lib_constexpr_complex): Likewise.
	* testsuite/26_numerics/complex/1.cc: New test.
	* testsuite/26_numerics/complex/2.cc: New test.

From-SVN: r279172
2019-12-10 16:15:59 +00:00
Jonathan Wakely 0d58d88db6 Fix some missing/incorrect feature test macros
* include/std/bit (__cpp_lib_bitops): Define.
	* include/std/version (__cpp_lib_constexpr): Remove.
	(__cpp_lib_bitops, __cpp_lib_constexpr_dynamic_alloc): Define.
	* testsuite/26_numerics/bit/header.cc: New test.
	* testsuite/26_numerics/bit/header-2.cc: New test.
	* testsuite/20_util/allocator_traits/header.cc: New test.
	* testsuite/20_util/allocator_traits/header-2.cc: New test.

From-SVN: r277633
2019-10-30 16:57:13 +00:00
Jonathan Wakely 6d0dff49ca Add iterator concepts and range access customization points for C++20
This adds most of the new C++20 features to <iterator>, as well as a few
initial pieces of <ranges> (but no actual <ranges> header just yet).

	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/iterator_concepts.h: New header.
	(contiguous_iterator_tag, iter_reference_t, ranges::iter_move)
	(iter_rvalue_reference_t, incrementable_traits, iter_difference_t)
	(readable_traits, iter_value_t, readable, iter_common_reference_t)
	(writable, waekly_incrementable, incrementable)
	(input_or_output_iterator, sentinel_for, disable_sized_sentinel)
	(sized_sentinel_for, input_iterator, output_iterator)
	(forward_iterator, bidirectional_iterator, random_access_iterator)
	(contiguous_iterator, indirectly_unary_invocable)
	(indirectly_regular_unary_invocable, indirect_unary_predicate)
	(indirect_relation, indirect_strict_weak_order, indirect_result_t)
	(projected, indirectly_movable, indirectly_movable_storable)
	(indirectly_copyable, indirectly_copyable_storable, ranges::iter_swap)
	(indirectly_swappable, indirectly_comparable, permutable, mergeable)
	(sortable, unreachable_sentinel_t, unreachable_sentinel)
	(default_sentinel_t, default_sentinel): Define.
	(__detail::__cpp17_iterator, __detail::__cpp17_input_iterator)
	(__detail::__cpp17_fwd_iterator, __detail::__cpp17_bidi_iterator)
	(__detail::__cpp17_randacc_iterator): Define.
	(__iterator_traits): Define constrained specializations.
	* include/bits/move.h (move): Only use old concept check for C++98.
	* include/bits/range_access.h (ranges::disable_sized_range)
	(ranges::begin, ranges::end, ranges::cbegin, ranges::cend)
	(ranges::rbegin, ranges::rend, ranges::crbegin, ranges::crend)
	(ranges::size, ranges::empty, ranges::data, ranges::cdata): Define
	new customization points for C++20.
	(ranges::range, ranges::sized_range): Define new concepts for C++20.
	(ranges::advance, ranges::distance, ranges::next, ranges::prev):
	Define new functions for C++20.
	(__adl_end, __adl_cdata, __adl_cbegin, __adl_cend, __adl_rbegin)
	(__adl_rend, __adl_crbegin, __adl_crend, __adl_cdata, __adl_size)
	(__adl_empty): Remove.
	* include/bits/stl_iterator.h (disable_sized_sentinel): Specialize
	for reverse_iterator.
	* include/bits/stl_iterator_base_types.h (contiguous_iterator_tag):
	Define new struct for C++20.
	(iterator_traits<_Tp*>): Constrain partial specialization in C++20.
	* include/std/concepts (__is_class_or_enum): Move to __detail
	namespace.
	* testsuite/20_util/forward/c_neg.cc: Adjust dg-error line number.
	* testsuite/20_util/forward/f_neg.cc: Likewise.
	* testsuite/24_iterators/associated_types/incrementable.traits.cc: New
	test.
	* testsuite/24_iterators/associated_types/readable.traits.cc: New test.
	* testsuite/24_iterators/contiguous/concept.cc: New test.
	* testsuite/24_iterators/contiguous/tag.cc: New test.
	* testsuite/24_iterators/customization_points/iter_move.cc: New test.
	* testsuite/24_iterators/customization_points/iter_swap.cc: New test.
	* testsuite/24_iterators/headers/iterator/synopsis_c++20.cc: New test.
	* testsuite/24_iterators/range_operations/advance.cc: New test.
	* testsuite/24_iterators/range_operations/distance.cc: New test.
	* testsuite/24_iterators/range_operations/next.cc: New test.
	* testsuite/24_iterators/range_operations/prev.cc: New test.
	* testsuite/26_numerics/adjacent_difference/requirements/
	explicit_instantiation/2.cc: Rename types that conflict with C++20
	concepts.
	* testsuite/26_numerics/adjacent_difference/requirements/
	explicit_instantiation/pod.cc: Likewise.
	* testsuite/26_numerics/partial_sum/requirements/
	explicit_instantiation/2.cc: Likewise.
	* testsuite/26_numerics/partial_sum/requirements/
	explicit_instantiation/pod.cc: Likewise.
	* testsuite/experimental/iterator/requirements.cc: Likewise.
	* testsuite/std/ranges/access/begin.cc: New test.
	* testsuite/std/ranges/access/cbegin.cc: New test.
	* testsuite/std/ranges/access/cdata.cc: New test.
	* testsuite/std/ranges/access/cend.cc: New test.
	* testsuite/std/ranges/access/crbegin.cc: New test.
	* testsuite/std/ranges/access/crend.cc: New test.
	* testsuite/std/ranges/access/data.cc: New test.
	* testsuite/std/ranges/access/empty.cc: New test.
	* testsuite/std/ranges/access/end.cc: New test.
	* testsuite/std/ranges/access/rbegin.cc: New test.
	* testsuite/std/ranges/access/rend.cc: New test.
	* testsuite/std/ranges/access/size.cc: New test.
	* testsuite/util/testsuite_iterators.h (contiguous_iterator_wrapper)
	(test_range, test_sized_range): New test utilities.

From-SVN: r277579
2019-10-29 17:44:18 +00:00
Jonathan Wakely bbf0495dd2 Define std::uniform_random_bit_generator concept for C++20
* include/bits/random.h (uniform_random_bit_generator): Define for
	C++20.
	* testsuite/26_numerics/random/concept.cc: New test.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error line.

From-SVN: r277369
2019-10-24 10:35:07 +01:00
Jonathan Wakely a38b51bc3a Specialize std::numbers constants for __float128
* include/std/numbers [!__STRICT_ANSI__ && _GLIBCXX_USE_FLOAT128]
	(e_v, log2e_v, log10e_v, pi_v, inv_pi_v, inv_sqrtpi_v, ln2_v, ln10_v)
	(sqrt2_v, sqrt3_v, inv_sqrt3, egamma_v, phi_v): Add explicit
	specializations for __float128.
	* testsuite/26_numerics/numbers/float128.cc: New test.

From-SVN: r274145
2019-08-06 16:57:51 +01:00
Jonathan Wakely 960b9ae05a Implement "P0631R4 Math Constants" for C++20
The values of the constants are taken from Glibc where the equivalent
constant exists, or by rounding the actual constant to the same number
of digits as the Glibc constants have.

	P0631R4 Math Constants
	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/precompiled/stdc++.h: Include new header.
	* include/std/numbers: New header.
	* include/std/version (__cpp_lib_math_constants): Define.
	* testsuite/26_numerics/numbers/1.cc: New test.
	* testsuite/26_numerics/numbers/2.cc: New test.
	* testsuite/26_numerics/numbers/3.cc: New test.
	* testsuite/26_numerics/numbers/nonfloat_neg.cc: New test.

From-SVN: r273940
2019-07-31 17:40:39 +01:00
Jonathan Wakely a5378f9b60 Define __cpp_lib_endian feature test macro
This macro was added as part of moving std::endian from <type_traits> to
<bit>.

	* include/std/bit (__cpp_lib_endian): Define.
	* include/std/version (__cpp_lib_endian): Define.
	* testsuite/26_numerics/endian/2.cc: New.
	* testsuite/26_numerics/endian/3.cc: New.
	* testsuite/26_numerics/endian/4.cc: New.

From-SVN: r273828
2019-07-26 14:30:42 +01:00
Jonathan Wakely 45c7215c1e Relocate std::endian from <type_traits> to <bit>
This change to an early C++2a feature was just approved (P1612R1).

	* include/std/bit (endian): Move definition here as per P1612R1.
	* include/std/type_traits (endian): Remove definition from here.
	* testsuite/20_util/endian/1.cc: Rename to ...
	* testsuite/26_numerics/endian/1.cc: ... here. Adjust header.

From-SVN: r273816
2019-07-25 21:30:25 +01:00
Jonathan Wakely 2ac8e32236 Rename testsuite directory to match P0553R4 stable names
* testsuite/26_numerics/bit/bitops.count/*: Rename to ...
	* testsuite/26_numerics/bit/bit.count/*: Here.

From-SVN: r273707
2019-07-22 17:57:40 +01:00
Jonathan Wakely f35da524a2 Adjust std::rotl, std::rotr etc to match final P0553R4 proposal
This proposal has now been accepted for C++20, with a few changes. This
patch adjusts std::rotl and std::rotr to match the final specification
and declares the additions for C++2a mode even when __STRICT_ANSI__ is
defined.

	* include/std/bit (__rotl, __rotr): Change second parameter from
	unsigned int to int and handle negative values.
	(rotl, rotr): Remove check for __STRICT_ANSI__. Change second
	parameter from unsigned int to int. Add nodiscard attribute.
	* testsuite/26_numerics/bit/bitops.rot/rotl.cc: Rename to ...
	* testsuite/26_numerics/bit/bit.rotate/rotl.cc: Here. Test negative
	shifts.
	* testsuite/26_numerics/bit/bitops.rot/rotr.cc: Rename to ...
	* testsuite/26_numerics/bit/bit.rotate/rotr.cc: Here. Test negative
	shifts.

From-SVN: r273706
2019-07-22 17:53:36 +01:00
Jonathan Wakely 281ab2fbff Change std::ceil2 to be undefined if the result can't be represented
* include/std/bit (__ceil2): Make unrepresentable results undefined,
	as per P1355R2. Add debug assertion. Perform one left shift, not two,
	so that out of range values cause undefined behaviour. Ensure that
	shift will still be undefined if left operand is promoted.
	* testsuite/26_numerics/bit/bit.pow.two/ceil2.cc: Replace checks for
	unrepresentable values with checks that they are not core constant
	expressions.
	* testsuite/26_numerics/bit/bit.pow.two/ceil2_neg.cc: New test.

From-SVN: r273705
2019-07-22 17:53:27 +01:00
Jonathan Wakely 47f7905440 Add new helper traits for signed/unsigned integer types
Reuse the __is_one_of alias in additional places, and define traits to
check for signed/unsigned integer types so we don't have to duplicate
those checks elsewhere.

The additional overloads for std::byte in <bit> were reviewed by LEWG
and considered undesirable, so this patch removes them.

	* include/bits/fs_path.h (path::__is_encoded_char): Use __is_one_of.
	* include/std/bit (_If_is_unsigned_integer_type): Remove.
	(_If_is_unsigned_integer): Use __is_unsigned_integer.
	(rotl(byte, unsigned), rotr(byte, unsigned), countl_zero(byte))
	(countl_one(byte), countr_zero(byte), countr_one(byte))
	(popcount(byte), ispow2(byte), ceil2(byte), floor2(byte))
	(log2p1(byte)): Remove.
	* include/std/charconv (__detail::__is_one_of): Move to <type_traits>.
	(__detail::__is_int_to_chars_type): Remove.
	(__detail::__integer_to_chars_result_type): Use __is_signed_integer
	and __is_unsigned_integer.
	* include/std/type_traits (__is_one_of): Move here from <charconv>.
	(__is_signed_integer, __is_unsigned_integer): New helpers.
	* testsuite/26_numerics/bit/bit.pow.two/ceil2.cc: Remove test for
	std::byte overload.
	* testsuite/26_numerics/bit/bit.pow.two/floor2.cc: Likewise.
	* testsuite/26_numerics/bit/bit.pow.two/ispow2.cc: Likewise.
	* testsuite/26_numerics/bit/bit.pow.two/log2p1.cc: Likewise.
	* testsuite/26_numerics/bit/bitops.count/countl_one.cc: Likewise.
	* testsuite/26_numerics/bit/bitops.count/countl_zero.cc: Likewise.
	* testsuite/26_numerics/bit/bitops.count/countr_one.cc: Likewise.
	* testsuite/26_numerics/bit/bitops.count/countr_zero.cc: Likewise.
	* testsuite/26_numerics/bit/bitops.count/popcount.cc: Likewise.
	* testsuite/26_numerics/bit/bitops.rot/rotl.cc: Likewise.
	* testsuite/26_numerics/bit/bitops.rot/rotr.cc: Likewise.

From-SVN: r272695
2019-06-26 15:38:23 +01:00
Jonathan Wakely a3c8d7fbe2 Fix std::midpoint for denormal values
* include/std/numeric (midpoint(T, T)): Change implementation for
	floating-point types to avoid incorrect rounding of denormals.
	* testsuite/26_numerics/midpoint/floating.cc: Add check for correct
	rounding with denormals.
	* testsuite/26_numerics/gcd/gcd_neg.cc: Adjust dg-error line numbers.
	* testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.

From-SVN: r272616
2019-06-24 13:09:51 +01:00
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
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 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 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
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 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 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
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 e339291fc1 Fix new testcase to not require std::copysign
Use __builtin_copysign{,f,l} when std::copysign isn't available.

	PR libstdc++/61761
	* testsuite/26_numerics/complex/proj.cc: Don't assume <cmath> defines
	std::copysign.

From-SVN: r270859
2019-05-03 20:25:05 +01:00
Jonathan Wakely 4f75543dc4 PR libstdc++/61761 fix std::proj for targets without C99 cproj
The current generic implementation of __complex_proj used when cproj is
not available calculates the wrong projection, giving a different result
than given by C99's cproj.

When C99 cproj is not available but isinf and copysign are, use those to
give correct results for float, double and long double. Otherwise, and
for other specializations of std::complex, just use a generic version
that returns its argument, and so doesn't support infinities.

We might want to consider adding additional overloads of __complex_proj
to support extended types such as _Float64x, _Float128 etc.

	PR libstdc++/61761
	* include/std/complex (__complex_proj): Return parameter unchanged.
	[_GLIBCXX_USE_C99_COMPLEX] (__complex_proj): Change overloads for
	floating-point types to take std::complex arguments.
	[_GLIBCXX_USE_C99_MATH_TR1] (__complex_proj): Add overloads for
	floating-point types.
	* testsuite/26_numerics/complex/proj.cc: New test.

From-SVN: r270759
2019-05-01 01:08:36 +01: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
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
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 8936f5310a Document LWG 2735 status and add test
This DR was already resolved for GCC 7.1 by the implementation of DR
2192, but we didn't have an explicit test for the behaviour that 2735
guarantees.

	* doc/xml/manual/intro.xml: Document LWG 2735 status.
	* include/bits/std_abs.h: Add comment about LWG 2735.
	* testsuite/26_numerics/headers/cstdlib/dr2735.cc: New test.

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

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

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

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

From-SVN: r267757
2019-01-09 09:37:34 +00:00
Jakub Jelinek a554497024 Update copyright years.
From-SVN: r267494
2019-01-01 13:31:55 +01:00