Commit Graph

10925 Commits

Author SHA1 Message Date
Jonathan Wakely 0124d2c5bb PR libstdc++/90361 add missing macro definition
The src/c++17/string-inst.cc file needs to override the default string
ABI so that it still contains the expected symbols even when the library
is configured with --with-default-libstdcxx-abi=gcc4-compatible.

	PR libstdc++/90361
	* src/c++17/string-inst.cc: Use _GLIBCXX_USE_CXX11_ABI=1 by default.

From-SVN: r274314
2019-08-12 17:41:27 +01:00
Jonathan Wakely 6fd4b25b50 Add noexcept-specifier to std::apply and std::make_from_tuple
When unpacking a std::tuple we know that the std::get calls are
noexcept, so only the invocation (for std::apply) and construction (for
std::make_from_tuple) can throw.

We also know the std::get calls won't throw for a std::array, but this
patch doesn't specialize the variable template for std::array. For an
arbitrary tuple-like type we don't know if the std::get calls will
throw, and so just use a potentially-throwing noexcept-specifier.

	* include/std/tuple (__unpack_std_tuple): New variable template and
	partial specializations.
	(apply, make_from_tuple): Add noexcept-specifier.
	* testsuite/20_util/tuple/apply/2.cc: New test.
	* testsuite/20_util/tuple/make_from_tuple/2.cc: New test.

From-SVN: r274312
2019-08-12 15:54:12 +01:00
Alexandre Oliva c787deb012 skip Cholesky decomposition in is>>n_mv_dist
normal_mv_distribution maintains the variance-covariance matrix param
in Cholesky-decomposed form.  Existing param_type constructors, when
taking a full or lower-triangle varcov matrix, perform Cholesky
decomposition to convert it to the internal representation.  This
internal representation is visible both in the varcov() result, and in
the streamed-out representation of a normal_mv_distribution object.

The problem is that when that representation is streamed back in, the
read-back decomposed varcov matrix is used as a lower-triangle
non-decomposed varcov matrix, and it undergoes Cholesky decomposition
again.  So, each cycle of stream-out/stream-in changes the varcov
matrix to its "square root", instead of restoring the original
params.

This patch includes Corentin's changes that introduce verification in
testsuite/ext/random/normal_mv_distribution/operators/serialize.cc and
other similar tests that the object read back in compares equal to the
written-out object: the modified tests pass only if (u == v).

This patch also fixes the error exposed by his change, introducing an
alternate private constructor for param_type, used only by operator>>.


for  libstdc++-v3/ChangeLog

	* include/ext/random
	(normal_mv_distribution::param_type::param_type): New private
	ctor taking a decomposed varcov matrix, for use by...
	(operator>>): ... this, befriended.
	* include/ext/random.tcc (operator>>): Use it.
	(normal_mv_distribution::param_type::_M_init_lower): Adjust
	member function name in exception message.

for  libstdc++-v3/ChangeLog
from  Corentin Gay  <gay@adacore.com>

	* testsuite/ext/random/beta_distribution/operators/serialize.cc,
	testsuite/ext/random/hypergeometric_distribution/operators/serialize.cc,
	testsuite/ext/random/normal_mv_distribution/operators/serialize.cc,
	testsuite/ext/random/triangular_distribution/operators/serialize.cc,
	testsuite/ext/random/von_mises_distribution/operators/serialize.cc:
	Add call to `VERIFY`.

From-SVN: r274233
2019-08-09 09:20:58 +00:00
Jonathan Wakely cb0de9b60c P0325R4 to_array from LFTS with updates
As an extension to what the standard requires, this also adds
conditional noexcept-specifiers to the std::to_array functions.

	P0325R4 to_array from LFTS with updates
	* include/experimental/array (to_array): Qualify call to __to_array.
	* include/std/array (__cpp_lib_to_array, to_array): Define for C++20.
	* include/std/version (__cpp_lib_to_array): Likewise.
	* testsuite/23_containers/array/creation/1.cc: New test.
	* testsuite/23_containers/array/creation/2.cc: New test.
	* testsuite/23_containers/array/creation/3_neg.cc: New test.
	* testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc:
	Use zero for dg-error line number.

From-SVN: r274209
2019-08-08 11:18:53 +01:00
Jonathan Wakely ffc500dd41 P1651R0 bind_front should not unwrap reference_wrapper
P1651R0 bind_front should not unwrap reference_wrapper
	* include/std/functional (bind_front): Don't unwrap reference_wrapper.
	* include/std/version (__cpp_lib_bind_front): Update value.
	* testsuite/20_util/function_objects/bind_front/1.cc: Fix test for
	feature test macro.
	* testsuite/20_util/function_objects/bind_front/2.cc: New test.

From-SVN: r274146
2019-08-06 16:57:55 +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
Gerald Pfeifer 011fc8c66f documentation_hacking.xml: doxygen.org is now doxygen.nl.
* doc/xml/manual/documentation_hacking.xml: doxygen.org is now
	doxygen.nl.

From-SVN: r274094
2019-08-04 13:20:32 +00:00
Edward Smith-Rowland 3a66e68ad9 Implement C++20 p0202 - Add Constexpr Modifiers to Functions in <algorithm> and <utility> Headers.
2019-08-01  Edward Smith-Rowland  <3dw4rd@verizon.net>

	Implement C++20 p0202 - Add Constexpr Modifiers to Functions
	in <algorithm> and <utility> Headers.
	Implement C++20 p1023 - constexpr comparison operators for std::array.
	* include/bits/algorithmfwd.h (all_of, any_of, binary_search, copy,
	copy_backward, copy_if, copy_n, equal_range, fill, find_end,
	find_if_not, includes, is_heap, is_heap_until, is_partitioned,
	is_permutation, is_sorted, is_sorted_until, iter_swap, lower_bound,
	none_of, partition_copy, partition_point, remove, remove_if,
	remove_copy, remove_copy_if, replace_copy, replace_copy_if,
	reverse_copy, rotate_copy, uunique, upper_bound, adjacent_find, count,
	count_if, equal, find, find_first_of, find_if, for_each, generate,
	generate_n, lexicographical_compare, merge, mismatch, replace,
	replace_if, search, search_n, set_difference, set_intersection,
	set_symmetric_difference, set_union, transform, unique_copy):
	Mark constexpr.
	* include/bits/cpp_type_traits.h (__miter_base): Mark constexpr.
	* include/bits/predefined_ops.h (_Iter_less_val::operator(),
	_Val_less_iter::operator(), _Iter_equal_to_iter::operator(),
	_Iter_equal_to_val::operator(), _Iter_equals_val::operator()):
	 Use const ref instead of ref arg;
	(_Iter_less_val, __iter_less_val, _Val_less_iter, __val_less_iter,
	__iter_equal_to_iter, __iter_equal_to_val, __iter_comp_val,
	_Iter_comp_val, _Val_comp_iter, __val_comp_iter, __iter_equals_val,
	_Iter_equals_iter, __iter_comp_iter, _Iter_pred, __pred_iter,
	_Iter_comp_to_val, __iter_comp_val, _Iter_comp_to_iter,
	__iter_comp_iter): Mark constexpr.
	* include/bits/stl_algo.h (__find_if, __find_if_not, __find_if_not_n,
	__search, __search_n_aux, __search_n, __find_end, find_end, all_of,
	none_of, any_of, find_if_not, is_partitioned, partition_point,
	__remove_copy_if, remove_copy, remove_copy_if, copy_if, __copy_n,
	copy_n, partition_copy, __remove_if, remove, remove_if, __adjacent_find,
	__unique, unique, __unique_copy, reverse_copy, rotate_copy,
	__unguarded_linear_insert, __insertion_sort, __unguarded_insertion_sort,
	__final_insertion_sort, lower_bound, __upper_bound, upper_bound,
	__equal_range, equal_range, binary_search, __includes, includes,
	__next_permutation, __prev_permutation, __replace_copy_if, replace_copy,
	replace_copy_if, __count_if, is_sorted, __is_sorted_until,
	is_sorted_until, __is_permutation, is_permutation, for_each, find,
	find_if, find_first_of, adjacent_find, count, count_if, search,
	search_n, transform, replace, replace_if, generate, generate_n,
	unique_copy, __merge, merge, __set_union, set_union, __set_intersection,
	set_intersection, __set_difference, set_difference,
	__set_symmetric_difference, set_symmetric_difference):  Mark constexpr.
	* include/bits/stl_algobase.h (__memmove, __memcmp): New maybe constexpr
	wrappers around __builtin_memmove and __builtin_memcmp
	respectively;
	(__niter_base, __niter_wrap, __copy_m, __copy_move_a, __copy_move_a2,
	copy, move, __copy_move_b, __copy_move_backward_a,
	__copy_move_backward_a2, copy_backward, move_backward, __fill_a, fill,
	__fill_n_a, fill_n, equal, __lc_rai::__newlast1, __lc_rai::__cnd2,
	__lexicographical_compare_impl, __lexicographical_compare,
	__lexicographical_compare<true>::__lc, __lexicographical_compare_aux,
	__lower_bound, lower_bound, equal, __equal4, lexicographical_compare,
	__mismatch, mismatch, __is_heap_until, __is_heap, is_heap_until,
	is_heap): Mark constexpr.
	* include/bits/stl_heap.h (__is_heap_until, __is_heap, is_heap_until,
	is_heap): Mark constexpr.
	* include/bits/stl_iterator.h (__niter_base, __miter_base): Mark constexpr.
	* include/std/array: Make comparison ops constexpr.
	* include/std/utility: Make exchange constexpr.
	* include/std/version (__cpp_lib_constexpr_algorithms): New macro.
	* testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust.
	* testsuite/23_containers/array/tuple_interface/
	tuple_element_neg.cc: Adjust.
	* testsuite/20_util/exchange/constexpr.cc: New.
	* testsuite/23_containers/array/comparison_operators/constexpr.cc: New.
	* testsuite/25_algorithms/constexpr_macro.cc: New.
	* testsuite/25_algorithms/adjacent_find/constexpr.cc: New.
	* testsuite/25_algorithms/all_of/constexpr.cc: New.
	* testsuite/25_algorithms/any_of/constexpr.cc: New.
	* testsuite/25_algorithms/binary_search/constexpr.cc: New.
	* testsuite/25_algorithms/copy/constexpr.cc: New.
	* testsuite/25_algorithms/copy_backward/constexpr.cc: New.
	* testsuite/25_algorithms/copy_if/constexpr.cc: New.
	* testsuite/25_algorithms/copy_n/constexpr.cc: New.
	* testsuite/25_algorithms/count/constexpr.cc: New.
	* testsuite/25_algorithms/count_if/constexpr.cc: New.
	* testsuite/25_algorithms/equal/constexpr.cc: New.
	* testsuite/25_algorithms/equal_range/constexpr.cc: New.
	* testsuite/25_algorithms/fill/constexpr.cc: New.
	* testsuite/25_algorithms/fill_n/constexpr.cc: New.
	* testsuite/25_algorithms/find/constexpr.cc: New.
	* testsuite/25_algorithms/find_end/constexpr.cc: New.
	* testsuite/25_algorithms/find_first_of/constexpr.cc: New.
	* testsuite/25_algorithms/find_if/constexpr.cc: New.
	* testsuite/25_algorithms/find_if_not/constexpr.cc: New.
	* testsuite/25_algorithms/for_each/constexpr.cc: New.
	* testsuite/25_algorithms/generate/constexpr.cc: New.
	* testsuite/25_algorithms/generate_n/constexpr.cc: New.
	* testsuite/25_algorithms/is_heap/constexpr.cc: New.
	* testsuite/25_algorithms/is_heap_until/constexpr.cc: New.
	* testsuite/25_algorithms/is_partitioned/constexpr.cc: New.
	* testsuite/25_algorithms/is_permutation/constexpr.cc: New.
	* testsuite/25_algorithms/is_sorted/constexpr.cc: New.
	* testsuite/25_algorithms/is_sorted_until/constexpr.cc: New.
	* testsuite/25_algorithms/lexicographical_compare/constexpr.cc: New.
	* testsuite/25_algorithms/lower_bound/constexpr.cc: New.
	* testsuite/25_algorithms/merge/constexpr.cc: New.
	* testsuite/25_algorithms/mismatch/constexpr.cc: New.
	* testsuite/25_algorithms/none_of/constexpr.cc: New.
	* testsuite/25_algorithms/partition_copy/constexpr.cc: New.
	* testsuite/25_algorithms/partition_point/constexpr.cc: New.
	* testsuite/25_algorithms/remove/constexpr.cc: New.
	* testsuite/25_algorithms/remove_copy/constexpr.cc: New.
	* testsuite/25_algorithms/remove_copy_if/constexpr.cc: New.
	* testsuite/25_algorithms/remove_if/constexpr.cc: New.
	* testsuite/25_algorithms/replace_copy/constexpr.cc: New.
	* testsuite/25_algorithms/replace_copy_if/constexpr.cc: New.
	* testsuite/25_algorithms/replace_if/constexpr.cc: New.
	* testsuite/25_algorithms/reverse_copy/constexpr.cc: New.
	* testsuite/25_algorithms/rotate_copy/constexpr.cc: New.
	* testsuite/25_algorithms/search/constexpr.cc: New.
	* testsuite/25_algorithms/search_n/constexpr.cc: New.
	* testsuite/25_algorithms/set_difference/constexpr.cc: New.
	* testsuite/25_algorithms/set_intersection/constexpr.cc: New.
	* testsuite/25_algorithms/set_symmetric_difference/constexpr.cc: New.
	* testsuite/25_algorithms/set_union/constexpr.cc: New.
	* testsuite/25_algorithms/transform/constexpr.cc: New.
	* testsuite/25_algorithms/unique/constexpr.cc: New.
	* testsuite/25_algorithms/unique_copy/constexpr.cc: New.
	* testsuite/25_algorithms/upper_bound/constexpr.cc: New.

From-SVN: r273975
2019-08-01 15:25:42 +00:00
Jonathan Wakely 3090082cbe Qualify call to prevent ADL
* include/std/memory (make_obj_using_allocator): Qualify call to
	uses_allocator_construction_args.

From-SVN: r273945
2019-07-31 20:08:56 +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 27e6c1f406 Add Doxygen comments to <bit> header
* include/std/bit: Add Doxygen comments.

From-SVN: r273938
2019-07-31 15:38:50 +01:00
Jonathan Wakely 949fdadb9d PR libstdc++/91308 fix constraints on unique_ptr assignment
PR libstdc++/91308
	* include/bits/unique_ptr.h (unique_ptr::__safe_conversion_up): Remove
	constraints on deleter that should only apply to the constructor.
	(unique_ptr<T[], D>::__safe_conversion_up): Likewise.
	(unique_ptr<T[], D>::unique_ptr(unique_ptr<U, D>&&)): Restore
	constraints on deleter here.
	* testsuite/20_util/unique_ptr/assign/91308.cc: New test.

From-SVN: r273937
2019-07-31 15:38:26 +01:00
Jonathan Wakely 50c2df93a6 PR libstdc++/51333 Define recursive_init_error constructor non-inline
The recursive_init_error class is defined in a header, with an inline
constructor, but the definition of the vtable and destructor are not
exported from the shared library. With -fkeep-inline-functions the
constructor gets emitted in user code, and requires the (non-exported)
vtable. This fails to link.

As far as I can tell, the recursive_init_error class definition was
moved into <cxxabi.h> so it could be documented with Doxygen, not for
any technical reason. But now it's there (and documented), somebody
could be relying on it, by catching that type and possibly performing
derived-to-base conversions to the std::exception base class. So the
conservative fix is to leave the class definition in the header but make
the constructor non-inline. This still allows the type to be caught and
still defines its base class. User code can no longer construct objects
of that type, but that's not something we need to support.

	PR libstdc++/51333
	* libsupc++/cxxabi.h (__gnu_cxx::recursive_init_error): Do not define
	constructor inline.
	* libsupc++/guard_error.cc (__gnu_cxx::recursive_init_error): Define
	constructor.
	* testsuite/18_support/51333.cc: New test.

From-SVN: r273878
2019-07-29 15:27:19 +01:00
Gerald Pfeifer c5993c9abc documentation_hacking.xml: Fix broken reference to the Doxygen manual.
* doc/xml/manual/documentation_hacking.xml: Fix broken reference
	to the Doxygen manual. Avoid a "here" link on the way.
	Fix another broken link to Doxygen docblocks.

From-SVN: r273852
2019-07-28 09:10:32 +00: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
François Dumont ac2dca4daf 2019-07-26 François Dumont <fdumont@gcc.gnu.org>
* testsuite/util/testsuite_iterators.h
	(bidirectional_iterator_wrapper): Fix type comment.
	(random_access_iterator_wrapper): Likewise.

From-SVN: r273824
2019-07-26 05:05:48 +00: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
Martin Liska 6343b6bf3b Extend DCE to remove unnecessary new/delete-pairs (PR c++/23383).
2019-07-25  Martin Liska  <mliska@suse.cz>
	    Dominik Infuhr  <dominik.infuehr@theobroma-systems.com>

	PR c++/23383
	* common.opt: Add -fallocation-dce
	* gimple.c (gimple_call_operator_delete_p): New.
	* gimple.h (gimple_call_operator_delete_p): Likewise.
	* tree-core.h (enum function_decl_type): Add OPERATOR_DELETE.
	* tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Handle
	DECL_IS_OPERATOR_DELETE_P.
	(mark_all_reaching_defs_necessary_1): Likewise.
	(propagate_necessity): Likewise.
	(eliminate_unnecessary_stmts): Handle
	gimple_call_operator_delete_p.
	* tree-streamer-in.c (unpack_ts_function_decl_value_fields):
	Add packing of OPERATOR_DELETE.
	* tree-streamer-out.c (pack_ts_function_decl_value_fields):
	Similarly here.
	* tree.h (DECL_IS_OPERATOR_DELETE_P): New.
	(DECL_SET_IS_OPERATOR_DELETE): New.
	(DECL_IS_REPLACEABLE_OPERATOR_NEW_P): Likewise.
2019-07-25  Martin Liska  <mliska@suse.cz>
	    Dominik Infuhr  <dominik.infuehr@theobroma-systems.com>

	PR c++/23383
	* c-decl.c (merge_decls): Merge OPERATOR_DELETE flag.
2019-07-25  Martin Liska  <mliska@suse.cz>
	    Dominik Infuhr  <dominik.infuehr@theobroma-systems.com>

	PR c++/23383
	* decl.c (cxx_init_decl_processing): Mark delete operators
	with DECL_SET_IS_OPERATOR_DELETE.
2019-07-25  Martin Liska  <mliska@suse.cz
	    Dominik Infuhr  <dominik.infuehr@theobroma-systems.com>

	PR c++/23383
	* g++.dg/cpp1y/new1.C: New test.
2019-07-25  Martin Liska  <mliska@suse.cz>
	    Dominik Infuhr  <dominik.infuehr@theobroma-systems.com>

	PR c++/23383
	* testsuite/ext/bitmap_allocator/check_delete.cc: Add
	-fno-allocation-dce.
	* testsuite/ext/bitmap_allocator/check_new.cc: Likewise.
	* testsuite/ext/new_allocator/check_delete.cc: Likewise.
	* testsuite/ext/new_allocator/check_new.cc: Likewise.

Co-Authored-By: Dominik Infuehr <dominik.infuehr@theobroma-systems.com>

From-SVN: r273791
2019-07-25 09:36:38 +00: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
François Dumont 2be3193b82 stl_tempbuf.h (__detail::__return_temporary_buffer): Fix sized deallocation size computation.
2019-07-19  François Dumont  <fdumont@gcc.gnu.org>

	* include/bits/stl_tempbuf.h (__detail::__return_temporary_buffer): Fix
	sized deallocation size computation.

From-SVN: r273609
2019-07-19 21:14:41 +00:00
Andreas Schwab 22469e4244 * config/abi/post/m68k-linux-gnu/baseline_symbols.txt: Update.
From-SVN: r273598
2019-07-19 09:57:08 +00:00
François Dumont f48d9d19dd stl_tempbuf.h (__detail::__return_temporary_buffer): New.
2019-07-18  François Dumont  <fdumont@gcc.gnu.org>

	* include/bits/stl_tempbuf.h (__detail::__return_temporary_buffer): New.
	(~_Temporary_buffer()): Use latter.
	(_Temporary_buffer(_FIterator, size_type)): Likewise.

From-SVN: r273586
2019-07-18 21:52:35 +00:00
Andreas Schwab 5d688cb277 * config/abi/post/ia64-linux-gnu/baseline_symbols.txt: Update.
From-SVN: r273547
2019-07-17 08:17:53 +00:00
Jason Merrill e6c847fb8f Add parens around constraint in <memory>.
C++20 concepts require parens around atomic constraints that are not
primary-expressions.

	* include/std/memory (uses_allocator_construction_args): Add parens
	around constraint.

From-SVN: r273515
2019-07-16 04:54:47 -04:00
Jonathan Wakely b979ca0ffd Fix inaccurate comment in new test
* testsuite/29_atomics/atomic_float/1.cc: Fix comment.

From-SVN: r273448
2019-07-12 16:45:16 +01:00
Jonathan Wakely 0d67cd380d Define __type_identity_t alias and use for string_view
This defines the equivalent of C++2a's std::type_identity_t alias but
for use in C++11 and later. This can be used to replace __detail::__idt
in the string_view headers, which previously used common_type_t because
the one argument specialization of common_type_t was simply the identity
transform (which is no longer true).

	* include/experimental/string_view (__detail::__idt): Remove.
	(operator==, operator!=, operator<, operator>, operator<=, operator>=):
	Use __type_identity_t instead of __detail::__idt;
	* include/std/string_view (__detail::__idt): Remove.
	(operator==, operator!=, operator<, operator>, operator<=, operator>=):
	Use __type_identity_t instead of __detail::__idt;
	* include/std/type_traits (__type_identity_t): New alias template.

From-SVN: r273442
2019-07-12 12:43:22 +01:00
Jonathan Wakely 804e2d0631 Update C++2a library status table
* doc/xml/manual/status_cxx2020.xml: Update status for atomic_ref
	and floating point atomics.

From-SVN: r273441
2019-07-12 12:43:17 +01:00
Jonathan Wakely f6822be73a Improve docs for --enable-libstdcxx-time=rt
* doc/xml/manual/configure.xml: Improve documentation of
	--enable-libstdcxx-time option.

From-SVN: r273421
2019-07-11 20:43:32 +01:00
Jonathan Wakely a90fe12c80 Define std::atomic_ref and std::atomic<floating-point> for C++20
This adds the new atomic types from C++2a, as proposed by P0019 and
P0020. To reduce duplication the calls to the compiler's atomic
built-ins are wrapped in new functions in the __atomic_impl namespace.
These functions are currently only used by std::atomic<floating-point>
and std::atomic_ref but could also be used for all other specializations
of std::atomic.

	* include/bits/atomic_base.h (__atomic_impl): New namespace for
	wrappers around atomic built-ins.
	(__atomic_float, __atomic_ref): New class templates for use as base
	classes.
	* include/std/atomic (atomic<float>, atomic<double>)
	(atomic<long double>): New explicit specializations.
	(atomic_ref): New class template.
	(__cpp_lib_atomic_ref): Define.
	* include/std/version (__cpp_lib_atomic_ref): Define.
	* testsuite/29_atomics/atomic/60695.cc: Adjust dg-error.
    	* testsuite/29_atomics/atomic_float/1.cc: New test.
    	* testsuite/29_atomics/atomic_float/requirements.cc: New test.
    	* testsuite/29_atomics/atomic_ref/deduction.cc: New test.
    	* testsuite/29_atomics/atomic_ref/float.cc: New test.
    	* testsuite/29_atomics/atomic_ref/generic.cc: New test.
    	* testsuite/29_atomics/atomic_ref/integral.cc: New test.
    	* testsuite/29_atomics/atomic_ref/pointer.cc: New test.
    	* testsuite/29_atomics/atomic_ref/requirements.cc: New test.

From-SVN: r273420
2019-07-11 20:43:25 +01:00
Jonathan Wakely a10b664eb7 Fix recent regression in __atomic_add_dispatch
* include/ext/atomicity.h (__exchange_and_add, __atomic_add): Replace
	throw() with _GLIBCXX_NOTHROW.
	(__atomic_add_dispatch): Return after performing atomic increment.

From-SVN: r273167
2019-07-06 22:16:38 +01:00
Jonathan Wakely 0dc7adb037 Fix ODR violations in code using <ext/atomicity.h>
Because the inline versions of __exchange_and_add and __atomic_add are
also marked static, they cannot be used from templates or other inline
functions without ODR violations. This change gives them external
linkage, but adds the always_inline attribute.

    	* include/ext/atomicity.h [_GLIBCXX_ATOMIC_BUILTINS] (__atomic_add)
    	(__exchange_and_add): Replace static specifier with always_inline
    	attribute.
    	(__exchange_and_add_single, __atomic_add_single): Likewise.
    	(__exchange_and_add_dispatch, __atomic_add_dispatch): Likewise. Also
    	combine !__gthread_active_p() and !__GTHREADS branches.

From-SVN: r273144
2019-07-05 17:10:47 +01:00
Jonathan Wakely 67699bf667 PR libstdc++/91067 fix missing exports for filesystem iterators
The copy assignment operator for recursive_directory_iterator was not
exported despite being needed. The __shared_ptr default constructors are
not needed when compiling with GCC but Clang requires them for -O1.

	PR libstdc++/91067
	* acinclude.m4 (libtool_VERSION): Bump to 6:27:0.
	* configure: Regenerate.
	* config/abi/pre/gnu.ver (GLIBCXX_3.4.27): Add new version. Export
	missing symbols.
	* testsuite/27_io/filesystem/iterators/91067.cc: New test.
	* testsuite/util/testsuite_abi.cc: Add new symbol version.

From-SVN: r273023
2019-07-03 22:06:25 +01:00
Jonathan Wakely 4887c9e808 Fix preprocessor checks for Clang builtins
Clang seems to define built-ins that start with "__builtin_" as
non-keywords, which means that we need to use __has_builtin to detect
them, not __is_identifier. The built-ins that don't start with
"__builtin_" are keywords, and can only be detected using
__is_identifier and not by __has_builtin.

	* include/bits/c++config (_GLIBCXX_HAVE_BUILTIN_LAUNDER)
	(_GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED): Use __has_builtin
	instead of __is_identifier to detect Clang support.

From-SVN: r272931
2019-07-02 12:50:27 +01:00
Jim Wilson 758d7478bf Fix libstdc++ install-pdf support.
Generating pdf files requires everything that is required for the xml files
except the style sheets.

	libstdc++-v3/
	* configure.ac (BUILD_PDF): Also test for doxygen, dot, xsltproc,
	and xmllint.
	* configure: Regenerate.

From-SVN: r272920
2019-07-01 19:30:52 -07:00
Jonathan Wakely e11c487111 PR libstdc++/91012 fixfilesystem_error::what() string
When I refactored the filesystem_error code I changed it to only use the
constructor parameter in the what() string, instead of the string
returned by system_error::what(). That meant it no longer included the
description of the error_code that system_error adds. This restores the
previous behaivour, as encouraged by the standard ("Implementations
should include the system_error::what() string and the pathnames of
path1 and path2 in the native format in the returned string").

	PR libstdc++/91012
	* src/c++17/fs_path.cc (filesystem_error::_Impl): Use a string_view
	for the what_arg parameters.
	(filesystem_error::filesystem_error): Pass system_error::what() to
	the _Impl constructor.
	* testsuite/27_io/filesystem/filesystem_error/cons.cc: Ensure that
	filesystem_error::what() contains system_error::what().

From-SVN: r272739
2019-06-27 10:42:39 +01:00
Jonathan Wakely 22ff8929d7 Define std::chars_format enumeration type
This type isn't used anywhere yet, but will be needed for the
floating-point overloads of to_chars and from_chars.

	* include/std/charconv (chars_format): Define bitmask type.
	* testsuite/20_util/to_chars/chars_format.cc: New test.

From-SVN: r272718
2019-06-26 23:54:38 +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 e88d863cbd Fix non-portable use of std::abs(double) in constexpr function
Although libstdc++ adds 'constexpr' to its std::abs(floating-point)
overloads (as a non-conforming extension), those overloads are not used
if the target libc provides them, which is the case on Solaris.

The fix is to avoid std::abs and simply apply the negation when needed.

	* include/std/numeric (midpoint(T, T)): Avoid std::abs in constexpr
	function.

From-SVN: r272653
2019-06-25 14:18:36 +01:00
Jakub Jelinek 32bab8b6ad pstl_config.h (_PSTL_PRAGMA_SIMD_SCAN, [...]): Define to OpenMP 5.0 pragmas even for GCC 10.0+.
* include/pstl/pstl_config.h (_PSTL_PRAGMA_SIMD_SCAN,
	_PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN, _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN):
	Define to OpenMP 5.0 pragmas even for GCC 10.0+.
	(_PSTL_UDS_PRESENT): Define to 1 for GCC 10.0+.

From-SVN: r272634
2019-06-25 08:59:12 +02: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 ff164b601b Define C11 macros such as FLT_DECIMAL_DIG for C++17
* testsuite/18_support/headers/cfloat/values_c++17.cc: New test.

From-SVN: r272615
2019-06-24 13:09:47 +01:00
Jonathan Wakely 86f73527aa Skip libstdc++ debug build in early bootstrap stages
As mentioned in PR 90770, this is a patch that Debian have been carrying
for some time. The additional unoptimized copies of libstdc++ libs that
get built during each stage are never going to be used, so don't bother
building them.

For a profiled bootstrap this means we won't train the compiler on the
unoptimized library code with assertions enabled, but that doesn't seem
like a big problem, as the same code has already been compiled once for
the main libstdc++ library.

	* acinclude.m4 (GLIBCXX_ENABLE_DEBUG): Only do debug build for final
	stage of bootstrap.
	* configure: Regenerate.

From-SVN: r272509
2019-06-20 15:17:57 +01:00
Jonathan Wakely d306dee31d Qualify calls to __never_valueless in <variant>
* include/std/variant (_Variant_storage, _Extra_visit_slot_needed):
	Qualify calls to __never_valueless.

From-SVN: r272508
2019-06-20 15:17:51 +01:00
Jonathan Wakely 9f35dcd405 Fix outdated reference to C++17 draft in the docs
* doc/xml/manual/status_cxx2017.xml: Fix outdated reference to
	C++17 working draft.

From-SVN: r272500
2019-06-20 10:13:03 +01:00
Jonathan Wakely 94872d7f99 Improve tests for std::vector<bool> printer
The current tests wouldn't notice if the vector<bool> contents were
printed in reverse, because it would read the same forwards and
backwards. Change the content so the tests would fail if that happened.

	* testsuite/libstdc++-prettyprinters/simple.cc: Use non-palindromic
	vector<bool> for test.
	* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.

From-SVN: r272499
2019-06-20 10:04:55 +01:00
Jonathan Wakely 638ad333ec Fix non-standard behaviour of std::istream_iterator
The current implementation of istream_iterator allows the iterator to be
reused after reaching end-of-stream, so that subsequent reads from the
stream can succeed (e.g. if the stream state has been cleared and stream
position changed from EOF). The P0738R2 paper clarified that the
expected behaviour is to set the stream pointer to null after reaching
end-of-stream, preventing further reads.

This implements that requirement, and adds the new default constructor
to std::ostream_iterator.

	* include/bits/stream_iterator.h (istream_iterator::_M_equal()): Make
	private.
	(istream_iterator::_M_read()): Do not check stream state before
	attempting extraction. Set stream pointer to null when extraction
	fails (P0738R2).
	(operator==(const istream_iterator&, const istream_iterator&)): Change
	to be a hidden friend of istream_iterator.
	(operator!=(const istream_iterator&, const istream_iterator&)):
	Likewise.
	(ostream_iterator::ostream_iterator()): Add default constructor.
	(ostream_iterator::ostream_iterator(ostream_type*, const C*)): Use
	addressof.
	* testsuite/24_iterators/istream_iterator/1.cc: New test.
	* testsuite/24_iterators/ostream_iterator/1.cc: New test.
	* testsuite/24_iterators/ostream_iterator/70766.cc: Also check
	constructor taking a string.
	* testsuite/24_iterators/ostream_iterator/requirements/constexpr.cc:
	New test.

From-SVN: r272491
2019-06-19 23:57:10 +01:00
Michael Weghorn 36d0dada67 Have std::vector printer's iterator return bool for vector<bool>
Have the pretty-printer for 'std::vector<bool>' return a
value of type 'bool' rather than an 'int'.

This way, the type is clear and that can be used for better
display and a 'gdb.Value' constructed from the returned value
will have type 'bool' again, not e.g. 'long long' as happened
previously (at least with GDB 8.2.1 on amd64).

2019-06-19  Michael Weghorn  <m.weghorn@posteo.de>
	    Jonathan Wakely  <jwakely@redhat.com>

	PR libstdc++/90945
	* python/libstdcxx/v6/printers.py (StdVectorPrinter._iterator): Use
	values of type bool for vector<bool> elements.
	* testsuite/libstdc++-prettyprinters/simple.cc: Test vector<bool>.
	* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.

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

From-SVN: r272490
2019-06-19 23:57:06 +01:00
Jonathan Wakely 0fd9e8482e PR libstdc++/90920 restore previous checks for empty ranges
The change in r263433 broke the contract of the __rotate functions, by no
longer accepting empty ranges. That means that callers which inlined the
old version of std::rotate (without checks) that end up linking to a new
definition of std::__rotate (also without checks) could perform a divide
by zero and crash.

This restores the old contract of the __rotate overloads.

	PR libstdc++/90920 partially revert r263433
	* include/bits/stl_algo.h (__rotate): Restore checks for empty ranges.
	(rotate): Remove checks.
	* testsuite/25_algorithms/rotate/90920.cc: New test.

From-SVN: r272489
2019-06-19 23:57:02 +01:00