Commit Graph

10563 Commits

Author SHA1 Message Date
Jonathan Wakely c3ba63c314 PR libstdc++/87704 fix unique_ptr(nullptr_t) constructors
Using a delegating constructor to implement these constructors means
that they instantiate the destructor, which requires the element_type to
be complete. In C++11 and C++14 they were specified to be delegating,
but that was changed as part of LWG 2801 so in C++17 they don't require
a complete type (as was intended all along).

	PR libstdc++/87704
	* include/bits/unique_ptr.h (unique_ptr::unique_ptr(nullptr_t)): Do
	not delegate to default constructor.
	(unique_ptr<T[], D>::unique_ptr(nullptr_t)): Likewise.
	* testsuite/20_util/unique_ptr/cons/incomplete.cc: New test.

From-SVN: r265423
2018-10-23 14:10:26 +01:00
François Dumont f65c0c735e testsuite_containers.h (forward_members_unordered<>::forward_members_unordered (const value_type&)): Add local_iterator pre and post increment checks.
2018-10-20  François Dumont  <fdumont@gcc.gnu.org>

	* testsuite/util/testsuite_containers.h
	(forward_members_unordered<>::forward_members_unordered
	(const value_type&)): Add local_iterator pre and post increment checks.
	* config/abi/pre/gnu.ver: Add GLIBCXX_3.4.26 new symbol.

From-SVN: r265344
2018-10-20 20:00:45 +00:00
Jonathan Wakely f324588755 Skip tests for GNU extensions when testing with strict mode
Tests for the implicit allocator rebinding extension will fail if the
extension is disabled, so skip them.

	* testsuite/23_containers/array/requirements/explicit_instantiation/
	3.cc: Skip test when compiled with a -std=c++NN strict mode.
	* testsuite/23_containers/deque/requirements/explicit_instantiation/
	3.cc: Likewise.
	* testsuite/23_containers/forward_list/requirements/
	explicit_instantiation/3.cc: Likewise.
	* testsuite/23_containers/list/requirements/explicit_instantiation/
	3.cc: Likewise.
	* testsuite/23_containers/map/requirements/explicit_instantiation/
	3.cc: Likewise.
	* testsuite/23_containers/multimap/requirements/explicit_instantiation/
	3.cc: Likewise.
	* testsuite/23_containers/multiset/requirements/explicit_instantiation/
	3.cc: Likewise.
	* testsuite/23_containers/set/requirements/explicit_instantiation/
	3.cc: Likewise.
	* testsuite/23_containers/unordered_map/requirements/
	explicit_instantiation/3.cc: Likewise.
	* testsuite/23_containers/unordered_multimap/requirements/
	explicit_instantiation/3.cc: Likewise.
	* testsuite/23_containers/unordered_multiset/requirements/
	explicit_instantiation/3.cc: Likewise.
	* testsuite/23_containers/unordered_set/requirements/
	explicit_instantiation/3.cc: Likewise.
	* testsuite/23_containers/vector/ext_pointer/explicit_instantiation/
	3.cc: Likewise.
	* testsuite/23_containers/vector/requirements/explicit_instantiation/
	3.cc: Likewise.

From-SVN: r265334
2018-10-19 22:50:15 +01:00
Jonathan Wakely 92bab15297 Fix testsuite failures due to extra errors in strict dialects
When __STRICT_ANSI__ is defined the incorrect allocators used in these
tests also trigger and additional static assertion. Prune those extra
errors so that the tests don't fail when built with strict dialects.

	* testsuite/23_containers/deque/48101_neg.cc: Prune additional errors
	printed when __STRICT_ANSI__ is defined.
	* testsuite/23_containers/forward_list/48101_neg.cc: Likewise.
	* testsuite/23_containers/list/48101_neg.cc: Likewise.
	* testsuite/23_containers/multiset/48101_neg.cc: Likewise.
	* testsuite/23_containers/set/48101_neg.cc: Likewise.
	* testsuite/23_containers/unordered_multiset/48101_neg.cc: Likewise.
	* testsuite/23_containers/unordered_set/48101_neg.cc: Likewise.
	* testsuite/23_containers/vector/48101_neg.cc: Likewise.

From-SVN: r265333
2018-10-19 22:50:03 +01:00
Jonathan Wakely f8f3939037 Conditionally disable tests of non-standard extensions
These tests include uses of the extension to allow allocators with the
wrong value_type in containers. Skip those parts of the tests when
__STRICT_ANIS__ is defined.

	* testsuite/23_containers/forward_list/requirements/
	explicit_instantiation/5.cc [__STRICT_ANSI__]: Don't test non-standard
	extension.
	* testsuite/23_containers/list/requirements/explicit_instantiation/
	5.cc [__STRICT_ANSI__]: Likewise.
	* testsuite/23_containers/map/requirements/explicit_instantiation/5.cc
	[__STRICT_ANSI__]: Likewise.
	* testsuite/23_containers/multimap/requirements/explicit_instantiation/
	5.cc [__STRICT_ANSI__]: Likewise.
	* testsuite/23_containers/multiset/requirements/explicit_instantiation/
	5.cc [__STRICT_ANSI__]: Likewise.
	* testsuite/23_containers/set/requirements/explicit_instantiation/5.cc
	[__STRICT_ANSI__]: Likewise.
	* testsuite/23_containers/unordered_map/requirements/debug_container.cc
	[__STRICT_ANSI__]: Likewise.
	* testsuite/23_containers/unordered_map/requirements/
	explicit_instantiation/5.cc [__STRICT_ANSI__]: Likewise.
	* testsuite/23_containers/unordered_multimap/requirements/
	explicit_instantiation/5.cc [__STRICT_ANSI__]: Likewise.
	* testsuite/23_containers/unordered_multiset/requirements/
	explicit_instantiation/5.cc [__STRICT_ANSI__]: Likewise.
	* testsuite/23_containers/unordered_set/requirements/
	explicit_instantiation/5.cc [__STRICT_ANSI__]: Likewise.

From-SVN: r265332
2018-10-19 22:49:49 +01:00
Jonathan Wakely 78ed0f80c3 Fix tests that use allocators with incorrect value types
As a GNU extension we allow containers to be instantiated with
allocators that use a different value type from the container, and
automatically rebind the allocator to the correct type. This extension
is disabled in strict modes (when __STRICT_ANSI__ is defined, i.e.
-std=c++NN dialects). These testcases unintentionally rely on the
extension and so fail for strict modes.

Tests which intentionally make use of the extension will still fail in
strict dialects, but will be addressed in a later change.

	* testsuite/20_util/scoped_allocator/1.cc: Use allocator with correct
	value type for the container.
	* testsuite/23_containers/forward_list/cons/14.cc: Likewise.
	* testsuite/23_containers/map/56613.cc: Likewise.
	* testsuite/23_containers/unordered_map/55043.cc: Likewise.
	* testsuite/23_containers/unordered_map/allocator/copy.cc: Likewise.
	* testsuite/23_containers/unordered_map/allocator/copy_assign.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/allocator/minimal.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/allocator/move.cc: Likewise.
	* testsuite/23_containers/unordered_map/allocator/move_assign.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/allocator/noexcept.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/cons/81891.cc: Likewise.
	* testsuite/23_containers/unordered_map/requirements/exception/
	basic.cc: Likewise.
	* testsuite/23_containers/unordered_map/requirements/exception/
	generation_prohibited.cc: Likewise.
	* testsuite/23_containers/unordered_map/requirements/exception/
	propagation_consistent.cc: Likewise.
	* testsuite/23_containers/unordered_multimap/55043.cc: Likewise.
	* testsuite/23_containers/unordered_multimap/allocator/copy.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/allocator/copy_assign.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/allocator/minimal.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/allocator/move.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/allocator/move_assign.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/allocator/noexcept.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/requirements/exception/
	basic.cc: Likewise.
	* testsuite/23_containers/unordered_multimap/requirements/exception/
	generation_prohibited.cc: Likewise.
	* testsuite/23_containers/unordered_multimap/requirements/exception/
	propagation_consistent.cc: Likewise.
	* testsuite/23_containers/unordered_multimap/requirements/
	explicit_instantiation/5.cc: Likewise.
	* testsuite/ext/malloc_allocator/sanity.cc: Likewise.

From-SVN: r265331
2018-10-19 22:49:40 +01:00
Jonathan Wakely e7f2d0bdb5 Disable tests that only pass for GNU dialects
The airy and hypergeometric functions are non-standard extensions and
are only defined for -std=gnu++NN dialects, not -std=c++NN ones.

	* ext/special_functions/airy_ai/check_nan.cc: Skip test for
	non-standard extension when a strict -std=c++NN dialect is used.
	* ext/special_functions/airy_ai/check_value.cc: Likewise.
	* ext/special_functions/airy_ai/compile.cc: Likewise.
	* ext/special_functions/airy_bi/check_nan.cc: Likewise.
	* ext/special_functions/airy_bi/check_value.cc: Likewise.
	* ext/special_functions/airy_bi/compile.cc: Likewise.
	* ext/special_functions/conf_hyperg/check_nan.cc: Likewise.
	* ext/special_functions/conf_hyperg/check_value.cc: Likewise.
	* ext/special_functions/conf_hyperg/compile.cc: Likewise.
	* ext/special_functions/hyperg/check_nan.cc: Likewise.
	* ext/special_functions/hyperg/check_value.cc: Likewise.
	* ext/special_functions/hyperg/compile.cc: Likewise.

From-SVN: r265330
2018-10-19 22:49:32 +01:00
Jonathan Wakely 88412b71ee Remove duplicate tests
These tests originally existed to check the containers in C++11 mode,
when the default was C++98 mode. Now that the default is C++14 (and we
run most tests for all modes) it serves no purpose to have two copies of
the tests when neither is explicitly using -std=gnu++98 anyway.

	* testsuite/23_containers/list/requirements/explicit_instantiation/
	5_c++0x.cc: Remove redundant test that is functionally identical to
	the 5.cc test.
	* testsuite/23_containers/map/requirements/explicit_instantiation/
	5_c++0x.cc: Likewise.
	* testsuite/23_containers/multimap/requirements/explicit_instantiation/
	5_c++0x.cc: Likewise.
	* testsuite/23_containers/multiset/requirements/explicit_instantiation/
	5_c++0x.cc: Likewise.
	* testsuite/23_containers/set/requirements/explicit_instantiation/
	5_c++0x.cc: Likewise.

From-SVN: r265329
2018-10-19 22:49:19 +01:00
Jonathan Wakely 30f7c08d96 Fix compilation error with _GLIBCXX_PARALLEL
* include/bits/regex_executor.tcc (_Backref_matcher::_M_apply): Use
	_GLIBCXX_STD_A to refer to normal mode algorithms.
	* testsuite/28_regex/headers/regex/parallel_mode.cc: New test.
	* testsuite/28_regex/headers/regex/std_c++0x_neg.cc: Remove empty
	whitespace.

From-SVN: r265314
2018-10-19 14:46:24 +01:00
Jonathan Wakely 7b1e8acfae Fix testsuite failures in Debug Mode
This fixes the following testsuite failures on ia32 when compiled with
-D_GLIBCXX_DEBUG:

FAIL: 23_containers/map/modifiers/erase/dr130-linkage-check.cc
FAIL: 23_containers/multimap/modifiers/erase/dr130-linkage-check.cc
FAIL: 23_containers/multiset/modifiers/erase/dr130-linkage-check.cc
FAIL: 23_containers/set/modifiers/erase/dr130-linkage-check.cc

The normal mode containers already use the abi-tag to mangle these
overloads differently, but the debug mode versions weren't fixed.

	* include/debug/map.h (map::erase(iterator)): Add abi-tag so that
	C++11 version mangles differently from incompatible C++98 version.
	* include/debug/multimap.h (multimap::erase(iterator)): Likewise.
	* include/debug/multiset.h (multiset::erase(iterator))
	(multiset::erase(const_iterator, const_iterator)): Likewise.
	* include/debug/set.h (set::erase(iterator))
	(multiset::erase(const_iterator, const_iterator)): Likewise.

From-SVN: r265313
2018-10-19 14:37:05 +01:00
Jonathan Wakely 955fe731e3 Fix tests that fail when built with different options
* testsuite/20_util/duration/cons/2.cc: Add -ffloat-store to fix
	failure when compiled without optimisation.
	* testsuite/ext/profile/mutex_extensions_neg.cc: Prune additional
	errors caused by C++17 std::pmr alias templates.

From-SVN: r265287
2018-10-18 21:04:55 +01:00
Jonathan Wakely c0ace69ec6 PR libstdc++/87642 handle multibyte thousands separators from libc
If a locale's THOUSANDS_SEP or MON_THOUSANDS_SEP string is not a
single character we either need to narrow it to a single char or
ignore it (and therefore disable digit grouping for that facet).

	PR libstdc++/87642
	* config/locale/gnu/monetary_members.cc
	(moneypunct<char, true>::_M_initialize_moneypunct): Use
	__narrow_multibyte_chars to convert multibyte thousands separators
	to a single char.
	* config/locale/gnu/numeric_members.cc
	(numpunct<char>::_M_initialize_numpunct): Likewise.
	(__narrow_multibyte_chars): New function.

From-SVN: r265286
2018-10-18 20:57:25 +01:00
Jonathan Wakely fab2c75b73 PR libstdc++/87641 correctly initialize accumulator in valarray::sum()
Use the value of the first element as the initial value of the
__valarray_sum accumulator. Value-initialization might not create the
additive identity for the value type.

Make a similar change to __valarray_product even though it's only ever
used internally with a value_type of size_t.

	PR libstdc++/87641
	* include/bits/valarray_array.h (__valarray_sum): Use first element
	to initialize accumulator instead of value-initializing it.
	(__valarray_product<_Tp>): Move to ...
	* src/c++98/valarray.cc (__valarray_product<_Tp>): Here. Use first
	element to initialize accumulator.
	(__valarray_product(const valarray<size_t>&)): Remove const_cast made
	unnecessary by LWG 389.
	* testsuite/26_numerics/valarray/87641.cc: New test.

From-SVN: r265270
2018-10-18 16:38:50 +01:00
François Dumont 7702ab653a revert: [multiple changes]
2018-10-18  François Dumont  <fdumont@gcc.gnu.org>

	Partial revert.
	2018-10-08  François Dumont  <fdumont@gcc.gnu.org>

	* include/debug/list (list<>::cbegin()): Use C++11 direct
	initialization.
	(list<>::cend()): Likewise.
	(list<>::erase(const_iterator, const_iterator)): Ensure consistent
	iterator comparisons.
	(list<>::splice(const_iterator, list&&, const_iterator,
	const_iterator)): Likewise.

	Partial revert.
	2018-10-15  François Dumont  <fdumont@gcc.gnu.org>

	* include/debug/vector (vector<>::cbegin()): Use C++11 direct
	initialization.
	(vector<>::cend()): Likewise.
	(vector<>::insert(const_iterator, const _Tp&)): Use consistent
	iterator comparison.
	(vector<>::erase(const_iterator)): Likewise.
	(vector<>::erase(const_iterator, const_iterator)): Likewise.

From-SVN: r265259
2018-10-18 05:36:02 +00:00
Ville Voutilainen 4026227f21 re PR libstdc++/87619 (sizeof(std::variant) can be reduced if its variant_size is UCHAR_MAX)
PR libstdc++/87619

* include/std/variant (__select_index): Fix an off-by-one.
* testsuite/20_util/variant/87619.cc: New.

From-SVN: r265247
2018-10-17 22:08:51 +03:00
Jonathan Wakely ec2e0ad5ea Fix regression in std::random_device default constructor
When the default constructor was split out into a separate function (in
r261522) I accidentally  made it call _M_init("mt19937") instead of
_M_init_pretr1("mt19937"). That means it will always throw an exception,
because "mt19937" isn't a valid token accepted by the _M_init function.
Restore the original behaviour by calling _M_init_pretr1("mt19937").

	* include/bits/random.h (random_device) [!_GLIBCXX_USE_DEV_RANDOM]:
	Fix default constructor to call correct function.

From-SVN: r265218
2018-10-16 23:42:39 +01:00
Jonathan Wakely 436ea0e5d3 Rename namespace alias in test to avoid name collision
* testsuite/experimental/net/internet/address/v4/creation.cc: Do not
	declare ip in global namespace, to avoid collision with struct ip
	defined in <netinet/ip.h>.

From-SVN: r265205
2018-10-16 17:13:00 +01:00
Jonathan Wakely a70a4be9c2 Fix versioned namespace macros for Networking TS
We no longer put the versioned namespace macros on the innermost
namespace, but always nested directly below namespace std.

	* include/experimental/bits/net.h: Move versioned namespace macros
	to correct location.
	* include/experimental/buffer: Likewise.
	* include/experimental/executor: Likewise.
	* include/experimental/internet: Likewise.
	* include/experimental/io_context: Likewise.
	* include/experimental/netfwd: Likewise.
	* include/experimental/socket: Likewise.
	* include/experimental/timer: Likewise.

From-SVN: r265204
2018-10-16 17:12:51 +01:00
Jonathan Wakely 82a0f2fd10 Use autoconf to check for features needed by Networking TS
* config.h.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Check for headers used by Networking TS.
	* include/experimental/executor: Include <condition_variable>
	instead of <mutex>.
	* include/experimental/internet: Use autoconf macros for available
	headers.  Include <sys/socket.h> for.  Remove <cstring> and use
	__builtin_memcpy and __builtin_strchr.
	(resolver_errc) [!_GLIBCXX_HAVE_NETDB_H]: Do not define.
	(address_v4::to_string, address_v6::to_string)
	[!_GLIBCXX_HAVE_ARPA_INET_H]: Likewise.
	(basic_resolver_results) [!_GLIBCXX_HAVE_NETDB_H]: Make private
	constructors report errors.
	[!_GLIBCXX_HAVE_NETINET_TCP_H] (tcp::no_delay): Do not define.
	* include/experimental/io_context: Likewise.
	* include/experimental/socket: Likewise.
	[!_GLIBCXX_HAVE_SYS_SOCKET_H, !_GLIBCXX_HAVE_POLL_H] (socket_base): Do
	not define nested types when relevant header not available.
	(__socket_impl::native_non_blocking) [!_GLIBCXX_HAVE_FCNTL_H]: Report
	an error.
	(__basic_socket_impl::open, __basic_socket_impl::local_endpoint)
	(__basic_socket_impl::bind) [!_GLIBCXX_HAVE_SYS_SOCKET_H]: Likewise.
	(__basic_socket_impl::io_control) [!_GLIBCXX_HAVE_SYS_IOCTL_H]:
	Likewise.
	(basic_socket::at_mark, basic_socket::shutdown)
	(basic_socket::remote_endpoint, basic_socket::connect)
	(basic_socket::async_connect) [!_GLIBCXX_HAVE_SYS_SOCKET_H]: Likewise.
	(basic_socket::available) [_GLIBCXX_HAVE_SYS_IOCTL_H]: Check macro
	for <sys/ioctl.h> availability.
	(basic_socket::wait) [!_GLIBCXX_HAVE_POLL_H]: Likewise.
	(basic_datagram_socket::receive, basic_datagram_socket::async_receive)
	(basic_datagram_socket::receive_from)
	(basic_datagram_socket::async_receive_from)
	(basic_datagram_socket::send, basic_datagram_socket::async_send)
	(basic_datagram_socket::send_to, basic_datagram_socket::async_send_to)
	[!_GLIBCXX_HAVE_SYS_SOCKET_H]: Likewise.
	(basic_stream_socket::receive, basic_stream_socket::async_receive)
	(basic_stream_socket::send, basic_stream_socket::async_send)
	[!_GLIBCXX_HAVE_SYS_SOCKET_H]: Likewise.
	(basic_socket_acceptor::listen, basic_socket_acceptor::accept)
	(basic_socket_acceptor::async_accept) [!_GLIBCXX_HAVE_SYS_SOCKET_H]:
	Likewise.
	(basic_socket_acceptor::wait) [!_GLIBCXX_HAVE_POLL_H]: Likewise.

From-SVN: r265203
2018-10-16 17:12:32 +01:00
Jonathan Wakely 7e8b87e901 Use effective target in Networking TS tests
* testsuite/experimental/net/headers.cc: Remove dg-options.
	* testsuite/experimental/net/buffer/arithmetic.cc: Replace dg-options
	with dg-do using effective target.
	* testsuite/experimental/net/buffer/const.cc: Likewise.
	* testsuite/experimental/net/buffer/creation.cc: Likewise.
	* testsuite/experimental/net/buffer/mutable.cc: Likewise.
	* testsuite/experimental/net/buffer/size.cc: Likewise.
	* testsuite/experimental/net/buffer/traits.cc: Likewise.
	* testsuite/experimental/net/execution_context/use_service.cc:
	Likewise.
	* testsuite/experimental/net/internet/address/v4/comparisons.cc:
	Likewise.
	* testsuite/experimental/net/internet/address/v4/cons.cc: Likewise.
	* testsuite/experimental/net/internet/address/v4/creation.cc:
	Likewise.
	* testsuite/experimental/net/internet/address/v4/members.cc: Likewise.
	* testsuite/experimental/net/internet/resolver/base.cc: Likewise.
	* testsuite/experimental/net/internet/resolver/ops/lookup.cc:
	Likewise.
	* testsuite/experimental/net/internet/resolver/ops/reverse.cc:
	Likewise.
	* testsuite/experimental/net/timer/waitable/cons.cc: Likewise.
	* testsuite/experimental/net/timer/waitable/dest.cc: Likewise.
	* testsuite/experimental/net/timer/waitable/ops.cc: Likewise.

From-SVN: r265200
2018-10-16 16:37:10 +01:00
Jonathan Wakely 345fba60b1 Add missing return
* include/experimental/socket (basic_socket::at_mark): Add missing
	return.

From-SVN: r265199
2018-10-16 16:24:00 +01:00
Jonathan Wakely 5ae2c32a8a Define _GLIBCXX_USE_DEV_RANDOM as replacement for _GLIBCXX_USE_RANDOM_TR1
Define and use a new macro with a more descriptive name. Only use the
old macro in <tr1/random.h>.

	* acinclude.m4 (GLIBCXX_CHECK_RANDOM_TR1): Replace with ...
	(GLIBCXX_CHECK_DEV_RANDOM): New macro with more descriptive name.
	Define _GLIBCXX_USE_DEV_RANDOM as well as _GLIBCXX_USE_RANDOM_TR1.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Use GLIBCXX_CHECK_DEV_RANDOM instead of
	GLIBCXX_CHECK_RANDOM_TR1.
	crossconfig.m4: Likewise.
	* include/bits/random.h (random_device): Use _GLIBCXX_USE_DEV_RANDOM
	instead of _GLIBCXX_USE_RANDOM_TR1.
	* testsuite/26_numerics/random/random_device/cons/token.cc: Likewise.

From-SVN: r265197
2018-10-16 15:49:29 +01:00
Rainer Orth 630f2da967 Introduce dg-add-options net_ts
* testsuite/lib/dg-options.exp (add_options_for_net_ts): New proc.
	* testsuite/experimental/net/internet/address/v4/comparisons.cc:
	Add dg-add-options net_ts.
	* testsuite/experimental/net/internet/address/v4/cons.cc: Likewise.
	* testsuite/experimental/net/internet/address/v4/creation.cc: Likewise.
	* testsuite/experimental/net/internet/address/v4/members.cc: Likewise.
	* testsuite/experimental/net/internet/resolver/base.cc: Likewise.
	* testsuite/experimental/net/internet/resolver/ops/lookup.cc: Likewise.
	* testsuite/experimental/net/internet/resolver/ops/reverse.cc: Likewise.

From-SVN: r265192
2018-10-16 12:27:52 +00:00
Jonathan Wakely b57d432bdd Fix tests that fail when compiled without optimisation
* testsuite/20_util/duration/literals/range_neg.cc: Adjust pruned
	diagnostic to account for quotes around 'constexpr'.
	* testsuite/23_containers/deque/capacity/max_size.cc: Define static
	variable.
	* testsuite/23_containers/vector/capacity/max_size.cc: Likewise.

From-SVN: r265190
2018-10-16 13:06:05 +01:00
Jonathan Wakely d30096b45f PR libstdc++/87618 fix typos in linker script
PR libstdc++/87618
	* config/abi/pre/gnu.ver: Fix typos in patterns for basic_stringbuf.
	* testsuite/27_io/basic_stringbuf/cons/char/default.cc: Disable
	optimisation to check constructor definition can be linked to.
	* testsuite/27_io/basic_stringbuf/cons/wchar_t/default.cc: Likewise.

From-SVN: r265188
2018-10-16 12:14:37 +01:00
Jonathan Wakely b219eb0378 Adjust test to pass with latest glibc
Glibc changed the it_IT locales to use thousands separators,
invalidating this test. Use nl_NL instead, as Dutch only uses grouping
for money not numbers.

	* testsuite/22_locale/numpunct/members/char/3.cc: Adjust test to
	account for change to glibc it_IT localedata (glibc bz#10797).

From-SVN: r265165
2018-10-15 14:55:42 +01:00
Jonathan Wakely f9bd185f18 PR libstdc++/87587 prevent -Wabi warnings
The warnings about changes to empty struct parameter passing can be
ignored because the callers are all internal to the library, and so
compiled with the same -fabi-version as the function definitions.

It would be preferable to use #pragma GCC diagnostic warning "-Wabi=12"
to get warnings about any other ABI changes in future versions, but
until PR c++/87611 is fixed the warnings must be completely disabled
with #pragma GCC diagnostic ignroed "-Wabi".

	PR libstdc++/87587
	* src/c++11/cxx11-shim_facets.cc: Suppress -Wabi warnings.

From-SVN: r265163
2018-10-15 13:58:51 +01:00
François Dumont 4b186707ee vector (vector<>::cbegin()): Use C++11 direct initialization.
2018-10-15  François Dumont  <fdumont@gcc.gnu.org>

	* include/debug/vector (vector<>::cbegin()): Use C++11 direct
	initialization.
	(vector<>::cend()): Likewise.
	(vector<>::emplace(const_iterator, _Args&&...)): Likewise and use
	consistent iterator comparison.
	(vector<>::insert(const_iterator, size_type, const _Tp&)): Likewise.
	(vector<>::insert(const_iterator, _InputIterator, _InputIterator)):
	Likewise.
	(vector<>::erase(const_iterator)): Likewise.
	(vector<>::erase(const_iterator, const_iterator)): Likewise.

From-SVN: r265156
2018-10-15 05:24:51 +00:00
Jonathan Wakely e5989e71ff Initial commit of Networking TS implementation
* include/Makefile.am: Add new headers.
	* include/Makefile.in: Regenerate.
	* include/experimental/bits/net.h: New header for common
	implementation details of Networking TS.
	* include/experimental/buffer: New header.
	* include/experimental/executor: New header.
	* include/experimental/internet: New header.
	* include/experimental/io_context: New header.
	* include/experimental/net: New header.
	* include/experimental/netfwd: New header.
	* include/experimental/socket: New header.
	* include/experimental/timer: New header.
	* testsuite/experimental/net/buffer/arithmetic.cc: New test.
	* testsuite/experimental/net/buffer/const.cc: New test.
	* testsuite/experimental/net/buffer/creation.cc: New test.
	* testsuite/experimental/net/buffer/mutable.cc: New test.
	* testsuite/experimental/net/buffer/size.cc: New test.
	* testsuite/experimental/net/buffer/traits.cc: New test.
	* testsuite/experimental/net/execution_context/use_service.cc: New
	test.
	* testsuite/experimental/net/headers.cc: New test.
	* testsuite/experimental/net/internet/address/v4/comparisons.cc: New
	test.
	* testsuite/experimental/net/internet/address/v4/cons.cc: New test.
	* testsuite/experimental/net/internet/address/v4/creation.cc: New
	test.
	* testsuite/experimental/net/internet/address/v4/members.cc: New
	test.
	* testsuite/experimental/net/internet/resolver/base.cc: New test.
	* testsuite/experimental/net/internet/resolver/ops/lookup.cc: New
	test.
	* testsuite/experimental/net/internet/resolver/ops/reverse.cc: New
	test.
	* testsuite/experimental/net/timer/waitable/cons.cc: New test.
	* testsuite/experimental/net/timer/waitable/dest.cc: New test.
	* testsuite/experimental/net/timer/waitable/ops.cc: New test.

From-SVN: r265080
2018-10-12 11:50:15 +01:00
Jonathan Wakely 49cb790a4c PR libstdc++/77691 increase allocation size to at least alignment
It's not safe to assume that malloc(n) returns memory aligned to more
than n, so when relying on the guaranteed alignment of malloc ensure
that the number of bytes allocated is at least as large as the
alignment.

	PR libstdc++/77691
	* include/experimental/memory_resource (__resource_adaptor_imp): Do
	not allocate sizes smaller than alignment when relying on guaranteed
	alignment.
	* testsuite/experimental/memory_resource/new_delete_resource.cc:
	Adjust expected number of bytes allocated for alignof(max_align_t).

From-SVN: r265068
2018-10-12 00:21:11 +01:00
François Dumont 3e670ecf0b 2018-10-11 François Dumont <fdumont@gcc.gnu.org>
* include/debug/forward_list
	(forward_list<>::before_begin()): Use C++11 direct initialization.
	(forward_list<>::begin()): Likewise.
	(forward_list<>::end()): Likewise.
	(forward_list<>::cbefore_begin()): Likewise.
	(forward_list<>::cbegin()): Likewise.
	(forward_list<>::cend()): Likewise.
	(forward_list<>::emplace_after<>(const_iterator, _Args&&...)): Likewise.
	(forward_list<>::insert_after(const_iterator, const _Tp&)): Likewise.
	(forward_list<>::insert_after(const_iterator, _Tp&&)): Likewise.
	(forward_list<>::insert_after(const_iterator, size_type, const _Tp&)):
	Likewise.
	(forward_list<>::insert_after(const_iterator, initializer_list<>)):
	Likewise.
	(forward_list<>::erase_after(const_iterator)): Likewise.
	(forward_list<>::erase_after(const_iterator, const_iterator)): Likewise
	and ensure consistent iterator comparison.

From-SVN: r265061
2018-10-11 20:47:13 +00:00
François Dumont 91febb0e2b 2018-10-11 François Dumont <fdumont@gcc.gnu.org>
* include/bits/forward_list.h
	(_Fwd_list_iterator<>::operator==): Replace member function with inline
	friend.
	(_Fwd_list_iterator<>::operator!=): Likewise.
	(_Fwd_list_const_iterator<>::operator==): Likewise.
	(_Fwd_list_const_iterator<>::operator!=): Likewise.
	(operator==(const _Fwd_list_iterator<>&,
	const _Fwd_list_const_iterator<>&)): Remove.
	(operator!=(const _Fwd_list_iterator<>&,
	const _Fwd_list_const_iterator<>&)): Remove.
	(forward_list<>::_Node): Take typedef from base type.
	(forward_list<>::iterator): Likewise.
	(forward_list<>::const_iterator): Likewise.

From-SVN: r265060
2018-10-11 20:21:57 +00:00
Jonathan Wakely cfef4c324a PR libstdc++/80538 Only call sleep for non-zero values
Avoid a system call when no sleep is required. Sleep in a loop (actually
two loops) to handle interruption by signals.

	PR libstdc++/80538
	* src/c++11/thread.cc (this_thread::__sleep_for)
	[_GLIBCXX_HAVE_SLEEP]: Only call sleep for non-zero values.
	Loop while sleep call is interrupted and until steady_clock
	shows requested duration has elapsed.
	(!_GLIBCXX_HAVE_USLEEP]: Use the _GLIBCXX_HAVE_SLEEP code path, but
	avoiding the usleep call.
	* testsuite/30_threads/this_thread/60421.cc: Test repeated
	signal interruptions.

From-SVN: r265044
2018-10-11 17:37:23 +01:00
Jonathan Wakely c7790bdbd9 Make ext allocators support heterogeneous equality comparison
The Allocator requirements include the ability to compare different
specializations of the same allocator class template. This did not work
for __gnu_cxx::new_allocator and other extension allocators.  This patch
replaces the equality operators for those allocators with inline friends
that support heterogeneous comparisons.  (I'm not changing all ext
allocators because some are bit-rotted already).

Additionally, the equality operators for comparing two std::allocator
objects of the same type are now defined as inline friends. Those
overloads don't need to be declared at namespace scope, because they
aren't specified in the standard (but they're needed in this
implementation to avoid ambiguities caused by the extra overloads
defined for the base allocator type).

	* include/bits/allocator.h
	(operator==(const allocator<_Tp>&, const allocator<_Tp>))
	(operator!=(const allocator<_Tp>&, const allocator<_Tp>)): Replace
	with inline friends.
	* include/ext/debug_allocator.h (operator==, operator!=): Replace
	with inline friend functions that compare to rebound allocators.
	* include/ext/malloc_allocator.h (operator==, operator!=): Likewise.
	* include/ext/new_allocator.h (operator==, operator!=): Likewise.
	* testsuite/ext/debug_allocator/eq.cc: New test.
	* testsuite/ext/ext_pointer/alloc_eq.cc: New test.
	* testsuite/ext/malloc_allocator/eq.cc: New test.
	* testsuite/ext/new_allocator/eq.cc: New test.

From-SVN: r265036
2018-10-11 12:32:29 +01:00
Jonathan Wakely 422a9f7789 PR libstdc++/87544 limit max_size() to PTRDIFF_MAX / sizeof(T)
The C++17 standard requires the default implementation for
allocator_traits::max_size to return SIZE_MAX / sizeof(value_type).
That causes GCC to warn because the value could be larger than can
sensibly be passed to malloc. This patch changes the new_allocator and
malloc_allocator max_size() members to use PTRDIFF_MAX instead of
SIZE_MAX (and because they define it, the allocator_traits default isn't
used). This also changes vector::max_size to impose a sensible limit
using PTRDIFF_MAX for cases where the value from the allocator or
allocator_traits is not sensible.

	PR libstdc++/87544
	* include/bits/stl_vector.h (vector::_S_max_size): Limit size to
	PTRDIFF_MAX / sizeof(value_type).
	* include/ext/malloc_allocator.h (malloc_allocator::max_size):
	Likewise.
	* include/ext/new_allocator.h (new_allocator::max_size): Likewise.
	* testsuite/23_containers/vector/allocator/minimal.cc: Adjust
	expected value for max_size().
	* testsuite/23_containers/vector/capacity/87544.cc: New test.

From-SVN: r265021
2018-10-10 16:39:33 +01:00
François Dumont 2f039722d0 2018-10-09 François Dumont <fdumont@gcc.gnu.org>
* include/bits/stl_list.h
	(_List_operator<>::operator==): Replace member function with inline
	friend.
	(_List_operator<>::operator!=): Likewise.
	(_List_const_operator<>::operator==): Likewise.
	(_List_const_operator<>::operator!=): Likewise.
	(operator==(const _List_iterator<>&, const _List_const_iterator<>&)):
	Remove.
	(operator!=(const _List_iterator<>&, const _List_const_iterator<>&)):
	Remove.

From-SVN: r264993
2018-10-09 20:38:06 +00:00
Jonathan Wakely 33b43b0d8c Define std::string and related typedefs outside __cxx11 namespace
The typedefs for common specializations of std::__cxx11::basic_string do
not need to be in the std::__cxx11 namespace. Those typedefs are never
used for linkage purposes so don't appear in mangled names, and so don't
need to be distinct from the equivalent typedefs for the COW
std::basic_string specializations. It is OK for the same typedef to
refer to different types in different translation units.

Defining them directly in namespace std improves diagnostics that use
those typedefs. For example:

error: could not convert '1' from 'int' to 'std::__cxx11::string' {aka 'std::__cxx11::basic_string<char>'}

will now be printed as:

error: could not convert '1' from 'int' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}

The precise type is still shown, but the typedef is not obfuscated with
the inline namespace.

	* include/bits/stringfwd.h (string, wstring, u16string, u32string):
	Define typedefs outside of __cxx11 inline namespace.
	* python/libstdcxx/v6/printers.py (register_type_printers): Also
	register printers for typedefs in new location.

From-SVN: r264958
2018-10-09 14:06:46 +01:00
Jonathan Wakely aca0dcde1f PR libstdc++/87538 Verify fix for std::experimental::not_fn
PR libstdc++/87538
	* testsuite/experimental/functional/87538.cc: New test.

From-SVN: r264922
2018-10-08 13:17:58 +01:00
Jonathan Wakely 606f6be67b PR libstdc++/87538 fix std::not_fn exception specifications
PR libstdc++/87538
	* include/std/functional (_Not_fn::operator()): Check value of
	__is_nothrow_invocable as well.
	* testsuite/20_util/function_objects/not_fn/87538.cc: New test.

From-SVN: r264921
2018-10-08 13:07:22 +01:00
François Dumont edec2bad9a list (list<>::cbegin()): Use C++11 direct initialization.
2018-10-08  François Dumont  <fdumont@gcc.gnu.org>

	* include/debug/list (list<>::cbegin()): Use C++11 direct
	initialization.
	(list<>::cend()): Likewise.
	(list<>::emplace<>(const_iterator, _Args&&...)): Likewise.
	(list<>::insert(const_iterator, initializer_list<>)): Likewise.
	(list<>::insert(const_iterator, size_type, const _Tp&)): Likewise.
	(list<>::erase(const_iterator, const_iterator)): Ensure consistent
	iterator comparisons.
	(list<>::splice(const_iterator, list&&, const_iterator,
	const_iterator)): Likewise.

From-SVN: r264911
2018-10-08 05:49:12 +00:00
François Dumont e0b9bc230a 2018-10-05 François Dumont <fdumont@gcc.gnu.org>
* include/bits/stl_tree.h
	(_Rb_tree_iterator<>::operator==): Make inline friend.
	(_Rb_tree_iterator<>::operator!=): Likewise.
	(_Rb_tree_const_iterator<>::operator==): Likewise.
	(_Rb_tree_const_iterator<>::operator!=): Likewise.
	(operator==(const _Rb_tree_iterator<>&,
	const _Rb_tree_const_iterator&)): Remove.
	(operator!=(const _Rb_tree_iterator<>&,
	const _Rb_tree_const_iterator&)): Remove.
	(operator==(const _Rb_tree<>&, const _Rb_tree<>&)): Make inline friend.
	(operator<(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise.
	(operator!=(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise and
	deprecate.
	(operator>(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise.
	(operator<=(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise.
	(operator>=(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise.
	* include/debug/map.h (map<>::erase(const_iterator, const_iterator)):
	Compare __victim with _Base::cend().
	* include/debug/multimap.h
	(multimap<>::erase(const_iterator, const_iterator)): Likewise.
	* include/debug/set.h (set<>::erase(const_iterator, const_iterator)):
	Compare __victim with _Base::cend().
	* include/debug/multiset.h
	(multiset<>::erase(const_iterator, const_iterator)): Likewise.

From-SVN: r264875
2018-10-05 16:01:39 +00:00
Jonathan Wakely 749c0e1d8b PR libstdc++/59439 optimize uses of classic ("C") std::locale
The global locale::_Impl that represents the "C" locale is never
destroyed, so there is no need to keep track of reference count updates
for that object. This greatly reduce contention between threads that
refer to the classic locale. Since the global std::locale initially uses
the classic locale, this benefits the common case for any code using the
global locale, such as construction/destruction of iostream objects.

All these updates are done inside libstdc++.so so there's no need to
worry about users' objects having inlined old versions of the code which
still update the reference count for the classic locale.

	PR libstdc++/59439
	* src/c++98/locale.cc (locale::locale(const locale&)): Bypass
	reference count updates for the classic locale.
	(locale::~locale()): Likewise.
	(locale::operator=(const locale&)): Likewise.
	* src/c++98/locale_init.cc (locale::locale()): Likewise.
	(locale::global(const locale&)): Likewise.

From-SVN: r264811
2018-10-03 12:27:40 +01:00
François Dumont 784779d471 2018-10-03 François Dumont <fdumont@gcc.gnu.org>
* include/debug/map.h
	(map<>::emplace<>(_Args&&...)): Use C++11 direct initialization.
	(map<>::emplace_hint<>(const_iterator, _Args&&...)): Likewise.
	(map<>::insert(value_type&&)): Likewise.
	(map<>::insert<>(_Pair&&)): Likewise.
	(map<>::insert<>(const_iterator, _Pair&&)): Likewise.
	(map<>::try_emplace): Likewise.
	(map<>::insert_or_assign): Likewise.
	(map<>::insert(node_type&&)): Likewise.
	(map<>::insert(const_iterator, node_type&&)): Likewise.
	(map<>::erase(const_iterator)): Likewise.
	(map<>::erase(const_iterator, const_iterator)): Likewise.
	* include/debug/multimap.h
	(multimap<>::emplace<>(_Args&&...)): Use C++11 direct initialization.
	(multimap<>::emplace_hint<>(const_iterator, _Args&&...)): Likewise.
	(multimap<>::insert<>(_Pair&&)): Likewise.
	(multimap<>::insert<>(const_iterator, _Pair&&)): Likewise.
	(multimap<>::insert(node_type&&)): Likewise.
	(multimap<>::insert(const_iterator, node_type&&)): Likewise.
	(multimap<>::erase(const_iterator)): Likewise.
	(multimap<>::erase(const_iterator, const_iterator)): Likewise.
	* include/debug/set.h
	(set<>::emplace<>(_Args&&...)): Use C++11 direct initialization.
	(set<>::emplace_hint<>(const_iterator, _Args&&...)): Likewise.
	(set<>::insert(value_type&&)): Likewise.
	(set<>::insert<>(const_iterator, value_type&&)): Likewise.
	(set<>::insert(const_iterator, node_type&&)): Likewise.
	(set<>::erase(const_iterator)): Likewise.
	(set<>::erase(const_iterator, const_iterator)): Likewise.
	* include/debug/multiset.h
	(multiset<>::emplace<>(_Args&&...)): Use C++11 direct initialization.
	(multiset<>::emplace_hint<>(const_iterator, _Args&&...)): Likewise.
	(multiset<>::insert<>(value_type&&)): Likewise.
	(multiset<>::insert<>(const_iterator, value_type&&)): Likewise.
	(multiset<>::insert(node_type&&)): Likewise.
	(multiset<>::insert(const_iterator, node_type&&)): Likewise.
	(multiset<>::erase(const_iterator)): Likewise.
	(multiset<>::erase(const_iterator, const_iterator)): Likewise.

From-SVN: r264805
2018-10-03 05:50:01 +00:00
Marc Glisse 86920074bf vector<bool> _M_start and 0 offset
2018-10-02  Marc Glisse  <marc.glisse@inria.fr>

	PR libstdc++/87258
	* include/bits/stl_bvector.h (vector::begin(), vector::cbegin()):
	Rebuild _M_start with an explicit 0 offset.

From-SVN: r264791
2018-10-02 14:59:25 +00:00
Jonathan Wakely 469218a3f9 Avoid redundant runtime checks in std::visit
Calling std::get will check some static assertions and also do a runtime
check for a valid index before calling __detail::__variant::__get. The
std::visit function already handles the case where any variant has an
invalid index, so __get can be used directly in __visit_invoke.

	* include/std/variant (__gen_vtable_impl::__visit_invoke): Call __get
	directly instead of get, as caller ensures correct index is used.
	(holds_alternative, get, get_if): Remove redundant inline specifiers.
	(_VARIANT_RELATION_FUNCTION_TEMPLATE): Likewise.

From-SVN: r264786
2018-10-02 15:00:50 +01:00
Joseph Myers 1c02928295 Use -fno-show-column in libstdc++ installed testing.
<https://gcc.gnu.org/ml/libstdc++/2016-08/msg00006.html> arranged for
libstdc++ tests to use -fno-show-column by default, but only for
build-tree testing.  This patch adds it to the options used for
installed testing as well.

Tested with installed testing for a cross to x86_64-linux-gnu, where
it fixes various test failures.

	* testsuite/lib/libstdc++.exp (libstdc++_init): Use
	-fno-show-column in default cxxflags.

From-SVN: r264784
2018-10-02 13:46:32 +01:00
Bernhard Reutner-Fischer 15b946f77d config: Remove unused define for os uClibc
__NO_STRING_INLINES was removed from uClibc around 2004 so has no
effect.

libstdc++-v3/ChangeLog:

2018-10-01  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>

        * config/os/uclibc/os_defines.h (__NO_STRING_INLINES): Delete.

From-SVN: r264783
2018-10-02 14:35:42 +02:00
Gerald Pfeifer 3553df866a allocator.xml: Adjust link to "Reconsidering Custom Memory Allocation".
* doc/xml/manual/allocator.xml: Adjust link to "Reconsidering
	Custom Memory Allocation".

From-SVN: r264761
2018-10-01 15:17:15 +00:00
Jonathan Wakely 8e4d333b0e Regenerate libstdc++ HTML pages
* doc/html/*: Regenerate.

From-SVN: r264760
2018-10-01 15:28:36 +01:00
Gerald Pfeifer f1525dd4b4 messages.xml: Switch link to www.oracle.com to https.
* doc/xml/manual/messages.xml: Switch link to www.oracle.com
	to https.

From-SVN: r264723
2018-09-30 11:41:31 +00:00
Gerald Pfeifer 8b3f158946 policy_data_structures_biblio.xml: Update link to Microsoft Component Model Object Technologies.
* doc/xml/manual/policy_data_structures_biblio.xml: Update
	link to Microsoft Component Model Object Technologies.

From-SVN: r264722
2018-09-30 10:53:14 +00:00
Gerald Pfeifer 15f8a37755 fdl-1.3.xml: The Free Software Foundation web site now uses https.
* doc/xml/gnu/fdl-1.3.xml: The Free Software Foundation web
	site now uses https. Also omit the unnecessary trailing slash.
	* doc/xml/gnu/gpl-3.0.xml: Ditto.

From-SVN: r264710
2018-09-29 11:25:57 +00:00
François Dumont 5c441345a3 functions.h (__foreign_iterator_aux3(const _Safe_iterator<>&, const _InputeIter&, const _InputIter&, __true_type)): Use empty() rather than begin() == end().
2018-09-28  François Dumont  <fdumont@gcc.gnu.org>

	* include/debug/functions.h
	(__foreign_iterator_aux3(const _Safe_iterator<>&, const _InputeIter&,
	const _InputIter&, __true_type)): Use empty() rather than begin() ==
	end().

From-SVN: r264699
2018-09-28 20:26:29 +00:00
Mike Crowe 29b26763f5 Use steady_clock to implement condition_variable::wait_for with predicate
In r263225 (d2e378182a12d68fe5caeffae681252662a2fe7b), I fixed
condition_variable::wait_for to use std::chrono::steady_clock for the wait.
Unfortunately, I failed to spot that the same fix is required for the
wait_for variant that takes a predicate too.

2018-09-25  Mike Crowe  <mac@mcrowe.com>

	* include/std/condition_variable (condition_variable::wait_for): Use
	steady clock in overload that uses a predicate.

From-SVN: r264575
2018-09-25 15:59:27 +01:00
Jonathan Wakely 16d30bbd4d PR libstdc++/87431 optimise valueless_by_exception()
If a std::variant can never get into valueless state then we don't need
to do a runtime check for a valid alternative.

	PR libstdc++/87431
	* include/std/variant (_Variant_storage<true, _Types...>::_M_valid):
	Avoid runtime test when all alternatives are scalars and so cannot
	throw during initialization.

From-SVN: r264574
2018-09-25 15:59:16 +01:00
Gerald Pfeifer 44eb8fa73b codecvt.xml: Move link to "UTF-8 and Unicode FAQ" to https.
* doc/xml/manual/codecvt.xml: Move link to "UTF-8 and Unicode FAQ"
	to https.

From-SVN: r264547
2018-09-24 22:01:49 +00:00
Gerald Pfeifer 54b7d98ec4 policy_data_structures_biblio.xml: Update link to "Priority Queues and the STL".
* doc/xml/manual/policy_data_structures_biblio.xml: Update link
	to "Priority Queues and the STL".

From-SVN: r264527
2018-09-24 11:14:36 +00:00
Gerald Pfeifer 839837b036 using_exceptions.xml: Move boost.orgs link to https.
* doc/xml/manual/using_exceptions.xml: Move boost.orgs link to
	https.

From-SVN: r264515
2018-09-23 14:57:25 +00:00
François Dumont 9b29794962 re PR libstdc++/87135 ([C++17] unordered containers violate iterator validity requirements)
2018-09-21  François Dumont  <fdumont@gcc.gnu.org>

	PR libstdc++/87135
	* src/c++11/hashtable_c++0x.cc (_Prime_rehash_policy::_M_next_bkt):
	Use __builtin_floor to compute _M_next_resize.
	* testsuite/23_containers/unordered_set/hash_policy/71181.cc: Adapt.
	* testsuite/23_containers/unordered_set/hash_policy/prime_rehash.cc:
	Adapt.

From-SVN: r264494
2018-09-21 20:39:07 +00:00
Jonathan Wakely ac51f07ad2 Un-split hypot<long double> tests
Remove the hypot-long-double.cc file that used dg-xfail-run-if and
simply use the lower tolerance for double if long double is not larger
than double.

	* testsuite/26_numerics/headers/cmath/hypot-long-double.cc: Remove.
	* testsuite/26_numerics/headers/cmath/hypot.cc: Restore test for
	long double unconditionally, but use lower tolerance when
	sizeof(long double) == sizeof(double).

From-SVN: r264483
2018-09-21 16:36:53 +01:00
Christophe Lyon eb3f731774 hypot-long-double.cc: Skip on arm*.
2018-09-20  Christophe Lyon  <christophe.lyon@linaro.org>

	* testsuite/26_numerics/headers/cmath/hypot-long-double.cc: Skip
	on arm*.

From-SVN: r264443
2018-09-20 19:09:31 +02:00
Jonathan Wakely dc9acaa99b Don't use __glibcxx_assert to check class invariants
Assertions should be used to check preconditions that users must meet,
not to check whether the implementation is correct.

	* include/bits/regex_automaton.tcc (_StateSeq<_TraitsT>::_M_clone()):
	Remove __glibcxx_assert statements and use map::find instead of
	map::operator[].

From-SVN: r264422
2018-09-19 12:20:51 +01:00
François Dumont a521e62615 re PR libstdc++/87135 ([C++17] unordered containers violate iterator validity requirements)
2018-09-18  François Dumont  <fdumont@gcc.gnu.org>

	PR libstdc++/87135
	* src/c++11/hashtable_c++0x.cc:
	(_Prime_rehash_policy::_M_next_bkt): Return a prime no smaller than
	requested size, but not necessarily greater.
	(_Prime_rehash_policy::_M_need_rehash): Rehash only if target size is
	strictly greater than next resize threshold.
	* testsuite/23_containers/unordered_map/modifiers/reserve.cc: Adapt test
	to validate that there is no rehash as long as number of insertion is
	lower or equal to the reserved number of elements.

From-SVN: r264413
2018-09-18 20:36:16 +00:00
Jonathan Wakely a12c16de52 Fix location of invocable check for unique_ptr deleter
The deleter only needs to be invocable when the unique_ptr destructor
and reset member function are instantiated. In other contexts it might
not be possible to pass unique_ptr<T, D>::pointer to the deleter, if
that requires a derived-to-base conversion from T* and T is incomplete.

	* include/bits/unique_ptr.h (__uniq_ptr_impl): Remove static assertion
	checking invocable condition.
	(unique_ptr::~unique_ptr, unique_ptr::reset): Restore static assertion
	here, where types must be complete. Pass pointer to deleter as an
	rvalue.
	* testsuite/20_util/unique_ptr/requirements/incomplete.cc: New test.

From-SVN: r264399
2018-09-18 17:05:36 +01:00
Jonathan Wakely 08233f0d6e Limit workaround for Clang bug to __clang_major__ <= 7
The bug https://bugs.llvm.org/show_bug.cgi?id=33222 is now fixed on
Clang trunk, so the workaround won't be needed for Clang 8.0 and later.

	* include/std/variant (variant) [__clang__]: Limit workaround to
	Clang 7 and older.

From-SVN: r264271
2018-09-13 14:47:14 +01:00
Jonathan Wakely 9e2d426c17 PR libstdc++/87278 restore support for std::make_shared<volatile T>()
PR libstdc++/87278
	* include/bits/shared_ptr.h (make_shared): Use remove_cv instead of
	remove_const.
	* testsuite/20_util/shared_ptr/creation/87278.cc: New test.

From-SVN: r264207
2018-09-11 12:50:39 +01:00
Jonathan Wakely 86fc6ec9f3 Implement LWG 2905 changes to constrain unique_ptr constructors
LWG DR 2905 says that is_constructible_v<unique_ptr<P, D>, P, D const &>
should be false when D is not copy constructible. This commit implements
the changes from the DR and simplifies the signatures as per
https://github.com/cplusplus/draft/issues/1530

	* include/bits/unique_ptr.h (__uniq_ptr_impl): Add assertions to
	check deleter type.
	(unique_ptr::unique_ptr(pointer, const deleter_type&)): Add copy
	constructible constraint.
	(unique_ptr::unique_ptr(pointer, deleter_type&&)): Disable for
	deleters of reference type and add move constructible constraint.
	(unique_ptr::unique_ptr(pointer, remove_reference_t<deleter_type>&&)):
	Disable for deleters of non-reference type. Define as deleted.
	(unique_ptr<T[], D>): Likewise.
	* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Replace dg-error
	directives with unstable line numbers with dg-prune-output.
	* testsuite/20_util/unique_ptr/cons/cv_qual_neg.cc: Likewise.
	* testsuite/20_util/unique_ptr/cons/lwg2905.cc: New test.
	* testsuite/20_util/unique_ptr/specialized_algorithms/swap_cxx17.cc:
	Make deleter types invocable.

From-SVN: r264206
2018-09-11 11:55:49 +01:00
Jonathan Wakely cfaa1c8908 * libsupc++/cxxabi.h (__cxa_demangle): Clarify doxygen comment.
From-SVN: r264127
2018-09-05 16:18:16 +01:00
Jonathan Wakely d4baef5be8 PR libstdc++/78179 run long double tests separately
Split the long double testing into a separate file, so that we can XFAIL
targets where the long double precision doesn't meet the expected
tolerances. The float and double tests are still expefted to PASS for
all targets.

	PR libstdc++/78179
	* testsuite/26_numerics/headers/cmath/hypot-long-double.cc: New test
	that runs the long double part of hypot.cc.
	* testsuite/26_numerics/headers/cmath/hypot.cc: Disable long double
	tests unless TEST_HYPOT_LONG_DOUBLE is defined.

From-SVN: r264063
2018-09-03 15:54:28 +01:00
Jonathan Wakely 7efe0dd0b4 Fix vector::_Temporary_value::_M_ptr
The pointer argument to allocator_traits::construct and
allocator_traits::destroy should be a raw pointer, not the allocator's
pointer type. _Temporary_value::_M_ptr was returning the wrong type.

	* include/bits/stl_vector.h (vector::_Temporary_value::_M_ptr):
	Return raw pointer not allocator's pointer type.
	(vector::_Temporary_value::_M_val): Use _M_ptr.

From-SVN: r264061
2018-09-03 15:25:29 +01:00
Jonathan Wakely 83a840a91f PR libstdc++/87194 fix range insertion into maps and sets
Since C++11 range insertion and construction of maps and sets from a
pair of iterators only requires that the iterator's value_type is
convertible to the container's value_type (previously it had to be the
same).

This fixes the implementation to meet that relaxed requirement, by
defining a pair of overloads that either insert or emplace, depending on
the iterator's value_type. Instead of adding yet another overload of
_M_insert_unique and _M_insert_equal, the overloads taking iterators are
renamed to _M_insert_range_unique and _M_insert_range_equal.

	PR libstdc++/87194
	* include/bits/stl_map.h
	(map::map(initializer_list<value_type>, const Compare&, const Alloc&))
	(map::map(initializer_list<value_type>, const Alloc&))
	(map::map(InputIterator, InputIterator, const Alloc&))
	(map::map(InputIterator, InputIterator))
	(map::map(InputIterator, InputIterator, const Compare&, const Alloc&))
	(map::insert(InputIterator, InputIterator)):
	Call _M_insert_range_unique instead of _M_insert_unique.
	* include/bits/stl_multimap.h
	(multimap::multimap(initializer_list<value_type>, const C&, const A&))
	(multimap::multimap(initializer_list<value_type>, const A&))
	(multimap::multimap(InputIterator, InputIterator, const A&))
	(multimap::multimap(InputIterator, InputIterator))
	(multimap::multimap(InputIterator, InputIterator, const C&, const A&))
	(multimap::insert(InputIterator, InputIterator)): Call
	_M_insert_range_equal instead of _M_insert_equal.
	* include/bits/stl_multiset.h
	(multiset::multiset(InputIterator, InputIterator))
	(multiset::multiset(InputIterator, InputIterator, const C&, const A&))
	(multiset::multiset(initializer_list<value_type>, const C&, const A&))
	(multiset::multiset(initializer_list<value_type>, const A&))
	(multiset::multiset(InputIterator, InputIterator, const A&))
	(multiset::insert(InputIterator, InputIterator)): Call
	_M_insert_range_equal instead of _M_insert_equal.
	* include/bits/stl_set.h
	(set::set(InputIterator, InputIterator))
	(set::set(InputIterator, InputIterator, const Compare&, const Alloc&))
	(set::set(initializer_list<value_type>, const Compare&, const Alloc&))
	(set::set(initializer_list<value_type>, const Alloc&))
	(set::set(InputIterator, InputIterator, const Alloc&))
	(set::insert(InputIterator, InputIterator)):
	Call _M_insert_range_unique instead of _M_insert_unique.
	* include/bits/stl_tree.h
	[__cplusplus >= 201103L] (_Rb_tree::__same_value_type): New alias
	template for SFINAE constraints.
	[__cplusplus >= 201103L] (_Rb_tree::_M_insert_range_unique): Pair of
	constrained overloads that either insert or emplace, depending on
	iterator's value_type.
	[__cplusplus >= 201103L] (_Rb_tree::_M_insert_range_equal): Likewise.
	[__cplusplus < 201103L] (_Rb_tree::_M_insert_range_unique)
	(_Rb_tree::_M_insert_range_equal): New functions replacing range
	versions of _M_insert_unique and _M_insert_equal.
	(_Rb_tree::_M_insert_unique(_InputIterator, _InputIterator))
	(_Rb_tree::_M_insert_equal(_InputIterator, _InputIterator)): Remove.
	* testsuite/23_containers/map/modifiers/insert/87194.cc: New test.
	* testsuite/23_containers/multimap/modifiers/insert/87194.cc: New test.
	* testsuite/23_containers/multiset/modifiers/insert/87194.cc: New test.
	* testsuite/23_containers/set/modifiers/insert/87194.cc: New test.

From-SVN: r264060
2018-09-03 15:25:25 +01:00
Jonathan Wakely bc62e155e4 PR libstdc++/78595 implement insertion into maps in terms of emplace
C++14 simplified the specification of the generic insert function
templates to be equivalent to calling emplace (or emplace_hint).
Defining them in terms of emplace takes care of the problems described
in PR 78595, ensuring a single conversion to value_type is done at the
right time.

	PR libstdc++/78595
	* include/bits/stl_map.h (map::insert(_Pair&&))
	(map::insert(const_iterator, _Pair&&)): Do emplace instead of insert.
	* include/bits/stl_multimap.h (multimap::insert(_Pair&&))
	(multimap::insert(const_iterator, _Pair&&)): Likewise.
	* include/bits/unordered_map.h (unordered_map::insert(_Pair&&))
	(unordered_map::insert(const_iterator, _Pair&&))
	(unordered_multimap::insert(_Pair&&))
	(unordered_multimap::insert(const_iterator, _Pair&&)): Likewise.
	* testsuite/23_containers/map/modifiers/insert/78595.cc: New test.
	* testsuite/23_containers/multimap/modifiers/insert/78595.cc: New test.
	* testsuite/23_containers/unordered_map/modifiers/78595.cc: New test.
	* testsuite/23_containers/unordered_multimap/modifiers/78595.cc: New
	test.

From-SVN: r264059
2018-09-03 15:25:12 +01:00
François Dumont b101633fa6 2018-09-02 François Dumont <fdumont@gcc.gnu.org>
* include/debug/safe_iterator.h
	(_Safe_iterator<_It, _Seq, _Cat>::_Self): New.
	(_Safe_iterator<_It, _Seq, std::random_access_iterator_tag>::_Self):
	New.
	(_Safe_iterator<_It, _Seq, std::random_access_iterator_tag>
	::_OtherSelf): New.
	(_GLIBCXX_DEBUG_VERIFY_OPERANDS, _GLIBCXX_DEBUG_VERIFY_EQ_OPERANDS)
	(_GLIBCXX_DEBUG_VERIFY_REL_OPERANDS)
	(_GLIBCXX_DEBUG_VERIFY_DIST_OPERANDS): Define macros.
	(_Safe_iterator<_It, _Seq, std::random_access_iterator_tag>
	::operator+(difference_type)): Use latters, inline as friend.
	(_Safe_iterator<_It, _Seq, std::random_access_iterator_tag>
	::operator-(difference_type)): Likewise.
	(operator==(const _Safe_iterator<>&, const _Safe_iterator<>&)):
	Likewise.
	(operator!=(const _Safe_iterator<>&, const _Safe_iterator<>&)):
	Likewise.
	(operator<(const _Safe_iterator<>&, const _Safe_iterator<>&)): Likewise.
	(operator<=(const _Safe_iterator<>&, const _Safe_iterator<>&)):
	Likewise.
	(operator>(const _Safe_iterator<>&, const _Safe_iterator<>&)): Likewise.
	(operator>=(const _Safe_iterator<>&, const _Safe_iterator<>&)):
	Likewise.
	(operator-(const _Safe_iterator<>&, const _Safe_iterator<>&)): Likewise.
	(operator+(difference_type, const _Safe_iterator<>&)): Likewise.
	(operator-(const _Safe_iterator<>&, difference_type)): Likewise.
	* include/debug/safe_iterator.tcc
	(_Safe_iterator<>::_M_can_advance(difference_type)): Take parameter by
	copy.
	* include/debug/safe_local_iterator.h
	(_Safe_local_iterator<_It, _Seq>::_Self): New.
	(_Safe_local_iterator<_It, _Seq>::_OtherSelf): New.
	(_GLIBCXX_DEBUG_VERIFY_OPERANDS): Define macro.
	(operator==(const _Safe_local_iterator<>&,
	const _Safe_local_iterator<>&)): Use latter, inline as friend.
	(operator!=(const _Safe_local_iterator<>&,
	const _Safe_local_iterator<>&)): Likewise.
	* testsuite/util/testsuite_containers.h: Include utility.
	(struct forward_members_unordered<_Tp, bool>): Remove 2nd template
	parameter.
	(forward_members_unordered<>::forward_members_unordered(value_type&)):
	Add using namespace std::rel_ops.
	Add iterator_concept_checks on local_iterator and const_local_iterator.
	Add asserts on comparison between const_local_iterator and
	local_iterator.
	(struct forward_members_unordered<_Tp, false>): Remove partial
	specialization.
	* testsuite/23_containers/forward_list/types/1.cc: New.
	* testsuite/23_containers/list/types/1.cc: New.

From-SVN: r264039
2018-09-02 10:20:57 +00:00
Gerald Pfeifer d1f43ba348 profile_mode.xml: Update three ieeexplore.ieee.org references.
* doc/xml/manual/profile_mode.xml: Update three ieeexplore.ieee.org
	references.

From-SVN: r264031
2018-09-01 21:27:14 +00:00
Sandra Loosemore 6cec3c81a7 10.cc: Add dg-require-fileio.
2018-08-31  Sandra Loosemore  <sandra@codesourcery.com>

	libstdc++-v3/

	* testsuite/21_strings/basic_string/inserters_extractors/wchar_t/10.cc:
	Add dg-require-fileio.
	* testsuite/21_strings/basic_string/inserters_extractors/wchar_t/11.cc:
	Likewise.
	* testsuite/21_strings/basic_string/inserters_extractors/wchar_t/5.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/wchar_t/2.cc:
	Likewise.
	* testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/4.cc:
	Likewise.
	* testsuite/25_algorithms/find/istreambuf_iterators/wchar_t/2.cc:
	Likewise.
	* testsuite/27_io/basic_filebuf/close/wchar_t/12790-1.cc: Likewise.
	* testsuite/27_io/basic_filebuf/close/wchar_t/12790-2.cc: Likewise.
	* testsuite/27_io/basic_filebuf/close/wchar_t/12790-3.cc: Likewise.
	* testsuite/27_io/basic_filebuf/close/wchar_t/12790-4.cc: Likewise.
	* testsuite/27_io/basic_filebuf/seekoff/wchar_t/11543.cc: Likewise.
	* testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-1.cc:
	Likewise.
	* testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-2.cc:
	Likewise.
	* testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-3.cc:
	Likewise.
	* testsuite/27_io/basic_filebuf/seekoff/wchar_t/12790-4.cc:
	Likewise.
	* testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-1.cc:
	Likewise.
	* testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-2.cc:
	Likewise.
	* testsuite/27_io/basic_filebuf/seekpos/wchar_t/12790-4.cc:
	Likewise.
	* testsuite/27_io/basic_filebuf/underflow/wchar_t/2.cc: Likewise.
	* testsuite/27_io/basic_filebuf/underflow/wchar_t/3.cc: Likewise.
	* testsuite/27_io/basic_ifstream/cons/wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_ifstream/open/wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_istream/extractors_character/wchar_t/4.cc:
	Likewise.
	* testsuite/27_io/basic_istream/extractors_other/wchar_t/2.cc:
	Likewise.
	* testsuite/27_io/basic_istream/get/wchar_t/2.cc: Likewise.
	* testsuite/27_io/basic_istream/getline/wchar_t/5.cc: Likewise.
	* testsuite/27_io/basic_istream/ignore/wchar_t/2.cc: Likewise.
	* testsuite/27_io/basic_istream/ignore/wchar_t/3.cc: Likewise.
	* testsuite/27_io/basic_istream/seekg/wchar_t/sstream.cc: Likewise.
	* testsuite/27_io/basic_istream/tellg/wchar_t/sstream.cc: Likewise.
	* testsuite/27_io/basic_ofstream/cons/wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_ofstream/open/wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/wchar_t/1.cc:
	Likewise.
	* testsuite/27_io/objects/wchar_t/10.cc: Likewise.
	* testsuite/27_io/objects/wchar_t/12048-1.cc: Likewise.
	* testsuite/27_io/objects/wchar_t/12048-2.cc: Likewise.
	* testsuite/27_io/objects/wchar_t/12048-3.cc: Likewise.
	* testsuite/27_io/objects/wchar_t/12048-4.cc: Likewise.
	* testsuite/27_io/objects/wchar_t/12048-5.cc: Likewise.
	* testsuite/experimental/string_view/inserters/wchar_t/2.cc:
	Likewise.
	* testsuite/ext/stdio_sync_filebuf/wchar_t/1.cc: Likewise.

From-SVN: r264022
2018-08-31 15:09:47 -04:00
Sandra Loosemore 24ce3d9485 noexcept30.C: Make dependence on -fdelete-null-pointer-checks explicit.
2018-08-30  Sandra Loosemore  <sandra@codesourcery.com>

	gcc/testsuite/
	* g++.dg/cpp0x/noexcept30.C: Make dependence on
	-fdelete-null-pointer-checks explicit.
	* g++.dg/cpp1y/constexpr-82218.C: Likewise.
	* g++.dg/expr/pmf-3.C: Likewise.
	* g++.dg/ext/attr-returns-nonnull.C: Likewise.
	* g++.dg/tree-ssa/lifetime-dse1.C: Likewise.
	* g++.dg/tree-ssa/pr61034.C: Likewise.
	* gcc.dg/addr_equal-1.c: Likewise.
	* gcc.dg/ipa/pr85734.c: Likewise.
	* gcc.dg/ipa/propmalloc-1.c: Likewise.
	* gcc.dg/ipa/propmalloc-2.c: Likewise.
	* gcc.dg/ipa/propmalloc-3.c: Likewise.
	* gcc.dg/tree-ssa/pr78154.c: Likewise.
	* gcc.dg/tree-ssa/pr83648.c: Likewise.

	libstdc++-v3/
	* testsuite/experimental/propagate_const/observers/1.cc: Make
	dependence on -fdelete-null-pointer-checks explicit.

From-SVN: r264001
2018-08-30 17:27:44 -04:00
Jonathan Wakely 2fb17d2d90 Avoid undefined shifts in ceil2 operations
For values where the result cannot be represented the shift width would
be equal to the width of the type, which is undefined. Perform two
well-defined shifts instead of one possible undefined shift.

	* include/bits/hashtable_policy.h (__clp2): Fix calculation for LLP64
	targets where sizeof(size_t) > sizeof(long). Avoid undefined shifts
	of the number of bits in the type.
	* include/std/bit (__ceil2): Avoid undefined shifts.
	* testsuite/26_numerics/bit/bit.pow.two/ceil2.cc: Test values with
	the most signifiant bit set.

From-SVN: r263986
2018-08-30 16:07:35 +01:00
Jonathan Wakely 0c05d45624 Fix undefined references seen with mingw-w64
* config/abi/pre/gnu.ver: Add missing exports for mingw.

From-SVN: r263977
2018-08-30 13:28:53 +01:00
Jonathan Wakely 4a559e91b1 Fix __gnu_cxx::_Pointer_adapter for long long arithmetic
* include/ext/pointer.h (_Pointer_adapter): Define operators for
	pointer arithmetic using long long offsets.
	* testsuite/ext/ext_pointer/1.cc: Test pointer arithmetic using
	long long values.

From-SVN: r263976
2018-08-30 13:24:06 +01:00
Jonathan Wakely 9111b08384 PR libstdc++/31413 fix test failure on Debian systems
Debian uses a different D_FMT string for the zh_TW.UTF-8 locale, which
caused this test to fail. Try to detect the Debian format and adjust
the input being tested.

	PR libstdc++/31413
	* testsuite/22_locale/time_get/get_date/wchar_t/4.cc: Check D_FMT
	string for alternative format.

From-SVN: r263948
2018-08-29 11:05:55 +01:00
Jonathan Wakely dd35da2cbe PR libstdc++/87116 fix path::lexically_normal() handling of dot-dot
Previously the logic that turned "a/b/c/../.." into "a/" failed to
preserve an empty path at the end of the iteration sequence, as required
by the trailing slash. That meant the result didn't meet the class
invariants, and that "a/b/c/d/../../.." would remove four components
instead of the three that "../../.." should remove.

	PR libstdc++/87116
	* src/filesystem/std-path.cc (path::lexically_normal): When handling
	a dot-dot filename, preserve an empty final component in the iteration
	sequence.
	[_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Use preferred-separator for
	root-directory.
	* testsuite/27_io/filesystem/path/generation/normal.cc: Add new tests
	for more than two adjacent dot-dot filenames.
	[_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Replace slashes with
	preferred-separator in expected normalized strings.

From-SVN: r263922
2018-08-28 16:33:53 +01:00
Iain Sandoe ee959ecbde Don't force visibility to hidden for Darwin > 8.
PR libstdc++/70694
	* configure.host (OPT_LDFLAGS): Don't append
	-fvisibility-inlines-hidden for newer Darwin.

From-SVN: r263850
2018-08-25 09:02:28 +00:00
Marc Glisse 6eac0600c4 new(nothrow) is malloc-like
2018-08-24  Marc Glisse  <marc.glisse@inria.fr>

	PR libstdc++/86822
	* libsupc++/new (operator new(size_t, nothrow_t), operator
	new[](size_t, nothrow_t), operator new(size_t, align_val_t, nothrow_t),
	operator new[](size_t, align_val_t, nothrow_t)): Add malloc attribute.

From-SVN: r263841
2018-08-24 18:24:42 +00:00
Jonathan Wakely 9ca2ac699a Forward declare debug containers so std::pmr aliases work
Prior to this change, including a <debug/xxx> header when _GLIBCXX_DEBUG
is also defined would fail to compile in C++17 or later. The <debug/xxx>
header would include the standard <xxx> header which defined
std::pmr::xxx as an alias for std::xxx. But in Debug Mode std::xxx
refers to std::__debug::xxx which has not been defined yet (because it
is in <debug/xxx> after the inclusion of <xxx>).

This adds declarations of the debug containers before including the
non-Debug Mode <xxx> header, so that the std::pmr::xxx aliases work.

	* include/debug/deque (std::__debug::deque): Declare.
	* include/debug/forward_list (std::__debug::forward_list): Declare.
	* include/debug/list (std::__debug::list): Declare.
	* include/debug/map (std::__debug::map): Declare.
	* include/debug/set (std::__debug::set): Declare.
	* include/debug/unordered_map (std::__debug::unordered_map): Declare.
	* include/debug/unordered_set (std::__debug::unordered_set): Declare.
	* include/debug/vector (std::__debug::vector): Declare.
	* testsuite/23_containers/deque/types/pmr_typedefs_debug.cc: New test.
	* testsuite/23_containers/forward_list/pmr_typedefs_debug.cc: New
	test.
	* testsuite/23_containers/list/pmr_typedefs_debug.cc: New test.
	* testsuite/23_containers/map/pmr_typedefs_debug.cc: New test.
	* testsuite/23_containers/multimap/pmr_typedefs_debug.cc: New test.
	* testsuite/23_containers/multiset/pmr_typedefs_debug.cc: New test.
	* testsuite/23_containers/set/pmr_typedefs_debug.cc: New test.
	* testsuite/23_containers/unordered_map/pmr_typedefs_debug.cc: New
	test.
	* testsuite/23_containers/unordered_multimap/pmr_typedefs_debug.cc:
	New test.
	* testsuite/23_containers/unordered_multiset/pmr_typedefs_debug.cc:
	New test.
	* testsuite/23_containers/unordered_set/pmr_typedefs_debug.cc: New
	test.
	* testsuite/23_containers/vector/cons/destructible_debug_neg.cc:
	Adjust dg-error lineno.
	* testsuite/23_containers/vector/types/pmr_typedefs_debug.cc: New
	test.

From-SVN: r263839
2018-08-24 18:43:18 +01:00
Jonathan Wakely 763ef11bff Fix failure when -fno-rtti test is run in C++17 or later
* testsuite/util/testsuite_allocator.h (__gnu_test::memory_resource):
	Only define when RTTI is enabled.

From-SVN: r263820
2018-08-23 20:27:54 +01:00
Jonathan Wakely 568d5ee44d Define debug mode function for C++98
This function is declared unconditionally but was only defined for C++11
and later, leading to linker errors when the testsuite was run with
-std=gnu++98 -D_GLIBCXX_DEBUG added to the flags.

	* include/debug/vector (__niter_base): Define for C++98.

From-SVN: r263816
2018-08-23 16:23:31 +01:00
Jonathan Wakely c07870270a Fix C++98 tests to not use C++11 features.
* testsuite/25_algorithms/partial_sort_copy/debug/irreflexive_neg.cc:
	Fix C++98 test to not use C++11 features.
	* testsuite/25_algorithms/fill_n/2.cc: Likewise.

From-SVN: r263815
2018-08-23 16:10:45 +01:00
Jonathan Wakely 6de2ce26bc Fix comments in testsuite script
* scripts/check_compile: Fix comments.

From-SVN: r263814
2018-08-23 16:10:35 +01:00
Jonathan Wakely 21bf6b2a93 Fix C++11-ism in C++98 member function
* include/debug/string (insert(__const_iterator, _InIter, _InIter)):
	[!_GLIBCXX_USE_CXX11_ABI]: Replace use of C++11-only cbegin() with
	begin(), for C++98 compatibility.

From-SVN: r263809
2018-08-23 12:21:17 +01:00
Jonathan Wakely 3eb1eda1c8 Fix testsuite failures for __gnu_debug::string with old ABI
The __gnu_debug string (mostly) implements the C++11 API, but when it
wraps the old COW string many of the member functions in the base class
have the wrong parameter types or return types. This makes the
__gnu_debug::string type adapt itself to the base class API. This
actually makes the debug string slightly more conforming than the
underlying string type when using the old ABI.

	* include/bits/basic_string.h [_GLIBCXX_USE_CXX11_ABI]
	(basic_string::__const_iterator): Change access to protected.
	[!_GLIBCXX_USE_CXX11_ABI] (basic_string::__const_iterator): Define
	as typedef for iterator.
	* include/debug/string (__const_iterator): Use typedef from base.
	(insert(const_iterator, _CharT))
	(replace(const_iterator, const_iterator, const basic_string&))
	(replace(const_iterator, const_iterator, const _CharT*, size_type))
	(replace(const_iterator, const_iterator, const CharT*))
	(replace(const_iterator, const_iterator, size_type, _CharT))
	(replace(const_iterator, const_iterator, _InputIter, _InputIter))
	(replace(const_iterator, const_iterator, initializer_list<_CharT>)):
	Change const_iterator parameters to __const_iterator.
	(insert(iterator, size_type, _CharT)): Add C++98 overload.
	(insert(const_iterator, _InputIterator, _InputIterator)): Change
	const_iterator parameter to __const_iterator.
	[!_GLIBCXX_USE_CXX11_ABI]: Add workaround for incorrect return type
	of base's member function.
	(insert(const_iterator, size_type, _CharT)) [!_GLIBCXX_USE_CXX11_ABI]:
	Likewise.
	(insert(const_iterator, initializer_list<_CharT>))
	[!_GLIBCXX_USE_CXX11_ABI]: Likewise.
	* testsuite/21_strings/basic_string/init-list.cc: Remove effective
	target directive.

From-SVN: r263808
2018-08-23 11:51:52 +01:00
Jonathan Wakely 0aa2934aaa Remove C++14-isms from C++11 tests
* testsuite/20_util/reference_wrapper/lwg2993.cc: Fix C++11 test to
	not use C++14 feature.
	* testsuite/23_containers/list/68222_neg.cc: Likewise.

From-SVN: r263801
2018-08-23 09:26:22 +01:00
Jonathan Wakely 75224273c3 Skip tests that depend on the cxx11 std::string
* testsuite/21_strings/basic_string/init-list.cc:
	Require cxx11-abi.
	* testsuite/experimental/polymorphic_allocator/pmr_typedefs_match.cc:
	Likewise.
	* testsuite/experimental/polymorphic_allocator/pmr_typedefs_string.cc:
	Likewise.

From-SVN: r263800
2018-08-23 09:26:16 +01:00
Jonathan Wakely f73a5316b6 Fix tests that fail in C++98 mode
* testsuite/23_containers/deque/capacity/max_size.cc: Fix test for
	C++98 mode.
	* testsuite/23_containers/deque/modifiers/assign/1.cc: Likewise.
	* testsuite/23_containers/list/modifiers/assign/1.cc: Likewise.
	* testsuite/23_containers/vector/bool/modifiers/assign/1.cc: Likewise.
	* testsuite/23_containers/vector/capacity/max_size.cc: Likewise.
	* testsuite/23_containers/vector/modifiers/assign/1.cc: Likewise.

From-SVN: r263792
2018-08-23 00:43:43 +01:00
Jonathan Wakely 1bc7a28f94 PR libstdc++/87061 remove pmr type aliases for COW strings
The pmr aliases for basic_string and match_results are incompatible with
the gcc4-compatible ABI because the Copy-On-Write basic_string class
doesn't support C++11 allocators.

	PR libstdc++/87061
	* include/experimental/regex [!_GLIBCXX_USE_CXX11_ABI]
	(experimental::pmr::match_results, experimental::pmr::cmatch)
	(experimental::pmr::smatch, experimental::pmr::wcmatch)
	(experimental::pmr::wsmatch): Do not declare for gcc4-compatible ABI,
	because COW strings don't support C++11 allocator model.
	* include/experimental/string [!_GLIBCXX_USE_CXX11_ABI]
	(experimental::pmr::basic_string, experimental::pmr::string)
	(experimental::pmr::u16string, experimental::pmr::u32string)
	(experimental::pmr::wstring): Likewise.
	* include/std/regex [!_GLIBCXX_USE_CXX11_ABI] (pmr::match_results)
	(pmr::cmatch, pmr::smatch, pmr::wcmatch, pmr::wsmatch): Likewise.
	* include/std/string [!_GLIBCXX_USE_CXX11_ABI] (pmr::basic_string)
	(pmr::string, pmr::u16string, pmr::u32string, pmr::wstring): Likewise.
	* testsuite/21_strings/basic_string/types/pmr_typedefs.cc: Require
	cxx11-abi.
	* testsuite/28_regex/match_results/pmr_typedefs.cc: Likewise.

From-SVN: r263791
2018-08-22 23:54:33 +01:00
Jonathan Wakely af55b3af33 PR libstdc++/78448 limit vector::max_size and deque::max_size
The container requirements imply that max_size() can't exceed the
maximum value of the container's difference_type. Enforce this for
std::vector and std::deque, and add checks to ensure the container
doesn't grow larger than that.

	PR libstdc++/78448
	* include/bits/deque.tcc (deque::_M_range_initialize): Use
	_S_check_init_len to check size.
	(deque::_M_push_back_aux, deque::_M_push_front_aux): Throw length
	error if size would exceed max_size().
	* include/bits/stl_deque.h (_Deque_base::size_type): Remove typedef.
	(_Deque_base(_Deque_base&&, const allocator_type&, size_t)): Use
	size_t instead of size_type.
	(deq(size_type, const allocator_type&)
	(deq(size_type, const value_type&, const allocator_type&)
	(deque::_M_initialize_dispatch): Use _S_check_init_len to check size.
	(deque::max_size): Call _S_max_size.
	(deque::_S_check_init_len, deque::_S_max_size): New functions.
	* include/bits/stl_vector.h (vector(size_type, const allocator_type&))
	(vector(size_type, const value_type&, const allocator_type&))
	(vector::_M_initialize_dispatch, vector::_M_range_initialize): Use
	_S_check_init_len to check size.
	(vector::max_size): Call _S_max_size.
	(vector::_M_check_len): Prevent max from being expanded as a
	function-like macro.
	(vector::_S_check_init_len, vector::_S_max_size): New functions.
	* include/bits/vector.tcc (vector::_M_assign_aux): Use
	_S_check_init_len to check size.
	* testsuite/23_containers/deque/capacity/max_size.cc: New test.
	* testsuite/23_containers/vector/capacity/max_size.cc: New test.

From-SVN: r263789
2018-08-22 23:22:40 +01:00
François Dumont e9afbed0d6 re PR libstdc++/68222 (_Safe_iterator provides operators the wrapped iterator can't actually support)
2018-08-22  François Dumont  <fdumont@gcc.gnu.org>

	PR libstdc++/68222
	* include/debug/safe_iterator.h
	(_Safe_iterator<_It, _Sq, _Cat>): Add category template parameter.
	(_Safe_iterator<>::_Const_iterator): Remove.
	(_Safe_iterator<>::_IsConstant): New.
	(_Safe_iterator<>::_OtherIterator): New.
	(_Safe_iterator<_It, _Sq, _Cat>::_Safe_iterator<_MutIte>(
	const _Safe_iterator<_MutIte, _Sq, _Cat>&)): Add _IsConstant::__value in
	__gnu_cxx::__enable_if condition.
	(_Safe_iterator<_It, _Sq, _Cat>::_M_get_distance_to): New.
	(_Safe_iterator<_It, _Sq, _Cat>::_M_get_distance_from_begin): New.
	(_Safe_iterator<_It, _Sq, _Cat>::_M_get_distance_to_end): New.
	(_Safe_iterator<_It, _Sq, std::bidirectional_iterator_tag>): New.
	(_Safe_iterator<_It, _Sq, _Cat>::operator--()): Move...
	(_Safe_iterator<_It, _Sq, std::bidirectional_iterator_tag>
	::operator--()): ...here.
	(_Safe_iterator<_It, _Sq, _Cat>::operator--(int)): Move...
	(_Safe_iterator<_It, _Sq, std::bidirectional_iterator_tag>
	::operator--(int)): ...here.
	(_Safe_iterator<_It, _Sq, _Cat>::_M_decrementable()): Move...
	(_Safe_iterator<_It, _Sq, std::bidirectional_iterator_tag>
	::_M_decrementable()): ...here.
	(_Safe_iterator<_It, _Sq, std::random_access_iterator_tag>): New.
	(_Safe_iterator<_It, _Sq, _Cat>::operator[](const difference_type&)):
	Move...
	(_Safe_iterator<_It, _Sq, std::random_access_iterator_tag>
	::operator[](const difference_type&)): ...here.
	(_Safe_iterator<_It, _Sq, _Cat>::operator+=(const difference_type&)):
	Move...
	(_Safe_iterator<_It, _Sq, std::random_access_iterator_tag>
	::operator+=(const difference_type&)): ...here.
	(_Safe_iterator<_It, _Sq, _Cat>::operator+(const difference_type&)):
	Move...
	(_Safe_iterator<_It, _Sq, std::random_access_iterator_tag>
	::operator+(const difference_type&)): ...here.
	(_Safe_iterator<_It, _Sq, _Cat>::operator-=(const difference_type&)):
	Move...
	(_Safe_iterator<_It, _Sq, std::random_access_iterator_tag>
	::operator-=(const difference_type&)): ...here.
	(_Safe_iterator<_It, _Sq, _Cat>::operator-(const difference_type&)):
	Move...
	(_Safe_iterator<_It, _Sq, std::random_access_iterator_tag>
	::operator-(const difference_type&)): ...here.
	(operator<(const _Safe_iterator<>&, const _Safe_iterator<>&)):
	Constraint to random access iterators.
	(operator<=(const _Safe_iterator<>&, const _Safe_iterator<>&)):
	Likewise.
	(operator>(const _Safe_iterator<>&, const _Safe_iterator<>&)): Likewise.
	(operator>=(const _Safe_iterator<>&, const _Safe_iterator<>&)):
	Likewise.
	(operator-(const _Safe_iterator<>&, const _Safe_iterator<>&)): Likewise.
	(operator+(const difference_type&, const _Safe_iterator<>&)): Likewise.
	(__check_dereferenceable(const _Safe_iterator<>&)): Remove.
	(__get_distance): Remove.
	(__get_distance_from_begin): Remove.
	(__get_distance_to_end): Remove.
	(struct __is_safe_random_iterator<_Safe_iterator<>>): Remove partial
	specialization.
	(__base(const _Safe_iterator<>&, std::input_iterator_tag)): Remove.
	(__base(const _Safe_iterator<>&, std::random_access_iterator_tag)): Remove.
	(__base(const _Safe_iterator<>&)): Constraint to random access iterator.
	* include/debug/safe_iterator.tcc
	(_Safe_iterator<>::_M_get_distance_from_begin()): New.
	(_Safe_iterator<>::_M_get_distance_to_end()): New.
	(_Safe_iterator<>::_M_get_distance_to(const _Safe_iterator<>&)): New.
	(_Safe_iterator<_It, _Seq, std::random_access_iterator_tag>
	::_M_valid_range): New.
	* include/debug/safe_local_iterator.h
	(_Safe_local_iterator<>::_Const_local_iterator): Remove.
	(_Safe_local_iterator<>::_IsConstant): New.
	(_Safe_local_iterator<>::_OtherIterator): New.
	(_Safe_local_iterator<_It, _Cont>::_Safe_local_iterator<_MutIte, _Cont>(
	const _Safe_local_iterator<_MutIte, _Seq>&)): Add _IsConstant::__value
	in __gnu_cxx::__enable_if condition. If singular compare base iterator
	with _MutIte rather than _It.
	(_Safe_local_iterator<>::_S_constant): Make constexpr.
	(_Safe_local_iterator<>::_M_get_distance_to): New.
	(__check_dereferenceable(const _Safe_local_iterator<>&)): Remove.
	(__get_distance(const _Safe_local_iterator<>&,
	const _Safe_local_iterator<>&, std::input_iterator_tag)): Remove.
	(__valid_range(const _Safe_local_iterator<>&,
	const _Safe_local_iterator<>&)): New.
	* include/debug/safe_local_iterator.tcc
	(_Safe_local_iterator<>::_M_get_distance_to): New.
	* include/debug/deque (std::__debug::deque<>): Add
	::__gnu_debug::_Safe_iterator<> friend declaration.
	* include/debug/forward_list (std::__debug::forward_list<>): Likewise.
	* include/debug/list (std::__debug::list<>): Likewise.
	* include/debug/map.h (std::__debug::map<>): Likewise.
	* include/debug/multimap.h (std::__debug::multimap<>): Likewise.
	* include/debug/set.h (std::__debug::set<>): Likewise.
	* include/debug/multiset.h (std::__debug::multiset<>): Likewise.
	* include/debug/string (std::__debug::basic_string<>): Likewise.
	* include/debug/unordered_map (std::__debug::unordered_map<>): Likewise
	and add ::__gnu_debug::_Safe_local_iterator<> friend declaration.
	(std::__debug::unordered_multimap<>): Likewise.
	* include/debug/unordered_set (std::__debug::unordered_set<>): Likewise.
	(std::__debug::unordered_multiset<>): Likewise.
	* include/debug/formatter.h: Adapt.
	* include/debug/helper_functions.h
	(__gnu_debug::_Safe_local_iterator<>): Add declaration.
	(__get_distance<_Ite>(_Ite, _Ite, std::random_access_iterator_tag):
	Pass parameter by copy.
	(__get_distance<_Ite>(_Ite, _Ite, std::input_iterator_tag): Likewise.
	(__get_distance<_Ite>(_Ite, _Ite): Likewise.
	(__valid_range_aux<_Integral>): Pass _Integral by copy.
	(__valid_range<_InputIterator>): Pass _InputIterator by copy.
	(__valid_range<>(const _Safe_iterator<>&,
	const _Safe_iterator<>&, typename _Distance_traits<>::__type&)):
	Declare.
	(__valid_range(const _Safe_local_iterator<>&,
	const _Safe_local_iterator<>&, typename _Distance_traits<>::__type&)):
	Declare.
	(__valid_range<>(const _Safe_iterator<>&, const _Safe_iterator<>&)):
	Declare.
	(__valid_range(const _Safe_local_iterator<>&, const _Safe_local_iterator<>&)):
	Declare.
	(__can_advance): Adapt.
	(struct __is_safe_random_iterator<>): Remove.
	(struct _SIter_base<>): Remove.
	* include/debug/functions.h: Include <bits/stl_iterator.h>.
	(__check_dereferenceable): Remove.
	(__foreign_iterator_aux4, __foreign_iterator_aux3): Adapt.
	(__foreign_iterator_aux2, __foreign_iterator_aux): Adapt.
	(__foreign_iterator): Adapt.
	* include/debug/stl_iterator.h
	(__is_safe_random_iterator<std::reverse_iterator<>>): Remove.
	(__base(const std::reverse_iterator<_Safe_iterator<_It, _Sq>)):
	Constraint for random access iterators.
	(__niter_base): Adapt.
	* testsuite/util/testsuite_containers.h:
	Include <bits/boost_concept_check.h>.
	(iterator_concept_checks<_It, _Mutable, _Category>): New.
	(citerator<_Cont>::forward_members::forward_members()): Instantiate
	latter for container iterator and const_iterator.
	* testsuite/23_containers/list/68222_neg.cc: New.
	* testsuite/23_containers/vector/cons/destructible_debug_neg.cc: Adapt
	line number.
	* testsuite/23_containers/unordered_set/debug/debug_functions.cc:
	(test01): Remove.
	* testsuite/23_containers/vector/debug/debug_functions.cc (test01):
	Remove.

From-SVN: r263786
2018-08-22 18:51:25 +00:00
Jonathan Wakely 7c1dcf5012 PR libstdc++/77854 document size_type for containers
PR libstdc++/77854
	* doc/xml/manual/status_cxx1998.xml: Document size_type and
	difference_type for containers.
	* doc/html/*: Regenerate.

From-SVN: r263767
2018-08-22 13:11:17 +01:00
François Dumont f7191a37ee P0646R1 Improving the Return Value of Erase-Like Algorithms I
2018-08-21  François Dumont  <fdumont@gcc.gnu.org>

	P0646R1 Improving the Return Value of Erase-Like Algorithms I
	* include/debug/forward_list (forward_list::__remove_return_type):
	Define typedef as size_type or void, according to __cplusplus value.
	(_GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG): Define macro as abi-tag or
	empty, according to __cplusplus value.
	(_GLIBCXX20_ONLY): Define macro.
	(forward_list::remove, forward_list::unique): Use typedef and macro
	to change return type and add abi-tag for C++2a. Return number of
	removed elements for C++2a.
	(forward_list::remove_if<Pred>, forward_list::unique<BinPred>): Use
	typedef to change return type for C++2a. Return number of removed
	elements for C++2a.
	* include/debug/list (list::__remove_return_type): Define typedef as
	size_type or void, according to __cplusplus value.
	(_GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG): Define macro as abi-tag or
	empty, according to __cplusplus value.
	(_GLIBCXX20_ONLY): Define macro.
	(list::remove, list::unique): Use typedef and macro to change return
	type and add abi-tag for C++2a. Return number of removed elements for
	C++2a.
	(list::remove_if<Predicate>, list::unique<BinaryPredicate>): Use typedef
	to change return type for C++2a. Return number of removed elements for
	C++2a.

From-SVN: r263752
2018-08-21 19:44:41 +00:00
David Edelsohn bce17c392a * testsuite/18_support/new_nothrow.cc: XFAIL on AIX.
From-SVN: r263703
2018-08-21 10:03:16 -04:00
Jonathan Wakely 25d4036370 Remove redundant { dg-do run } directives in tests
These tests accidentally had two dg-do directives. Only the second one
is needed.

	* testsuite/26_numerics/bit/bitops.count/countl_one.cc: Remove
	redundant dg-do directive.
	* 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.

From-SVN: r263695
2018-08-21 10:34:26 +01:00
Jonathan Wakely a2c5e1ae59 PR libstdc++/86963 Remove use of __tuple_base in std::tuple
The _Tuple_impl base class can be used to disable copy/move assignment,
without requiring an extra base class.

Exception specifications on std::tuple assignment and swap functions can
be defined directly using is_nothrow_swappable, instead of querying the
base classes.

	PR libstdc++/86963
	* include/std/tuple (_Tuple_impl::operator=): Define as deleted.
	(_Tuple_impl::_M_assign): New functions to perform assignment instead
	of assignment operators.
	(_Tuple_impl::_M_swap): Remove exception specification.
	(_Tuple_impl<_Idx, _Head>): Likewise.
	(_TC::_NonNestedTuple, _TC::_NotSameTuple): Use __remove_cvref_t.
	(__tuple_base): Remove.
	(tuple, tuple<_T1, _T2>): Remove inheritance from __tuple_base.
	(tuple::operator=, tuple<_T1, _T2>::operator=): Call _M_assign.
	(tuple::swap, tuple<_T1, _T2>::swap): Define exception specification
	using __is_nothrow_swappable.
	(tuple<_T1, _T2>::tuple(_U1&&, _U2&&)): Use __remove_cvref_t.

From-SVN: r263661
2018-08-20 14:53:56 +01:00
Jonathan Wakely b655b8fc7e Refactor std::optional SFINAE constraints
* include/std/optional (_Optional_payload): Use variable templates
	for conditions in default template arguments and exception
	specifications.
	(optional): Likewise. Adjust indentation.
	(optional::__not_self, optional::__not_tag, optional::_Requires): New
	SFINAE helpers.
	(optional::optional): Use new helpers in constructor constraints.
	* include/std/type_traits (__or_v, __and_v): New variable templates.
	* testsuite/20_util/optional/cons/value_neg.cc: Change dg-error to
	dg-prune-output. Remove unused header.

From-SVN: r263657
2018-08-20 13:13:25 +01:00
François Dumont 6672e849b8 86658.cc: Use dg-options to define _GLIBCXX_DEBUG.
2018-08-18  François Dumont  <fdumont@gcc.gnu.org>

	* testsuite/25_algorithms/copy/86658.cc: Use dg-options to define
	_GLIBCXX_DEBUG.

From-SVN: r263647
2018-08-18 20:01:14 +00:00
Jonathan Wakely 478490f681 PR libstdc++/86963 Implement LWG 2729 constraints on tuple assignment
PR libstdc++/86963
	* include/std/tuple (__tuple_base): New class template with deleted
	copy assignment operator.
	(tuple, tuple<_T1, _T2>): Derive from __tuple_base<tuple> so that
	implicit copy/move assignment operator will be deleted/suppressed.
	(tuple::__assignable, tuple<_T1, _T2>::__assignable): New helper
	functions for SFINAE constraints on assignment operators.
	(tuple::__nothrow_assignable, tuple<_T1, _T2>::__nothrow_assignable):
	New helper functions for exception specifications.
	(tuple::operator=(const tuple&), tuple::operator=(tuple&&))
	(tuple<_T1, _T2>::operator=(const tuple&))
	(tuple<_T1, _T2>::operator=(tuple&&)): Change parameter types to
	__nonesuch_no_braces when the operator should be defined implicitly.
	Use __nothrow_assignable for exception specifications.
	(tuple::operator=(const tuple<_UElements...>&))
	(tuple::operator=(tuple<_UElements...>&&))
	(tuple<_T1, _T2>::operator=(const tuple<_U1, _U2>&))
	(tuple<_T1, _T2>::operator=(tuple<_U1, _U2>&&))
	(tuple<_T1, _T2>::operator=(const pair<_U1, _U2>&))
	(tuple<_T1, _T2>::operator=(pair<_U1, _U2>&&)): Constrain using
	__assignable and use __nothrow_assignable for exception
	specifications.
	* python/libstdcxx/v6/printers.py (is_specialization_of): Accept
	gdb.Type as first argument, instead of a string.
	(StdTuplePrinter._iterator._is_nonempty_tuple): New method to check
	tuple for expected structure.
	(StdTuplePrinter._iterator.__init__): Use _is_nonempty_tuple.
	* testsuite/20_util/tuple/dr2729.cc: New test.
	* testsuite/20_util/tuple/element_access/get_neg.cc: Change dg-error
	to dg-prune-output.

From-SVN: r263625
2018-08-17 18:52:49 +01:00
Jonathan Wakely 0ac40f6186 Fix warning with -Wsign-compare -Wsystem-headers
* include/tr1/legendre_function.tcc (__sph_legendre): Avoid warning
	about signed/unsigned comparison.

From-SVN: r263596
2018-08-16 18:16:33 +01:00
Jonathan Wakely 450f33d6ba Avoid deprecation warning with -Wsystem-headers
C++17 says to use std::uncaught_exceptions() here instead of
std::uncaught_exception() but since we only care whether the result is
non-zero (and we aren't planning to remove the deprecated version) we
can just keep using std::uncaught_exception() and suppress the warning.

	* include/std/ostream (basic_ostream::sentry::~sentry): Suppress
	deprecation warnings for using uncaught_exception().

From-SVN: r263593
2018-08-16 17:56:40 +01:00
Jonathan Wakely 891b1d6872 Fix bootstrap with --enable-fully-dynamic-string
PR libstdc++/86447
	* src/c++11/cow-stdexcept.cc [_GLIBCXX_FULLY_DYNAMIC_STRING]
	(logic_error::logic_error(logic_error&&))
	(logic_error::operator=(logic_error&&))
	(runtime_error::runtime_error(runtime_error&&))
	(runtime_error::operator=(runtime_error&&)): Copy strings instead of
	moving, to avoid allocating empty reps for moved-from strings.

From-SVN: r263590
2018-08-16 16:56:21 +01:00
Jonathan Wakely b8eac4d064 Fix experimental::pmr typedefs and add tests
The typedefs in <experimental/regex> and <experimental/string> don't
need to be in the __cxx11 namespace, because they are only aliases and
so will have the same mangled name as the underlying types.

	* include/experimental/regex: Remove begin/end macros for namespace.
	* include/experimental/string: Likewise.
	* testsuite/experimental/polymorphic_allocator/pmr_typedefs_deque.cc:
	New test.
	* testsuite/experimental/polymorphic_allocator/
	pmr_typedefs_forward_list.cc: New test.
	* testsuite/experimental/polymorphic_allocator/pmr_typedefs_list.cc:
	New test.
	* testsuite/experimental/polymorphic_allocator/pmr_typedefs_map.cc:
	New test.
	* testsuite/experimental/polymorphic_allocator/pmr_typedefs_match.cc:
	New test.
	* testsuite/experimental/polymorphic_allocator/
	pmr_typedefs_multimap.cc: New test.
	* testsuite/experimental/polymorphic_allocator/
	pmr_typedefs_multiset.cc: New test.
	* testsuite/experimental/polymorphic_allocator/pmr_typedefs_set.cc:
	New test.
	* testsuite/experimental/polymorphic_allocator/pmr_typedefs_string.cc:
	New test.
	* testsuite/experimental/polymorphic_allocator/
	pmr_typedefs_unordered_map.cc: New test.
	* testsuite/experimental/polymorphic_allocator/
	pmr_typedefs_unordered_multimap.cc: New test.
	* testsuite/experimental/polymorphic_allocator/
	pmr_typedefs_unordered_multiset.cc: New test.
	* testsuite/experimental/polymorphic_allocator/
	pmr_typedefs_unordered_set.cc: New test.
	* testsuite/experimental/polymorphic_allocator/pmr_typedefs_vector.cc:
	New test.

From-SVN: r263568
2018-08-15 20:46:25 +01:00
Jonathan Wakely b479fbad24 Refactor uses-allocator construction
Remove duplicated logic in experimental::pmr::polymorphic_allocator by
calling the __uses_allocator_construct helper.

Fix bugs in std::pmr::polymorphic_allocator with incorrect SFINAE
constraint and incorrect argument order.

	* include/bits/uses_allocator.h (__uses_allocator_construct): Qualify
	calls to __uses_allocator_construct_impl and __use_alloc.
	* include/experimental/memory_resource
	(polymorphic_allocator::_M_construct): Remove.
	(polymorphic_allocator::construct): Call __uses_allocator_construct.
	Qualify calls to __use_alloc.
	* include/std/memory_resource (polymorphic_allocator::construct): Fix
	type in SFINAE constraint. Use constexpr if instead of tag dispatching
	to _S_construct overloads.
	(polymorphic_allocator::construct(pair<T1, T2>*, ...)): Fix order of
	arguments to _S_construct_p.
	(polymorphic_allocator::_S_construct): Remove.
	(polymorphic_allocator::_S_construct_p): Return allocators by value
	not by reference.
	* include/std/scoped_allocator (scoped_allocator_adaptor::construct):
	Qualify calls to __use_alloc.
	* testsuite/20_util/polymorphic_allocator/construct_pair.cc: New test,
	copied from testsuite/20_util/scoped_allocator/construct_pair.cc.
	* testsuite/experimental/polymorphic_allocator/1.cc: New test.
	* testsuite/experimental/polymorphic_allocator/construct_pair.cc:
	New test.

From-SVN: r263566
2018-08-15 20:20:02 +01:00
Jonathan Wakely 25b030b85a Fix single-threaded build for targets without atomics
* src/c++17/memory_resource.cc [!_GLIBCXX_HAS_GTHREADS]
	(atomic_mem_res): Add unsynchronized definition for single-threaded.

From-SVN: r263554
2018-08-15 10:56:33 +01:00
Jonathan Wakely aa7df52e4f PR libstdc++/86954 use non-placement operator delete
As explained in the PR, there's no reason to call the nothrow delete,
we can just use the normal one.

	PR libstdc++/86954
	* include/bits/stl_tempbuf.h (return_temporary_buffer): Use
	non-placement delete.

From-SVN: r263542
2018-08-14 21:19:20 +01:00
Jonathan Wakely b8b5398cbd Simplify overflow checks in duration literals
* include/std/chrono (__check_overflow): Simplify definition.
	(_Checked_integral_constant): Remove.

From-SVN: r263537
2018-08-14 14:55:21 +01:00
Jonathan Wakely 26e130482e PR libstdc++/86846 Alternative to pointer-width atomics
Define a class using std::mutex for when std::atomic<memory_resource*>
cannot be used to implement the default memory resource.

When std::mutex constructor is not constexpr the constant_init trick
won't work, so just define a global and use init_priority for it. The
compiler warns about using reserved priority, so put the definition in a
header file using #pragma GCC system_header to suppress the warning.

	PR libstdc++/86846
	* src/c++17/default_resource.h: New file, defining default_res.
	* src/c++17/memory_resource.cc [ATOMIC_POINTER_LOCK_FREE != 2]
	(atomic_mem_res): Define alternative for atomic<memory_resource*>
	using a mutex instead of atomics.

From-SVN: r263536
2018-08-14 14:13:37 +01:00
Jonathan Wakely 484e936e88 PR libstdc++/85343 overload __throw_ios_failure to take errno
[ios::failure] p2: "When throwing ios_base::failure exceptions,
implementations should provide values of ec that identify the specific
reason for the failure."

This adds a new overload of __throw_ios_failure that can be passed
errno, to store error_code(errno, system_category()) in the exception
object.

	PR libstdc++/85343
	* acinclude.m4 (libtool_VERSION): Bump version.
	* config/abi/pre/gnu.ver (GLIBCXX_3.4.26): Add new symbol version.
	Export new symbol.
	* configure: Regenerate.
	* doc/xml/manual/abi.xml: Document new versions.
	* include/bits/fstream.tcc (basic_filebuf<C, T>::underflow)
	(basic_filebuf<C, T>::xsgetn): Pass errno to __throw_ios_failure.
	* include/bits/functexcept.h (__throw_ios_failure(const char*, int)):
	Declare new overload.
	* src/c++11/cxx11-ios_failure.cc (__ios_failure): Add new constructor
	and static member function.
	(__throw_ios_failure(const char*, int)): Define.
	* src/c++98/ios_failure.cc [!_GLIBCXX_USE_DUAL_ABI]
	(__throw_ios_failure(const char*, int)): Define.
	* testsuite/util/testsuite_abi.cc: Update known and latest versions.

From-SVN: r263535
2018-08-14 13:09:57 +01:00
Jeremy Sawicki 3ffa55de60 Rope iterators: don't retain pointers when copied
Rope iterators sometimes contain pointers to an internal buffer
inside the iterator itself.  When such an iterator is copied, the
copy incorrectly retains pointers to the original.

This patch takes the simple approach of not copying the cached
information when the internal buffer is being used, instead
requiring it to be recomputed when the copied iterator is
dereferenced.  An alternative would be to adjust the pointers so
they refer to the buffer in the copy.

2018-08-14  Jeremy Sawicki  <jeremy-gcc@sawicki.us>

	* include/ext/rope (_Rope_iterator_base(const _Rope_iterator_base&))
	(_Rope_const_iterator::operator=(const _Rope_const_iterator&))
	(_Rope_iterator::operator=(const _Rope_iterator&)): Ensure
	copied/assigned rope iterators don't retain pointers to the iterator
	they were copied/assigned from.
	* testsuite/ext/rope/7.cc: New.

From-SVN: r263534
2018-08-14 12:23:50 +01:00
Jonathan Wakely ca086dda97 PR libstdc++/45093 avoid warnings for _M_destroy_node
PR libstdc++/45093
	* include/bits/stl_tree.h (_Rb_tree::_M_destroy_node(_Link_type)):
	Combine definitions to avoid --detect-odr-violations warning.

From-SVN: r263516
2018-08-13 19:54:43 +01:00
Jonathan Wakely 2383ed0269 Minor optimisations in operator new(size_t, align_val_t)
* libsupc++/new_opa.cc (operator new(size_t, align_val_t)): Use
	__is_pow2 to check for valid alignment. Avoid branching when rounding
	size to multiple of alignment.

From-SVN: r263515
2018-08-13 19:54:38 +01:00
Jonathan Wakely 7997ede243 Add <bit> and <version> to freestanding headers
* include/Makefile.am: Install <bit> and <version> for freestanding.
	* include/Makefile.in: Regenerate.
	* testsuite/17_intro/freestanding.cc: Check for <bit> and <version>.

From-SVN: r263514
2018-08-13 19:54:34 +01:00
Jonathan Wakely 9db03bee15 Revert "libstdc++-v3: Have aligned_alloc() on Newlib"
This reverts commit r263461 / 2e920cd849b3cf0a72df4f172e27676a3e70b73f
because aligned_alloc is not defined for baremetal newlib targets, see
https://gcc.gnu.org/ml/libstdc++/2018-08/msg00065.html

Revert
2018-08-10  Sebastian Huber  <sebastian.huber@embedded-brains.de>

	PR target/85904
	* configure.ac: Define HAVE_ALIGNED_ALLOC if building for
	Newlib.
	* configure: Regenerate.

From-SVN: r263513
2018-08-13 19:54:21 +01:00
Jonathan Wakely b66e5a95c0 PR libstdc++/68210 adjust operator new and delete for LWG 206
Ensure that nothrow versions of new and delete call the ordinary
versions of new or delete, instead of calling malloc or free directly.

These files are all compiled with -std=gnu++14 so can use noexcept and
nullptr to make the code more readable.

	PR libstdc++/68210
	* doc/xml/manual/intro.xml: Document LWG 206 change.
	* libsupc++/del_op.cc: Replace _GLIBCXX_USE_NOEXCEPT with noexcept.
	* libsupc++/del_opa.cc: Likewise.
	* libsupc++/del_opant.cc: Likewise.
	* libsupc++/del_opnt.cc: Likewise. Call operator delete(ptr) instead
	of free(ptr).
	* libsupc++/del_ops.cc: Replace _GLIBCXX_USE_NOEXCEPT with noexcept.
	* libsupc++/del_opsa.cc: Likewise.
	* libsupc++/del_opva.cc: Likewise.
	* libsupc++/del_opvant.cc: Likewise.
	* libsupc++/del_opvnt.cc: Likewise. Call operator delete[](ptr)
	instead of operator delete(ptr).
	* libsupc++/del_opvs.cc: Replace _GLIBCXX_USE_NOEXCEPT with noexcept.
	* libsupc++/del_opvsa.cc: Likewise.
	* libsupc++/new_op.cc: Use __builtin_expect in check for zero size.
	* libsupc++/new_opa.cc: Use nullptr instead of literal 0.
	* libsupc++/new_opant.cc: Likewise. Replace _GLIBCXX_USE_NOEXCEPT
	with noexcept.
	* libsupc++/new_opnt.cc: Likewise. Call operator new(sz) instead of
	malloc(sz).
	* libsupc++/new_opvant.cc: Use nullptr and noexcept.
	* libsupc++/new_opvnt.cc: Likewise. Call operator new[](sz) instead of
	operator new(sz, nothrow).
	* testsuite/18_support/new_nothrow.cc: New test.

From-SVN: r263478
2018-08-10 21:20:27 +01:00
Jonathan Wakely 6894c57b1e Fix formatting in ChangeLog
From-SVN: r263476
2018-08-10 20:04:01 +01:00
Martin Liska 8b9a5b5e0e Remove not needed __builtin_expect due to malloc predictor.
2018-08-10  Martin Liska  <mliska@suse.cz>

	* libsupc++/new_op.cc (new): Remove __builtin_expect as malloc
        predictor can handle that.
	* libsupc++/new_opa.cc: Likewise.
	* libsupc++/new_opnt.cc (new): Likewise.

From-SVN: r263470
2018-08-10 11:40:40 +00:00
Sebastian Huber ee6ad3e788 libstdc++-v3: Have aligned_alloc() on Newlib
While building for Newlib, some configure checks must be hard coded.
The aligned_alloc() is supported since 2015 in Newlib.

libstdc++-v3/

	PR target/85904
	* configure.ac: Define HAVE_ALIGNED_ALLOC if building for
	Newlib.
	* configure: Regenerate.

From-SVN: r263461
2018-08-10 06:27:35 +00:00
Jonathan Wakely 1fc9d0b0e4 Define aliases for containers using polymorphic_allocator
These aliases are placed in the top-level header, e.g. <vector> not
<bits/stl_vector.h>. This ensures that they refer to whichever of
std::vector or __debug::vector or __profile::vector is in use when the
header is included.

	* include/std/deque (std::pmr::deque): Declare alias.
	* include/std/forward_list (std::pmr::forward_list): Likewise.
	* include/std/list (std::pmr::list): Likewise.
	* include/std/map (std::pmr::map, std::pmr::multimap): Likewise.
	* include/std/regex (std::pmr::match_results, std::pmr::cmatch)
	(std::pmr::smatch, std::pmr::wcmatch, std::pmr::wsmatch): Likewise.
	* include/std/set (std::pmr::set, std::pmr::multiset): Likewise.
	* include/std/string (std::pmr::basic_string, std::pmr::string)
	(std::pmr::u16string, std::pmr::u32string, std::pmr::wstring):
	Likewise.
	* include/std/unordered_map (std::pmr::unordered_map)
	(std::pmr::unordered_multimap): Likewise.
	* include/std/unordered_set (std::pmr::unordered_set)
	(std::pmr::unordered_multiset): Likewise.
	* include/std/vector (std::pmr::vector): Likewise.
	* testsuite/21_strings/basic_string/types/pmr_typedefs.cc: New test.
	* testsuite/23_containers/deque/types/pmr_typedefs.cc: New test.
	* testsuite/23_containers/forward_list/pmr_typedefs.cc: New test.
	* testsuite/23_containers/list/pmr_typedefs.cc: New test.
	* testsuite/23_containers/map/pmr_typedefs.cc: New test.
	* testsuite/23_containers/multimap/pmr_typedefs.cc: New test.
	* testsuite/23_containers/multiset/pmr_typedefs.cc: New test.
	* testsuite/23_containers/set/pmr_typedefs.cc: New test.
	* testsuite/23_containers/unordered_map/pmr_typedefs.cc: New test.
	* testsuite/23_containers/unordered_multimap/pmr_typedefs.cc: New
	test.
	* testsuite/23_containers/unordered_multiset/pmr_typedefs.cc: New
	test.
	* testsuite/23_containers/unordered_set/pmr_typedefs.cc: New test.
	* testsuite/23_containers/vector/pmr_typedefs.cc: New test.
	* testsuite/28_regex/match_results/pmr_typedefs.cc: New test.

From-SVN: r263456
2018-08-10 00:25:53 +01:00
François Dumont 29a9c26c55 2018-08-08 François Dumont <fdumont@gcc.gnu.org>
* include/bits/stl_algo.h
	(__rotate(_Ite, _Ite, _Ite, forward_iterator_tag))
	(__rotate(_Ite, _Ite, _Ite, bidirectional_iterator_tag))
	(__rotate(_Ite, _Ite, _Ite, random_access_iterator_tag)): Move code duplication...
	(rotate(_Ite, _Ite, _Ite)): ...here.
	(__stable_partition_adaptive(_FIt, _FIt, _Pred, _Dist, _Pointer, _Dist)):
	Simplify rotate call.
	(__rotate_adaptive(_BIt1, _BIt1, _BIt1, _Dist, _Dist, _Bit2, _Dist)):
	Likewise.
	(__merge_without_buffer(_BIt, _BIt, _BIt, _Dist, _Dist, _Comp)):
	Likewise.

From-SVN: r263433
2018-08-08 20:28:21 +00:00
Jonathan Wakely a801991954 Prevent internal aligned_alloc clashing with libc version
If configure fails to detect aligned_alloc we will try to define our
own in new_opa.cc but that could clash with the libcversion in
<stdlib.h>. Use a namespace to keep them distinct.

	* libsupc++/new_opa.cc (aligned_alloc): Declare inside namespace to
	avoid clashing with an ::aligned_alloc function that was not detected
	by configure.

From-SVN: r263409
2018-08-08 16:16:43 +01:00
Jonathan Wakely 2e9dae0456 Fix Docbook markup for table entry
* doc/xml/manual/using.xml: Fix markup for empty table entry.
	* doc/html/*: Regenerate.

From-SVN: r263401
2018-08-08 14:37:24 +01:00
Jonathan Wakely c0d57e63bb Add missing <experimental/numeric> header to docs
* doc/xml/manual/using.xml: Add missing header to table and fix typo.
	* doc/html/*: Regenerate.

From-SVN: r263398
2018-08-08 14:29:25 +01:00
Jonathan Wakely d3f3c68099 PR libstdc++/86597 directory_entry observers should clear error_code
PR libstdc++/86597
	* include/bits/fs_dir.h (directory_entry::_M_file_type(error_code&)):
	Clear error_code when cached type is used.
	* testsuite/27_io/filesystem/directory_entry/86597.cc: New test.

From-SVN: r263397
2018-08-08 14:09:19 +01:00
Jonathan Wakely 0ec78a9369 PR libstdc++/86874 fix std::variant::swap regression
PR libstdc++/86874
	* include/std/variant (_Copy_ctor_base::_M_destructive_move): Define
	here instead of in _Move_assign_base.
	(_Copy_ctor_base<true, _Types...>::_M_destructive_move): Define.
	(_Copy_assign_base::operator=): Use _M_destructive_move when changing
	the contained value to another alternative.
	(_Move_assign_base::operator=): Likewise.
	(_Move_assign_base::_M_destructive_move): Remove.
	* testsuite/20_util/variant/86874.cc: New test.

From-SVN: r263365
2018-08-07 20:13:26 +01:00
Jonathan Wakely 1d1b732865 PR libstdc++/86861 Meet precondition for Solaris memalign
Solaris memalign requires alignment to be at least sizeof(int), so
increase it as needed.

Also move the check for valid alignments from the fallback
implementation of aligned_alloc into operator new, as it's required for
all of aligned_alloc, memalign, posix_memalign and __aligned_malloc.
This adds a branch to check for undefined behaviour which we could just
ignore, so the check could just be removed. It should certainly be
removed if PR 86878 is implemented to issue a warning about calls with
invalid alignments.

	PR libstdc++/86861
	* libsupc++/new_opa.cc [_GLIBCXX_HAVE_MEMALIGN] (aligned_alloc):
	Replace macro with inline function.
	[__sun]: Increase alignment to meet memalign precondition.
	[!HAVE__ALIGNED_MALLOC && !HAVE_POSIX_MEMALIGN && !HAVE_MEMALIGN]
	(aligned_alloc): Move check for valid alignment to operator new.
	Remove redundant check for non-zero size, it's enforced by the caller.
	(operator new): Move check for valid alignment here. Use
	__builtin_expect on check for zero size.

From-SVN: r263360
2018-08-07 17:10:29 +01:00
Jonathan Wakely ea2329d170 Define monotonic_buffer_resource members out-of-line
Move the allocation logic into libstdc++.so so that it can be changed
without worrying about inlined code in existing binaries.

Leave do_allocate inline so that calls to it can be devirtualized, and
only the slow path needs to call into the library.

	* config/abi/pre/gnu.ver: Export monotonic_buffer_resource members.
	* include/std/memory_resource (monotonic_buffer_resource::release):
	Call _M_release_buffers to free buffers.
	(monotonic_buffer_resource::do_allocate): Call _M_new_buffer to
	allocate a new buffer from upstream.
	(monotonic_buffer_resource::_M_new_buffer): Declare.
	(monotonic_buffer_resource::_M_release_buffers): Declare.
	(monotonic_buffer_resource::_Chunk): Replace definition with
	declaration as opaque type.
	* src/c++17/memory_resource.cc (monotonic_buffer_resource::_Chunk):
	Define.
	(monotonic_buffer_resource::_M_new_buffer): Define.
	(monotonic_buffer_resource::_M_release_buffers): Define.

From-SVN: r263354
2018-08-07 12:31:16 +01:00
François Dumont dd5faf200e stl_iterator.h: Fix comment.
2018-08-05  François Dumont  <fdumont@gcc.gnu.org>

	* include/bits/stl_iterator.h: Fix comment.

From-SVN: r263318
2018-08-05 15:33:58 +00:00
Jonathan Wakely d7487e2ae8 Add workaround for non-unique errno values on AIX
* src/c++11/system_error.cc
	(system_error_category::default_error_condition): Add workaround for
	ENOTEMPTY and EEXIST having the same value on AIX.
	* testsuite/19_diagnostics/error_category/system_category.cc: Add
	extra testcases for EDOM, EILSEQ, ERANGE, EEXIST and ENOTEMPTY.

From-SVN: r263289
2018-08-03 13:53:34 +01:00
Jonathan Wakely 9fbd2e55a1 Add -D_GLIBCXX_ASSERTIONS to DEBUG_FLAGS
Enable assertions in the extra debug library built when
--enable-libstdcxx-debug is used. Replace some Debug Mode assertions
in src/c++11/futex.cc with __glibcxx_assert, because the library will
never be built with Debug Mode.

	* configure: Regenerate.
	* configure.ac: Add -D_GLIBCXX_ASSERTIONS to default DEBUG_FLAGS.
	* src/c++11/futex.cc: Use __glibcxx_assert instead of
	_GLIBCXX_DEBUG_ASSERT.

From-SVN: r263235
2018-08-01 20:52:46 +01:00
Mike Crowe 9e68aa3cc5 Use steady_clock to implement condition_variable::wait_for
The C++ standard says that std::condition_variable::wait_for should be
implemented to be equivalent to:

  return wait_until(lock, chrono::steady_clock::now() + rel_time);

But the existing implementation uses chrono::system_clock. Now that
wait_until has potentially-different behaviour for chrono::steady_clock,
let's at least try to wait using the correct clock.

2018-08-01  Mike Crowe  <mac@mcrowe.com>

	* include/std/condition_variable (wait_for): Use steady_clock.

From-SVN: r263225
2018-08-01 16:39:57 +01:00
Mike Crowe 2f59343265 Report early wakeup of condition_variable::wait_until as no_timeout
As currently implemented, condition_variable always ultimately waits
against std::chrono::system_clock. This clock can be changed in arbitrary
ways by the user which may result in us waking up too early or too late
when measured against the caller-supplied clock.

We can't (yet) do much about waking up too late (PR 41861), but
if we wake up too early we must return cv_status::no_timeout to indicate a
spurious wakeup rather than incorrectly returning cv_status::timeout.

2018-08-01  Mike Crowe  <mac@mcrowe.com>

	* include/std/condition_variable (wait_until): Only report timeout
	if we really have timed out when measured against the
	caller-supplied clock.
	* testsuite/30_threads/condition_variable/members/2.cc: Add test
	case to confirm above behaviour.

From-SVN: r263224
2018-08-01 16:39:45 +01:00
Jonathan Wakely 5ecfbf82a4 PR libstdc++/60555 std::system_category() should recognise POSIX errno values
PR libstdc++/60555
	* src/c++11/system_error.cc
	(system_error_category::default_error_condition): New override to
	check for POSIX errno values.
	* testsuite/19_diagnostics/error_category/generic_category.cc: New
	* testsuite/19_diagnostics/error_category/system_category.cc: New
	test.

From-SVN: r263210
2018-08-01 14:57:05 +01:00
Jonathan Wakely e182158261 PR libstdc++/86751 default assignment operators for std::pair
The solution for PR 77537 causes ambiguities due to the extra copy
assignment operator taking a __nonesuch_no_braces parameter. By making
the base class non-assignable we don't need the extra deleted overload
in std::pair. The copy assignment operator will be implicitly deleted
(and the move assignment operator not declared) as needed. Without the
additional user-provided operator in std::pair the ambiguity is avoided.

	PR libstdc++/86751
	* include/bits/stl_pair.h (__pair_base): New class with deleted copy
	assignment operator.
	(pair): Derive from __pair_base.
	(pair::operator=): Remove deleted overload.
	* python/libstdcxx/v6/printers.py (StdPairPrinter): New pretty printer
	so that new base class isn't shown in GDB.
	* testsuite/20_util/pair/86751.cc: New test.
	* testsuite/20_util/pair/ref_assign.cc: New test.

From-SVN: r263185
2018-07-31 23:31:20 +01:00
Jonathan Wakely ff27340046 Don't unconditionally define feature test macros in <version>
The macro definitions in <version> should depend on the same
preprocessor conditions as the original macros in other headers.
Otherwise <version> can define macros that imply the availability of
features that are not actually defined.

This fix is incomplete, as __cpp_lib_filesystem should depend on whether
libstdc++fs.a is supported, and several macros should only be defined
when _GLIBCXX_HOSTED is defined. Also, the feature test macros should
define their value as type long, but most are type int.

	* include/bits/c++config (_GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP)
	(_GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE): Move definitions here.
	(_GLIBCXX_HAVE_BUILTIN_LAUNDER): Likewise. Use !__is_identifier
	instead of __has_builtin.
	* include/std/type_traits (_GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP)
	(_GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE): Remove definitions from here.
	* include/std/version [!_GLIBCXX_HAS_GTHREADS]
	(__cpp_lib_shared_timed_mutex, __cpp_lib_scoped_lock)
	(__cpp_lib_shared_mutex): Don't define when Gthreads not in use.
	[!_GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP]
	(__cpp_lib_has_unique_object_representations): Don't define when
	builtin not available.
	[!_GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE] (__cpp_lib_is_aggregate):
	Likewise.
	[!_GLIBCXX_HAVE_BUILTIN_LAUNDER] (__cpp_lib_launder): Likewise.
	* libsupc++/new (_GLIBCXX_HAVE_BUILTIN_LAUNDER): Remove definition
	from here.

From-SVN: r263184
2018-07-31 23:31:14 +01:00
Jonathan Wakely 3e64a626d7 Improve libstdc++ docs w.r.t newer C++ standards
Instead of repeating all the old headers for every new standard I've
changed the docs to only list the new headers for each standard.

	* doc/xml/manual/test.xml: Improve documentation on writing tests for
	newer standards.
	* doc/xml/manual/using.xml: Document all headers for C++11 and later.
	* doc/html/*: Regenerate.

From-SVN: r263163
2018-07-31 16:02:32 +01:00
Jonathan Wakely 77a6c969e9 Replace safe bool idiom with explicit operator bool
* include/ext/pointer.h [__cplusplus >= 201103L]
	(_Pointer_adapter::operator bool): Add explicit conversion operator
	to replace safe bool idiom.

From-SVN: r263162
2018-07-31 15:55:36 +01:00
Jonathan Wakely a64ede727f PR libstdc++/86734 make reverse_iterator::operator-> more robust
Implement the proposed resolution from LWG 1052, which also resolves
DR 2118 by avoiding taking the address in the first place.

	PR libstdc++/86734
	* include/bits/stl_iterator.h (reverse_iterator::operator->): Call
	_S_to_pointer (LWG 1052, LWG 2118).
	(reverse_iterator::_S_to_pointer): Define overloaded helper functions.
	* testsuite/24_iterators/reverse_iterator/dr1052.cc: New test.
	* testsuite/24_iterators/reverse_iterator/dr2188.cc: New test.

From-SVN: r263074
2018-07-30 18:13:05 +01:00
Jonathan Wakely 1b3b888d11 Add workaround for aligned_alloc bug on AIX
20_util/memory_resource/2.cc FAILs on AIX 7.2.0.0, because aligned_alloc
incorrectly requires the alignment to be a multiple of sizeof(void*).

This adds a workaround to the operator new overload taking an alignment
value, to increase the alignment (and size) if needed.

	* libsupc++/new_opa.cc (operator new(size_t, align_val_t)): Add
	workaround for aligned_alloc bug on AIX.
	* testsuite/18_support/new_aligned.cc: New test.

From-SVN: r263073
2018-07-30 18:12:44 +01:00
Marek Polacek ccfe77fa22 * 30_threads/condition_variable_any/cond.cc: New test.
From-SVN: r263022
2018-07-26 21:23:12 +00:00
Marek Polacek 4b8b1f5997 * src/c++98/locale_init.cc: Fix #ifdef condition.
From-SVN: r263016
2018-07-26 16:36:50 +00:00
Jonathan Wakely 49ba258864 Add missing dg-require-cstdint directives to tests
* testsuite/18_support/aligned_alloc/aligned_alloc.cc: Add
	dg-require-cstdint directive.
	* testsuite/20_util/allocator/overaligned.cc: Likewise.
	* testsuite/20_util/any/cons/aligned.cc: Likewise.
	* testsuite/20_util/monotonic_buffer_resource/allocate.cc: Likewise.
	* testsuite/20_util/monotonic_buffer_resource/deallocate.cc: Likewise.
	* testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc:
	Likewise.
	* testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc: Likewise.
	* testsuite/23_containers/list/modifiers/insert/25288.cc: Likewise.
	* testsuite/23_containers/set/allocator/move_assign.cc: Likewise.
	* testsuite/25_algorithms/make_heap/complexity.cc: Likewise.
	* testsuite/25_algorithms/pop_heap/complexity.cc: Require cstdint and
	random_device effective-target.
	* testsuite/25_algorithms/push_heap/complexity.cc: Likewise.
	* testsuite/25_algorithms/sample/1.cc: Require cstdint.
	* testsuite/25_algorithms/sample/2.cc: Likewise.
	* testsuite/25_algorithms/sort_heap/complexity.cc: Require cstdint
	and random_device.
	* testsuite/26_numerics/headers/random/types_std_c++0x.cc: Require
	cstdint.
	* testsuite/26_numerics/random/chi_squared_distribution/83833.cc:
	Likewise.
	* testsuite/26_numerics/random/discard_block_engine/requirements/
	constexpr_data.cc: Likewise.
	* testsuite/26_numerics/random/discard_block_engine/requirements/
	constexpr_functions.cc: Likewise.
	* testsuite/26_numerics/random/independent_bits_engine/requirements/
	constexpr_functions.cc: Likewise.
	* testsuite/26_numerics/random/linear_congruential_engine/requirements/
	constexpr_data.cc: Likewise.
	* testsuite/26_numerics/random/linear_congruential_engine/requirements/
	constexpr_functions.cc: Likewise.
	* testsuite/26_numerics/random/mersenne_twister_engine/requirements/
	constexpr_data.cc: Likewise.
	* testsuite/26_numerics/random/mersenne_twister_engine/requirements/
	constexpr_functions.cc: Likewise.
	* testsuite/26_numerics/random/pr60037-neg.cc: Likewise.
	* testsuite/26_numerics/random/seed_seq/cons/65631.cc: Likewise.
	* testsuite/26_numerics/random/shuffle_order_engine/requirements/
	constexpr_data.cc: Add dg-require-cstdint directive.
	* testsuite/26_numerics/random/shuffle_order_engine/requirements/
	constexpr_functions.cc: Likewise.
	* testsuite/26_numerics/random/subtract_with_carry_engine/requirements/
	constexpr_data.cc: Likewise.
	* testsuite/26_numerics/random/subtract_with_carry_engine/requirements/
	constexpr_functions.cc: Likewise.
	* testsuite/26_numerics/random/uniform_real_distribution/operators/
	64351.cc: Likewise.
	* testsuite/29_atomics/headers/atomic/types_std_c++0x.cc: Likewise.
	* testsuite/experimental/algorithm/sample-2.cc: Likewise.
	* testsuite/experimental/algorithm/sample.cc: Likewise.
	* testsuite/experimental/algorithm/search.cc: Likewise.
	* testsuite/experimental/algorithm/shuffle.cc: Likewise.
	* testsuite/experimental/any/cons/aligned.cc: Likewise.
	* testsuite/experimental/memory_resource/new_delete_resource.cc:
	Likewise.
	* testsuite/experimental/memory_resource/resource_adaptor.cc: Likewise.
	* testsuite/experimental/random/randint.cc: Likewise.
	* testsuite/experimental/source_location/1.cc: Likewise.
	* testsuite/ext/bitmap_allocator/overaligned.cc: Likewise.
	* testsuite/ext/malloc_allocator/overaligned.cc: Likewise.
	* testsuite/ext/mt_allocator/overaligned.cc: Likewise.
	* testsuite/ext/new_allocator/overaligned.cc: Likewise.
	* testsuite/ext/pb_ds/regression/hash_map_rand.cc: Likewise.
	* testsuite/ext/pb_ds/regression/hash_set_rand.cc: Likewise.
	* testsuite/ext/pb_ds/regression/list_update_map_rand.cc: Likewise.
	* testsuite/ext/pb_ds/regression/list_update_set_rand.cc: Likewise.
	* testsuite/ext/pb_ds/regression/priority_queue_rand.cc: Likewise.
	* testsuite/ext/pb_ds/regression/tree_map_rand.cc: Likewise.
	* testsuite/ext/pb_ds/regression/tree_set_rand.cc: Likewise.
	* testsuite/ext/pb_ds/regression/trie_map_rand.cc: Likewise.
	* testsuite/ext/pb_ds/regression/trie_set_rand.cc: Likewise.
	* testsuite/ext/pool_allocator/overaligned.cc: Likewise.
	* testsuite/ext/throw_allocator/check_allocate_max_size.cc: Likewise.
	* testsuite/ext/throw_allocator/check_deallocate_null.cc: Likewise.
	* testsuite/ext/throw_allocator/check_delete.cc: Likewise.
	* testsuite/ext/throw_allocator/check_new.cc: Likewise.
	* testsuite/ext/throw_allocator/deallocate_global.cc: Likewise.
	* testsuite/ext/throw_allocator/deallocate_local.cc: Likewise.
	* testsuite/ext/throw_allocator/explicit_instantiation.cc: Likewise.
	* testsuite/ext/throw_allocator/variadic_construct.cc: Likewise.
	* testsuite/tr1/8_c_compatibility/cinttypes/functions.cc: Likewise.

From-SVN: r263008
2018-07-26 15:03:28 +01:00
Jonathan Wakely 47114f2d02 Remove dg-require-cstdint directive from tests
Tests for components which are no longer dependent on
_GLIBCXX_USE_C99_STDINT_TR1 do not need to require <cstdint>.

	* testsuite/30_threads/recursive_mutex/cons/1.cc: Likewise.
	* testsuite/30_threads/recursive_mutex/cons/assign_neg.cc: Likewise.
	* testsuite/30_threads/recursive_mutex/cons/copy_neg.cc: Likewise.
	* testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc:
	Likewise.
	* testsuite/30_threads/recursive_mutex/lock/1.cc: Likewise.
	* testsuite/30_threads/recursive_mutex/native_handle/1.cc: Likewise.
	* testsuite/30_threads/recursive_mutex/native_handle/typesizes.cc:
	Likewise.
	* testsuite/30_threads/recursive_mutex/requirements/standard_layout.cc:
	Likewise.
	* testsuite/30_threads/recursive_mutex/requirements/typedefs.cc:
	Likewise.
	* testsuite/30_threads/recursive_mutex/try_lock/1.cc: Likewise.
	* testsuite/30_threads/recursive_mutex/try_lock/2.cc: Likewise.
	* testsuite/30_threads/recursive_mutex/unlock/1.cc: Likewise.
	* testsuite/30_threads/recursive_mutex/unlock/2.cc: Likewise.
	* testsuite/30_threads/recursive_timed_mutex/cons/1.cc: Likewise.
	* testsuite/30_threads/recursive_timed_mutex/cons/assign_neg.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/cons/copy_neg.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/dest/
	destructor_locked.cc: Likewise.
	* testsuite/30_threads/recursive_timed_mutex/lock/1.cc: Likewise.
	* testsuite/30_threads/recursive_timed_mutex/lock/2.cc: Likewise.
	* testsuite/30_threads/recursive_timed_mutex/native_handle/1.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/native_handle/
	typesizes.cc: Likewise.
	* testsuite/30_threads/recursive_timed_mutex/requirements/typedefs.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/try_lock/1.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/try_lock/2.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/try_lock_for/1.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/try_lock_for/2.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/try_lock_for/3.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/try_lock_until/1.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/try_lock_until/2.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/unlock/1.cc: Likewise.
	* testsuite/30_threads/recursive_timed_mutex/unlock/2.cc: Likewise.
	* testsuite/30_threads/scoped_lock/cons/1.cc: Likewise.
	* testsuite/30_threads/scoped_lock/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/30_threads/scoped_lock/requirements/typedefs.cc: Likewise.
	* testsuite/30_threads/shared_future/cons/assign.cc: Likewise.
	* testsuite/30_threads/shared_future/cons/constexpr.cc: Likewise.
	* testsuite/30_threads/shared_future/cons/copy.cc: Likewise.
	* testsuite/30_threads/shared_future/cons/default.cc: Likewise.
	* testsuite/30_threads/shared_future/cons/move.cc: Likewise.
	* testsuite/30_threads/shared_future/cons/move_assign.cc: Likewise.
	* testsuite/30_threads/shared_future/members/45133.cc: Likewise.
	* testsuite/30_threads/shared_future/members/get.cc: Likewise.
	* testsuite/30_threads/shared_future/members/get2.cc: Likewise.
	* testsuite/30_threads/shared_future/members/valid.cc: Likewise.
	* testsuite/30_threads/shared_future/members/wait.cc: Likewise.
	* testsuite/30_threads/shared_future/members/wait_for.cc: Likewise.
	* testsuite/30_threads/shared_future/members/wait_until.cc: Likewise.
	* testsuite/30_threads/shared_future/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/30_threads/shared_lock/cons/1.cc: Likewise.
	* testsuite/30_threads/shared_lock/cons/2.cc: Likewise.
	* testsuite/30_threads/shared_lock/cons/3.cc: Likewise.
	* testsuite/30_threads/shared_lock/cons/4.cc: Likewise.
	* testsuite/30_threads/shared_lock/cons/5.cc: Likewise.
	* testsuite/30_threads/shared_lock/cons/6.cc: Likewise.
	* testsuite/30_threads/shared_lock/locking/1.cc: Likewise.
	* testsuite/30_threads/shared_lock/locking/2.cc: Likewise.
	* testsuite/30_threads/shared_lock/locking/3.cc: Likewise.
	* testsuite/30_threads/shared_lock/locking/4.cc: Likewise.
	* testsuite/30_threads/shared_lock/modifiers/1.cc: Likewise.
	* testsuite/30_threads/shared_lock/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/30_threads/shared_lock/requirements/typedefs.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.
	* testsuite/30_threads/shared_timed_mutex/cons/1.cc: Likewise.
	* testsuite/30_threads/shared_timed_mutex/cons/assign_neg.cc: Likewise.
	* testsuite/30_threads/shared_timed_mutex/cons/copy_neg.cc: Likewise.
	* testsuite/30_threads/shared_timed_mutex/requirements/
	standard_layout.cc: Likewise.
	* testsuite/30_threads/shared_timed_mutex/try_lock/1.cc: Likewise.
	* testsuite/30_threads/shared_timed_mutex/try_lock/2.cc: Likewise.
	* testsuite/30_threads/shared_timed_mutex/try_lock/3.cc: Likewise.
	* testsuite/30_threads/shared_timed_mutex/unlock/1.cc: Likewise.
	* testsuite/30_threads/this_thread/1.cc: Likewise.
	* testsuite/30_threads/this_thread/2.cc: Likewise.
	* testsuite/30_threads/this_thread/3.cc: Likewise.
	* testsuite/30_threads/this_thread/4.cc: Likewise.
	* testsuite/30_threads/this_thread/58038.cc: Likewise.
	* testsuite/30_threads/thread/70503.cc: Likewise.
	* testsuite/30_threads/thread/84532.cc: Likewise.
	* testsuite/30_threads/thread/adl.cc: Likewise.
	* testsuite/30_threads/thread/cons/1.cc: Likewise.
	* testsuite/30_threads/thread/cons/2.cc: Likewise.
	* testsuite/30_threads/thread/cons/3.cc: Likewise.
	* testsuite/30_threads/thread/cons/4.cc: Likewise.
	* testsuite/30_threads/thread/cons/49668.cc: Likewise.
	* testsuite/30_threads/thread/cons/5.cc: Likewise.
	* testsuite/30_threads/thread/cons/6.cc: Likewise.
	* testsuite/30_threads/thread/cons/7.cc: Likewise.
	* testsuite/30_threads/thread/cons/8.cc: Likewise.
	* testsuite/30_threads/thread/cons/84535.cc: Likewise.
	* testsuite/30_threads/thread/cons/9.cc: Likewise.
	* testsuite/30_threads/thread/cons/assign_neg.cc: Likewise.
	* testsuite/30_threads/thread/cons/copy_neg.cc: Likewise.
	* testsuite/30_threads/thread/cons/lwg2097.cc: Likewise.
	* testsuite/30_threads/thread/cons/moveable.cc: Likewise.
	* testsuite/30_threads/thread/cons/terminate.cc: Likewise.
	* testsuite/30_threads/thread/id/operators.cc: Likewise.
	* testsuite/30_threads/thread/members/1.cc: Likewise.
	* testsuite/30_threads/thread/members/2.cc: Likewise.
	* testsuite/30_threads/thread/members/3.cc: Likewise.
	* testsuite/30_threads/thread/members/4.cc: Likewise.
	* testsuite/30_threads/thread/members/5.cc: Likewise.
	* testsuite/30_threads/thread/members/hardware_concurrency.cc:
	Likewise.
	* testsuite/30_threads/thread/native_handle/cancel.cc: Likewise.
	* testsuite/30_threads/thread/swap/1.cc: Likewise.
	* testsuite/30_threads/timed_mutex/cons/1.cc: Likewise.
	* testsuite/30_threads/timed_mutex/cons/assign_neg.cc: Likewise.
	* testsuite/30_threads/timed_mutex/cons/copy_neg.cc: Likewise.
	* testsuite/30_threads/timed_mutex/dest/destructor_locked.cc: Likewise.
	* testsuite/30_threads/timed_mutex/lock/1.cc: Likewise.
	* testsuite/30_threads/timed_mutex/native_handle/1.cc: Likewise.
	* testsuite/30_threads/timed_mutex/native_handle/typesizes.cc:
	Likewise.
	* testsuite/30_threads/timed_mutex/requirements/
	standard_layout.cc: Likewise.
	* testsuite/30_threads/timed_mutex/requirements/typedefs.cc: Likewise.
	* testsuite/30_threads/timed_mutex/try_lock/1.cc: Likewise.
	* testsuite/30_threads/timed_mutex/try_lock/2.cc: Likewise.
	* testsuite/30_threads/timed_mutex/try_lock_for/1.cc: Likewise.
	* testsuite/30_threads/timed_mutex/try_lock_for/2.cc: Likewise.
	* testsuite/30_threads/timed_mutex/try_lock_for/3.cc: Likewise.
	* testsuite/30_threads/timed_mutex/try_lock_until/1.cc: Likewise.
	* testsuite/30_threads/timed_mutex/try_lock_until/2.cc: Likewise.
	* testsuite/30_threads/timed_mutex/try_lock_until/57641.cc: Likewise.
	* testsuite/30_threads/timed_mutex/unlock/1.cc: Likewise.
	* testsuite/30_threads/timed_mutex/unlock/2.cc: Likewise.
	* testsuite/30_threads/try_lock/1.cc: Likewise.
	* testsuite/30_threads/try_lock/2.cc: Likewise.
	* testsuite/30_threads/try_lock/3.cc: Likewise.
	* testsuite/30_threads/try_lock/4.cc: Likewise.
	* testsuite/30_threads/unique_lock/cons/1.cc: Likewise.
	* testsuite/30_threads/unique_lock/cons/2.cc: Likewise.
	* testsuite/30_threads/unique_lock/cons/3.cc: Likewise.
	* testsuite/30_threads/unique_lock/cons/4.cc: Likewise.
	* testsuite/30_threads/unique_lock/cons/5.cc: Likewise.
	* testsuite/30_threads/unique_lock/cons/6.cc: Likewise.
	* testsuite/30_threads/unique_lock/locking/1.cc: Likewise.
	* testsuite/30_threads/unique_lock/locking/2.cc: Likewise.
	* testsuite/30_threads/unique_lock/locking/3.cc: Likewise.
	* testsuite/30_threads/unique_lock/locking/4.cc: Likewise.
	* testsuite/30_threads/unique_lock/modifiers/1.cc: Likewise.
	* testsuite/30_threads/unique_lock/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/30_threads/unique_lock/requirements/typedefs.cc: Likewise.

From-SVN: r263007
2018-07-26 15:03:01 +01:00
Jonathan Wakely c37f07c4d8 Remove dg-require-cstdint directive from tests
Tests for components which are no longer dependent on
_GLIBCXX_USE_C99_STDINT_TR1 do not need to require <cstdint>.

	* testsuite/30_threads/async/42819.cc: Remove dg-require-cstdint
	directive.
	* testsuite/30_threads/async/49668.cc: Likewise.
	* testsuite/30_threads/async/54297.cc: Likewise.
	* testsuite/30_threads/async/84532.cc: Likewise.
	* testsuite/30_threads/async/any.cc: Likewise.
	* testsuite/30_threads/async/async.cc: Likewise.
	* testsuite/30_threads/async/except.cc: Likewise.
	* testsuite/30_threads/async/forced_unwind.cc: Likewise.
	* testsuite/30_threads/async/launch.cc: Likewise.
	* testsuite/30_threads/async/lwg2021.cc: Likewise.
	* testsuite/30_threads/async/sync.cc: Likewise.
	* testsuite/30_threads/call_once/39909.cc: Likewise.
	* testsuite/30_threads/call_once/49668.cc: Likewise.
	* testsuite/30_threads/call_once/60497.cc: Likewise.
	* testsuite/30_threads/call_once/call_once1.cc: Likewise.
	* testsuite/30_threads/call_once/constexpr.cc: Likewise.
	* testsuite/30_threads/call_once/dr2442.cc: Likewise.
	* testsuite/30_threads/call_once/once_flag.cc: Likewise.
	* testsuite/30_threads/condition_variable/54185.cc: Likewise.
	* testsuite/30_threads/condition_variable/cons/1.cc: Likewise.
	* testsuite/30_threads/condition_variable/cons/assign_neg.cc:
	Likewise.
	* testsuite/30_threads/condition_variable/cons/copy_neg.cc: Likewise.
	* testsuite/30_threads/condition_variable/members/1.cc: Likewise.
	* testsuite/30_threads/condition_variable/members/2.cc: Likewise.
	* testsuite/30_threads/condition_variable/members/3.cc: Likewise.
	* testsuite/30_threads/condition_variable/members/53841.cc: Likewise.
	* testsuite/30_threads/condition_variable/members/68519.cc: Likewise.
	* testsuite/30_threads/condition_variable/native_handle/typesizes.cc:
	Likewise.
	* testsuite/30_threads/condition_variable/requirements/
	standard_layout.cc: Likewise.
	* testsuite/30_threads/condition_variable/requirements/typedefs.cc:
	* Likewise.
	* testsuite/30_threads/condition_variable_any/50862.cc: Likewise.
	* testsuite/30_threads/condition_variable_any/53830.cc: Likewise.
	* testsuite/30_threads/condition_variable_any/cons/1.cc: Likewise.
	* testsuite/30_threads/condition_variable_any/cons/assign_neg.cc:
	Likewise.
	* testsuite/30_threads/condition_variable_any/cons/copy_neg.cc:
	Likewise.
	* testsuite/30_threads/condition_variable_any/members/1.cc: Likewise.
	* testsuite/30_threads/condition_variable_any/members/2.cc: Likewise.
	* testsuite/30_threads/future/cons/assign_neg.cc: Likewise.
	* testsuite/30_threads/future/cons/constexpr.cc: Likewise.
	* testsuite/30_threads/future/cons/copy_neg.cc: Likewise.
	* testsuite/30_threads/future/cons/default.cc: Likewise.
	* testsuite/30_threads/future/cons/move.cc: Likewise.
	* testsuite/30_threads/future/cons/move_assign.cc: Likewise.
	* testsuite/30_threads/future/members/45133.cc: Likewise.
	* testsuite/30_threads/future/members/get.cc: Likewise.
	* testsuite/30_threads/future/members/get2.cc: Likewise.
	* testsuite/30_threads/future/members/share.cc: Likewise.
	* testsuite/30_threads/future/members/valid.cc: Likewise.
	* testsuite/30_threads/future/members/wait.cc: Likewise.
	* testsuite/30_threads/future/members/wait_for.cc: Likewise.
	* testsuite/30_threads/future/members/wait_until.cc: Likewise.
	* testsuite/30_threads/future/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/30_threads/headers/condition_variable/types_std_c++0x.cc:
	Likewise.
	* testsuite/30_threads/headers/future/types_std_c++0x.cc: Likewise.
	* testsuite/30_threads/headers/mutex/types_std_c++0x.cc: Likewise.
	* testsuite/30_threads/headers/thread/std_c++0x_neg.cc: Likewise.
	* testsuite/30_threads/headers/thread/types_std_c++0x.cc: Likewise.
	* testsuite/30_threads/lock/1.cc: Likewise.
	* testsuite/30_threads/lock/2.cc: Likewise.
	* testsuite/30_threads/lock/3.cc: Likewise.
	* testsuite/30_threads/lock/4.cc: Likewise.
	* testsuite/30_threads/lock_guard/cons/1.cc: Likewise.
	* testsuite/30_threads/lock_guard/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/30_threads/lock_guard/requirements/typedefs.cc: Likewise.
	* testsuite/30_threads/mutex/cons/1.cc: Likewise.
	* testsuite/30_threads/mutex/cons/assign_neg.cc: Likewise.
	* testsuite/30_threads/mutex/cons/constexpr.cc: Likewise.
	* testsuite/30_threads/mutex/cons/copy_neg.cc: Likewise.
	* testsuite/30_threads/mutex/dest/destructor_locked.cc: Likewise.
	* testsuite/30_threads/mutex/lock/1.cc: Likewise.
	* testsuite/30_threads/mutex/native_handle/1.cc: Likewise.
	* testsuite/30_threads/mutex/native_handle/typesizes.cc: Likewise.
	* testsuite/30_threads/mutex/requirements/standard_layout.cc::
	Likewise.
	* testsuite/30_threads/mutex/requirements/typedefs.cc: Likewise.
	* testsuite/30_threads/mutex/try_lock/1.cc: Likewise.
	* testsuite/30_threads/mutex/try_lock/2.cc: Likewise.
	* testsuite/30_threads/mutex/unlock/1.cc: Likewise.
	* testsuite/30_threads/mutex/unlock/2.cc: Likewise.
	* testsuite/30_threads/once_flag/cons/constexpr.cc: Likewise.
	* testsuite/30_threads/packaged_task/49668.cc: Likewise.
	* testsuite/30_threads/packaged_task/60564.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/1.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/2.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/3.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/56492.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/alloc.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/alloc2.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/alloc_min.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/assign_neg.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/copy_neg.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/move.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/move_assign.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/at_thread_exit.cc:
	Likewise.
	* testsuite/30_threads/packaged_task/members/get_future.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/get_future2.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/invoke.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/invoke2.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/invoke3.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/invoke4.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/invoke5.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/reset.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/reset2.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/swap.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/valid.cc: Likewise.
	* testsuite/30_threads/packaged_task/requirements/
	explicit_instantiation.cc: Likewise.
	* testsuite/30_threads/packaged_task/uses_allocator.cc: Likewise.
	* testsuite/30_threads/promise/60966.cc: Likewise.
	* testsuite/30_threads/promise/69106.cc: Likewise.
	* testsuite/30_threads/promise/cons/1.cc: Likewise.
	* testsuite/30_threads/promise/cons/alloc.cc: Likewise.
	* testsuite/30_threads/promise/cons/alloc2.cc: Likewise.
	* testsuite/30_threads/promise/cons/alloc_min.cc: Likewise.
	* testsuite/30_threads/promise/cons/assign_neg.cc: Likewise.
	* testsuite/30_threads/promise/cons/copy_neg.cc: Likewise.
	* testsuite/30_threads/promise/cons/move.cc: Likewise.
	* testsuite/30_threads/promise/cons/move_assign.cc: Likewise.
	* testsuite/30_threads/promise/members/at_thread_exit.cc: Likewise.
	* testsuite/30_threads/promise/members/at_thread_exit2.cc: Likewise.
	* testsuite/30_threads/promise/members/get_future.cc: Likewise.
	* testsuite/30_threads/promise/members/get_future2.cc: Likewise.
	* testsuite/30_threads/promise/members/set_exception.cc: Likewise.
	* testsuite/30_threads/promise/members/set_exception2.cc: Likewise.
	* testsuite/30_threads/promise/members/set_value.cc: Likewise.
	* testsuite/30_threads/promise/members/set_value2.cc: Likewise.
	* testsuite/30_threads/promise/members/set_value3.cc: Likewise.
	* testsuite/30_threads/promise/members/swap.cc: Likewise.
	* testsuite/30_threads/promise/requirements/explicit_instantiation.cc:
	* Likewise.
	* testsuite/30_threads/promise/uses_allocator.cc: Likewise.

From-SVN: r263006
2018-07-26 15:02:42 +01:00
Jonathan Wakely 2b69e93cd1 Remove dg-require-cstdint directive from tests
Tests for components which are no longer dependent on
_GLIBCXX_USE_C99_STDINT_TR1 do not need to require <cstdint>.

	* testsuite/18_support/numeric_limits/char16_32_t.cc: Qualify names
	from namespace std.
	* testsuite/20_util/align/2.cc: Remove dg-require-cstdint directive.
	* testsuite/20_util/duration/arithmetic/1.cc: Likewise.
	* testsuite/20_util/duration/arithmetic/2.cc: Likewise.
	* testsuite/20_util/duration/arithmetic/dr2020.cc: Likewise.
	* testsuite/20_util/duration/arithmetic/dr934-1.cc: Likewise.
	* testsuite/20_util/duration/arithmetic/dr934-2.cc: Likewise.
	* testsuite/20_util/duration/comparison_operators/1.cc: Likewise.
	* testsuite/20_util/duration/cons/1.cc: Likewise.
	* testsuite/20_util/duration/cons/1_neg.cc: Likewise.
	* testsuite/20_util/duration/cons/2.cc: Likewise.
	* testsuite/20_util/duration/cons/54025.cc: Likewise.
	* testsuite/20_util/duration/cons/dr974_neg.cc: Likewise.
	* testsuite/20_util/duration/requirements/explicit_instantiation/
	explicit_instantiation.cc: Likewise.
	* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Likewise.
	* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Likewise.
	* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Likewise.
	* testsuite/20_util/make_signed/requirements/typedefs-4.cc: Likewise.
	* testsuite/20_util/ratio/comparisons/comp1.cc: Likewise.
	* testsuite/20_util/ratio/comparisons/comp2.cc: Likewise.
	* testsuite/20_util/ratio/comparisons/comp3.cc: Likewise.
	* testsuite/20_util/ratio/cons/cons1.cc: Likewise.
	* testsuite/20_util/ratio/operations/45866.cc: Likewise.
	* testsuite/20_util/ratio/operations/47913.cc: Likewise.
	* testsuite/20_util/ratio/operations/53840.cc: Likewise.
	* testsuite/20_util/ratio/operations/ops1.cc: Likewise.
	* testsuite/20_util/shared_ptr/atomic/3.cc: Likewise.
	* testsuite/20_util/system_clock/1.cc: Likewise.
	* testsuite/20_util/time_point/1.cc: Likewise.
	* testsuite/20_util/time_point/2.cc: Likewise.
	* testsuite/20_util/time_point/3.cc: Likewise.
	* testsuite/20_util/time_point/requirements/explicit_instantiation/
	explicit_instantiation.cc: Likewise.
	* testsuite/21_strings/basic_string/requirements/
	explicit_instantiation/char16_t/1.cc: Likewise.
	* testsuite/21_strings/basic_string/requirements/
	explicit_instantiation/char32_t/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/char_traits/requirements/
	explicit_instantiation/char16_t/1.cc: Likewise.
	* testsuite/21_strings/char_traits/requirements/
	explicit_instantiation/char32_t/1.cc: Likewise.
	* testsuite/21_strings/headers/string/types_std_c++0x.cc: Likewise.
	* testsuite/22_locale/codecvt/char16_t.cc: Likewise.
	* testsuite/22_locale/codecvt/char32_t.cc: Likewise.
	* testsuite/22_locale/codecvt/codecvt_utf16/requirements/1.cc:
	Likewise.
	* testsuite/22_locale/codecvt/codecvt_utf8/requirements/1.cc:
	Likewise.
	* testsuite/22_locale/codecvt/codecvt_utf8_utf16/requirements/1.cc:
	Likewise.
	* testsuite/22_locale/codecvt/utf8.cc: Likewise.
	* testsuite/23_containers/vector/bool/72847.cc: Likewise.
	* testsuite/23_containers/vector/debug/multithreaded_swap.cc:
	Likewise.
	* testsuite/experimental/string_view/requirements/
	explicit_instantiation/char16_t/1.cc: Likewise.
	* testsuite/experimental/string_view/requirements/
	explicit_instantiation/char32_t/1.cc: Likewise.
	* testsuite/ext/vstring/requirements/explicit_instantiation/char16_t/
	1.cc: Likewise.
	* testsuite/ext/vstring/requirements/explicit_instantiation/char32_t/
	1.cc: Likewise.

From-SVN: r263005
2018-07-26 15:02:26 +01:00
Jonathan Wakely 54c674327f Add missing checks for _GLIBCXX_USE_C99_STDINT_TR1
The throw_allocator extension depends on <tr1/random> which depends on
_GLIBCXX_USE_C99_STDINT_TR1.

The Transactional Memory support uses fixed-width integer types from
<stdint.h>.

	* include/ext/throw_allocator.h [!_GLIBCXX_USE_C99_STDINT_TR1]
	(random_condition, throw_value_random, throw_allocator_random)
	(std::hash<throw_value_random>): Do not define when <tr1/random> is
	not usable.
	* src/c++11/cow-stdexcept.cc [!_GLIBCXX_USE_C99_STDINT_TR1]: Do not
	define transactional memory support when <stdint.h> is not usable.

From-SVN: r263004
2018-07-26 15:02:11 +01:00
Jonathan Wakely 4957b284f1 Modify some library internals to work without <stdint.h>
std::__detail::__clp2 used uint_fast32_t and uint_fast64_t without
checking _GLIBCXX_USE_C99_STDINT_TR1 which was a potential bug. A
simpler implementation based on the new std::__ceil2 code performs
better and doesn't depend on <stdint.h> types.

std::align and other C++11 functions in <memory> where unnecessarily
missing when _GLIBCXX_USE_C99_STDINT_TR1 was not defined.

	* include/bits/hashtable_policy.h (__detail::__clp2): Use faster
	implementation that doesn't depend on <stdint.h> types.
	* include/std/memory (align) [!_GLIBCXX_USE_C99_STDINT_TR1]: Use
	std::size_t when std::uintptr_t is not usable.
	[!_GLIBCXX_USE_C99_STDINT_TR1] (pointer_safety, declare_reachable)
	(undeclare_reachable, declare_no_pointers, undeclare_no_pointers):
	Define independent of _GLIBCXX_USE_C99_STDINT_TR1.

From-SVN: r263003
2018-07-26 15:02:05 +01:00
Jonathan Wakely 612c9c702e Remove char16_t and char32_t dependency on <stdint.h>
The char16_t and char32_t types are automatically defined by the
compiler and do not depend on support in <stdint.h>. The char_traits
specializations depend on uint_leastNN_t but can be made to work anyway
by using the predefined macros, or as a last resort make_unsigned.

	* include/bits/basic_string.h [!_GLIBCXX_USE_C99_STDINT_TR1]
	(hash<u16string>, hash<u32string>): Remove dependency on
	_GLIBCXX_USE_C99_STDINT_TR1.
	* include/bits/char_traits.h [!_GLIBCXX_USE_C99_STDINT_TR1]
	(char_traits<char16_t>, char_traits<char32_t>): Remove dependency on
	_GLIBCXX_USE_C99_STDINT_TR1. Use __UINT_LEAST16_TYPE__ and
	__UINT_LEAST32_TYPE__ or make_unsigned when <stdint.h> is not usable.
	* include/bits/codecvt.h [!_GLIBCXX_USE_C99_STDINT_TR1]
	(codecvt<char16_t, char, mbstate_t>)
	(codecvt<char32_t, char, mbstate_t>)
	(codecvt_byname<char16_t, char, mbstate_t>)
	(codecvt_byname<char32_t, char, mbstate_t>): Remove dependency
	on _GLIBCXX_USE_C99_STDINT_TR1.
	* include/bits/locale_facets.h [!_GLIBCXX_USE_C99_STDINT_TR1]
	(_GLIBCXX_NUM_UNICODE_FACETS): Likewise.
	* include/bits/stringfwd.h [!_GLIBCXX_USE_C99_STDINT_TR1]
	(char_traits<char16_t>, char_traits<char32_t>)
	(basic_string<char16_t>, basic_string<char32_t>): Remove dependency
	on _GLIBCXX_USE_C99_STDINT_TR1.
	* include/experimental/string_view [!_GLIBCXX_USE_C99_STDINT_TR1]
	(u16string_view, u32string_view, hash<u16string_view>)
	(hash<u32string_view>, operator""sv(const char16_t, size_t))
	(operator""sv(const char32_t, size_t)): Likewise.
	* include/ext/vstring.h [!_GLIBCXX_USE_C99_STDINT_TR1]
	(hash<__u16vstring>, hash<__u32vstring>): Likewise.
	* include/ext/vstring_fwd.h [!_GLIBCXX_USE_C99_STDINT_TR1]
	(__u16vstring, __u16sso_string, __u16rc_string, __u32vstring)
	(__u32sso_string, __u32rc_string): Likewise.
	* include/std/codecvt [!_GLIBCXX_USE_C99_STDINT_TR1] (codecvt_mode)
	(codecvt_utf8, codecvt_utf16, codecvt_utf8_utf16): Likewise.
	* include/std/string_view [!_GLIBCXX_USE_C99_STDINT_TR1]
	(u16string_view, u32string_view, hash<u16string_view>)
	(hash<u32string_view>, operator""sv(const char16_t, size_t))
	(operator""sv(const char32_t, size_t)): Likewise.
	* src/c++11/codecvt.cc: Likewise.
	* src/c++98/locale_init.cc: Likewise.
	* src/c++98/localename.cc: Likewise.

From-SVN: r263002
2018-07-26 15:02:01 +01:00
Jonathan Wakely 8ba7f29e3d Remove <chrono> dependency on _GLIBCXX_USE_C99_STDINT_TR1
By adding fallback definitions of std::intmax_t and std::uintmax_t it's
possible to define <ratio> without _GLIBCXX_USE_C99_STDINT_TR1. This in
turn allows most of <chrono> to be defined, which removes the dependency
on _GLIBCXX_USE_C99_STDINT_TR1 for all of the C++11 concurrency features.

The compiler defines __INTMAX_TYPE__ and __UINTMAX_TYPE__
unconditionally so it should be safe to rely on them.

	* include/bits/atomic_futex.h [!_GLIBCXX_USE_C99_STDINT_TR1]
	(__atomic_futex_unsigned_base): Remove dependency on
	_GLIBCXX_USE_C99_STDINT_TR1 macro.
	* include/bits/unique_lock.h [!_GLIBCXX_USE_C99_STDINT_TR1]
	(unique_lock): Remove dependency on _GLIBCXX_USE_C99_STDINT_TR1.
	* include/c_global/cstdint [!_GLIBCXX_USE_C99_STDINT_TR1] (intmax_t)
	(uintmax_t): Define using predefined macros.
	* include/std/chrono [!_GLIBCXX_USE_C99_STDINT_TR1] (duration)
	(time_point, system_clock, high_resolution_clock, steady_clock): Remove
	dependency on _GLIBCXX_USE_C99_STDINT_TR1 macro.
	(nanoseconds, microseconds, milliseconds, seconds, minutes, hours):
	[!_GLIBCXX_USE_C99_STDINT_TR1]: Define using __INT64_TYPE__ or
	long long when <stdint.h> is not usable.
	* include/std/condition_variable [!_GLIBCXX_USE_C99_STDINT_TR1]
	(condition_variable, condition_variable_any): Remove dependency on
	_GLIBCXX_USE_C99_STDINT_TR1.
	* include/std/future [!_GLIBCXX_USE_C99_STDINT_TR1] (future, promise)
	(packaged_task, async): Likewise.
	* include/std/mutex [!_GLIBCXX_USE_C99_STDINT_TR1] (recursive_mutex)
	(timed_mutex, recursive_timed_mutex, try_lock, lock, scoped_lock)
	(once_flag, call_once): Likewise.
	* include/std/ratio [!_GLIBCXX_USE_C99_STDINT_TR1] (ratio): Likewise.
	* include/std/shared_mutex [!_GLIBCXX_USE_C99_STDINT_TR1]
	(shared_mutex, shared_timed_mutex, shared_lock): Likewise.
	* include/std/thread [!_GLIBCXX_USE_C99_STDINT_TR1] (thread)
	(this_thread::get_id, this_thread::yield, this_thread::sleep_for)
	(this_thread::sleep_until): Likewise.
	* src/c++11/chrono.cc: Remove dependency on
	_GLIBCXX_USE_C99_STDINT_TR1 macro.
	* src/c++11/condition_variable.cc: Likewise.
	* src/c++11/futex.cc: Likewise.
	* src/c++11/future.cc: Likewise.
	* src/c++11/mutex.cc: Likewise.
	* src/c++11/thread.cc: Likewise.
	* testsuite/20_util/duration/literals/range_neg.cc: Adjust dg-error.
	* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Likewise.
	* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Likewise.
	* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Likewise.
	* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Likewise.
	* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Likewise.

From-SVN: r263001
2018-07-26 15:01:55 +01:00
Rainer Orth 864f020a10 xfail experimental/memory_resource/new_delete_resource.cc on 32-bit Solaris/x86 (PR libstdc++/77691)
PR libstdc++/77691
	* testsuite/experimental/memory_resource/new_delete_resource.cc:
	xfail execution on 32-bit Solaris/x86.

From-SVN: r263000
2018-07-26 12:36:21 +00:00
Marc Glisse e98edc20cd optimize std::vector move assignment
2018-07-26  Marc Glisse  <marc.glisse@inria.fr>

	* include/bits/stl_vector.h (_Vector_impl_data::_M_copy_data): New.
	(_Vector_impl_data::_M_swap_data): Use _M_copy_data.
	(vector::_M_move_assign): Reorder the swaps.

From-SVN: r262998
2018-07-26 12:01:14 +00:00
Jonathan Wakely aea3722348 PR libstdc++/86676 another alignment fix for test
PR libstdc++/86676
	* testsuite/20_util/monotonic_buffer_resource/release.cc: Request
	same alignment for post-release allocation.

From-SVN: r262984
2018-07-26 00:38:17 +01:00
Jonathan Wakely 17a6321210 PR libstdc++/86676 Do not assume stack buffer is aligned
PR libstdc++/86676
	* testsuite/20_util/monotonic_buffer_resource/release.cc: Allow for
	buffer being misaligned and so returned pointer not being at start.

From-SVN: r262980
2018-07-25 21:23:07 +01:00
Jonathan Wakely 16d0ab7f44 Add missing header for std::max_align_t
* include/experimental/memory_resource: Include <cstddef> header.

From-SVN: r262977
2018-07-25 18:24:49 +01:00
Jonathan Wakely a9d49e9681 Add new src/c++17 directory to list in acinclude.m4
* acinclude.m4 (glibcxx_SUBDIRS): Add src/c++17.
	* src/Makefile.am: Add comment.
	* src/c++17/Makefile.in: Regenerate.

From-SVN: r262964
2018-07-25 12:01:39 +01:00
Jonathan Wakely 1fba0606b8 Move std::unique_lock definition to a separate header
This will allow std::mutex and std::lock_guard to be used elsewhere in
the library without pulling in the whole of <chrono>.

Previously the whole of <bits/std_mutex.h> was conditional on the
_GLIBCXX_USE_C99_STDINT_TR1 macro, but only the std::unique_lock members
that use <chrono> facilities should depend on that. std::mutex only
needs to depend on _GLIBCXX_HAS_GTHREADS and std::lock_guard can be
defined unconditionally.

Some parts of <bits/std_mutex.h> and <mutex> are based on code in
<ext/concurrence.h> which dates from 2003. However, the std::unique_lock
implementation was added in 2008 by r135007, without using any earlier
code. Therefore the new header file has copyright years 2008-2018.

	* include/Makefile.am: Add new <bits/unique_lock.h> header.
	* include/Makefile.in: Regenerate.
	* include/bits/std_mutex.h [!_GLIBCXX_USE_C99_STDINT_TR1] (mutex)
	(lock_guard): Define independent of _GLIBCXX_USE_C99_STDINT_TR1.
	(unique_lock): Move definition to ...
	* include/bits/unique_lock.h: New header.
	[!_GLIBCXX_USE_C99_STDINT_TR1] (unique_lock): Define unconditionally.
	[_GLIBCXX_USE_C99_STDINT_TR1] (unique_lock(mutex_type&, time_point))
	(unique_lock(mutex_type&, duration), unique_lock::try_lock_until)
	(unique_lock::try_lock_for): Define only when <chrono> is usable.
	* include/std/condition_variable: Include <bits/unique_lock.h>.
	* include/std/mutex: Likewise.

From-SVN: r262963
2018-07-25 11:40:12 +01:00
Jonathan Wakely dfaa3c47cc Add initial version of C++17 <memory_resource> header
This is missing the synchronized_pool_resource and
unsynchronized_pool_resource classes but is otherwise complete.

This is a new implementation, not based on the existing code in
<experimental/memory_resource>, but memory_resource and
polymorphic_allocator ended up looking almost the same anyway.

The constant_init kluge in src/c++17/memory_resource.cc is apparently
due to Richard Smith and ensures that the objects are constructed during
constant initialiation phase and not destroyed (because the
constant_init destructor doesn't destroy the union member and the
storage is not reused).

	* config/abi/pre/gnu.ver: Export new symbols.
	* configure: Regenerate.
	* include/Makefile.am: Add new <memory_resource> header.
	* include/Makefile.in: Regenerate.
	* include/precompiled/stdc++.h: Include <memory_resource> for C++17.
	* include/std/memory_resource: New header.
	(memory_resource, polymorphic_allocator, new_delete_resource)
	(null_memory_resource, set_default_resource, get_default_resource)
	(pool_options, monotonic_buffer_resource): Define.
	* src/Makefile.am: Add c++17 directory.
	* src/Makefile.in: Regenerate.
	* src/c++11/Makefile.am: Fix comment.
	* src/c++17/Makefile.am: Add makefile for new sub-directory.
	* src/c++17/Makefile.in: Generate.
	* src/c++17/memory_resource.cc: New.
	(newdel_res_t, null_res_t, constant_init, newdel_res, null_res)
	(default_res, new_delete_resource, null_memory_resource)
	(set_default_resource, get_default_resource): Define.
	* testsuite/20_util/memory_resource/1.cc: New test.
	* testsuite/20_util/memory_resource/2.cc: New test.
	* testsuite/20_util/monotonic_buffer_resource/1.cc: New test.
	* testsuite/20_util/monotonic_buffer_resource/allocate.cc: New test.
	* testsuite/20_util/monotonic_buffer_resource/deallocate.cc: New test.
	* testsuite/20_util/monotonic_buffer_resource/release.cc: New test.
	* testsuite/20_util/monotonic_buffer_resource/upstream_resource.cc:
	New test.
	* testsuite/20_util/polymorphic_allocator/1.cc: New test.
	* testsuite/20_util/polymorphic_allocator/resource.cc: New test.
	* testsuite/20_util/polymorphic_allocator/select.cc: New test.
	* testsuite/util/testsuite_allocator.h (__gnu_test::memory_resource):
	Define concrete memory resource for testing.
	(__gnu_test::default_resource_mgr): Define RAII helper for changing
	default resource.

From-SVN: r262953
2018-07-24 22:09:55 +01:00
Jonathan Wakely e874029dd9 PR libstdc++/86658 fix __niter_wrap to not copy invalid iterators
An output iterator passed as the unused first argument to __niter_wrap
might have already been invalidated, so don't copy it.

	PR libstdc++/86658
	* include/bits/stl_algobase.h (__niter_wrap<_Iterator>): Pass unused
	parameter by reference, to avoid copying invalid iterators.
	* testsuite/25_algorithms/copy/86658.cc: New test.

From-SVN: r262952
2018-07-24 21:49:10 +01:00
Jonathan Wakely 337dc30754 Minor refactoring in <bit> header
* include/std/bit (__countl_zero, __countr_zero, __popcount): Use
	local variables for number of digits instead of type aliases.
	(__log2p1): Remove redundant branch also checked in __countl_zero.

From-SVN: r262947
2018-07-24 14:51:50 +01:00
Jonathan Wakely 4f3c75ba3a Reorder conditions in uses-allocator construction helper
The erased_type condition is only true for code using the Library
Fundamentals TS, so assume it's less common and only check it after
checking for convertibility.

This does mean for types using erased_type the more expensive
convertibility check is done first, but such types are rare.

	* include/bits/uses_allocator.h (__is_erased_or_convertible): Reorder
	conditions. Add comments.
	* testsuite/20_util/uses_allocator/69293_neg.cc: Adjust dg-error line.
	* testsuite/20_util/uses_allocator/cons_neg.cc: Likewise.
	* testsuite/20_util/scoped_allocator/69293_neg.cc: Likewise.

From-SVN: r262945
2018-07-24 14:03:25 +01:00
Jonathan Wakely 7a4be38049 Make __resource_adaptor_imp usable with C++17 memory_resource
By making the memory_resource base class a template parameter the
__resource_adaptor_imp can be used to adapt an allocator into a
std::pmr::memory_resource instead of experimental::pmr::memory_resource.

	* include/experimental/memory_resource: Adjust comments and
	whitespace.
	(__resource_adaptor_imp): Add second template parameter for type of
	memory resource base class.
	(memory_resource): Define default constructor, destructor, copy
	constructor and copy assignment operator as defaulted.

From-SVN: r262944
2018-07-24 14:03:20 +01:00
Jonathan Wakely 0568ade6f8 PR libstdc++/70966 fix lifetime bug for default resource
PR libstdc++/70966
	* include/experimental/memory_resource (__get_default_resource): Use
	placement new to create an object with dynamic storage duration.

From-SVN: r262943
2018-07-24 14:03:11 +01:00
Jonathan Wakely 2d6c8eea1d PR libstdc++/70940 optimize pmr::resource_adaptor for allocators using malloc
pmr::resource_adaptor can avoid allocating an oversized buffer and doing
manual alignment within that buffer when the wrapped allocator is known
to always meet the requested alignment. Specifically, if the allocator
is known to use malloc or new directly, then we can call the allocator
directly for any fundamental alignment.

	PR libstdc++/70940
	* include/experimental/memory_resource
	(__resource_adaptor_common::_AlignMgr::_M_unadjust): Add assertion.
	(__resource_adaptor_common::__guaranteed_alignment): New helper to
	give maximum alignment an allocator guarantees. Specialize for known
	allocators using new and malloc.
	(__resource_adaptor_imp::do_allocate): Use __guaranteed_alignment.
	(__resource_adaptor_imp::do_deallocate): Likewise.
	* testsuite/experimental/memory_resource/new_delete_resource.cc:
	Check that new and delete are called with expected sizes.

From-SVN: r262935
2018-07-23 20:40:28 +01:00
Jonathan Wakely bf0086f1c8 PR libstdc++/86595 add missing noexcept
PR libstdc++/86595
	* include/bits/fs_dir.h (directory_entry::refresh(error_code&)): Add
	noexcept.

From-SVN: r262904
2018-07-20 12:52:54 +01:00
Fangrui Song 2143168e07 Use default visibility to work around clang -fvisibility-inlines-hidden bug
Clang (including trunk and many older versions) incorrectly marks static
local variables (__tag) hidden when -fvisibility-inlines-hidden is used.
This can lead to multiple instances of __tag when shares objects are used.

2018-07-20  Fangrui Song  <maskray@google.com>

	* include/bits/shared_ptr_base.h (_Sp_make_shared_tag::_S_ti): Use
	_GLIBCXX_VISIBILITY(default).

From-SVN: r262903
2018-07-20 12:24:55 +01:00
Jonathan Wakely afa07bdd78 PR libstdc++/86603 Move __cpp_lib_list_remove_return_type macro
This should only be defined for C++2a not C++17.

	PR libstdc++/86603
	* include/std/version: Move __cpp_lib_list_remove_return_type macro.

From-SVN: r262902
2018-07-20 12:24:38 +01:00
Jonathan Wakely c01f9216b7 Simplify the base characteristics for some type traits
* include/std/type_traits (__is_member_object_pointer_helper): Use
	__not_<is_function<_Tp>>::type instead of integral_constant.
	(__is_member_function_pointer_helper): Likewise for
	is_function<_Tp>::type.
	(is_compund): Likewise for __not_<is_fundamental<_Tp>>::type.
	(__do_is_nt_destructible_impl): Use __bool_constant and reindent.
	(is_trivially_constructible): Remove redundant use of
	is_constructible.
	(__is_trivially_copy_assignable_impl): Remove redundant use of
	is_copy_assignable.
	(__is_trivially_move_assignable_impl): Remove redundant use of
	is_move_assignable.
	(is_trivially_destructible): Use __bool_constant.
	* testsuite/20_util/is_trivially_assignable/value.cc: Add some more
	tests for scalar types.

From-SVN: r262889
2018-07-19 20:12:37 +01:00
Glen Joseph Fernandes 20a0c4e3dc Use __builtin_memmove for trivially copyable types
2018-07-19  Glen Joseph Fernandes  <glenjofe@gmail.com>

	* include/bits/stl_algobase.h (__copy_move_a): Used
	__is_trivially_copyable.
	(__copy_move_backward_a): Likewise.
	* testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc:
	New test.

From-SVN: r262884
2018-07-19 19:58:09 +01:00
Jonathan Wakely c3be340eb6 PR libstdc++/86450 use -Wabi=2 and simplify -Werror use
Use -Wabi=2 to fix warnings about -Wabi having no effect on its own.
This requires suppressing two warnings in src/c++11/debug.cc which do
not affect the library ABI.

Previously libstdc++ defaulted to --enable-werror but the -Werror flag
was not actually added unless --enable-maintainer-mode was used. This is
not documented and not the expected behaviour. This removes any special
treatment for maintainer-mode, makes -Werror depend directly on
--enable-werror, and changes the default to --enable-werror=no.

	PR libstdc++/86450
	* acinclude.m4 (GLIBCXX_CHECK_COMPILER_FEATURES): Don't define WERROR.
	(GLIBCXX_EXPORT_FLAGS): Use -Wabi=2 instead of -Wabi.
	* configure: Regenerate.
	* configure.ac: Change GLIBCXX_ENABLE_WERROR default to "no".
	* doc/Makefile.in: Regenerate.
	* fragment.am: Set WERROR_FLAG to -Werror instead of $(WERROR).
	* include/Makefile.in: Regenerate.
	* libsupc++/Makefile.in: Regenerate.
	* po/Makefile.in: Regenerate.
	* python/Makefile.in: Regenerate.
	* src/Makefile.in: Regenerate.
	* src/c++11/Makefile.in: Regenerate.
	* src/c++11/debug.cc: Use diagnostic pragmas to suppress warnings
	from -Wabi=2 that don't affect exported symbols.
	* src/c++98/Makefile.in: Regenerate.
	* src/filesystem/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.

From-SVN: r262824
2018-07-17 14:18:47 +01:00
Jonathan Wakely 79a88477ad Remove unused explicit instantiation of __bind_simple
The explicit instantiation of std::call_once used to require an
instantiation of __bind_simple, but call_once was changed by r241031 to
not use __bind_simple. The instantiation of __bind_simple (and the
definitions it uses) are not needed. They should have been removed
instead of doing the changes in r241111 that kept them compiling.

The use of std::call_once by _Async_state_common::_M_join can be
simplified to use a pointer instead of reference wrapper. The call_once
symbol isn't exported so the change isn't visible outside the library.

	* src/c++11/compatibility-thread-c++0x.cc [_GLIBCXX_SHARED]
	(_Async_state_common::_M_join): Simplify use of std::call_once and
	corresponding explicit instantiation.
	(_Maybe_wrap_member_pointer, _Bind_simple, _Bind_simple_helper)
	(__bind_simple): Remove definitions and explicit instantiation that
	are not required by exported symbols.

From-SVN: r262823
2018-07-17 14:16:51 +01:00
Jonathan Wakely b8c9cad352 * scripts/create_testsuite_files: Fix typo in comment.
From-SVN: r262741
2018-07-16 18:42:20 +01:00
Jonathan Wakely 20b47be02c PR libstdc++/86537 remove less<shared_ptr<T>> partial specialization
The standard doesn't specify this partial specialization (it was
required after the changes in N2637 but then should have been removed
following LWG 1262). Its presence is observable because it causes
different results when operator< has been overloaded for a shared_ptr
specialization.

	PR libstdc++/86537
	* include/bits/shared_ptr.h (less<shared_ptr<_Tp>>): Remove
	non-standard partial specialization.
	* include/bits/shared_ptr_base.h (_Sp_less): Remove class definition.
	(less<__shared_ptr<_Tp, _Lp>): Remove partial specialization.
	* testsuite/20_util/shared_ptr/comparison/86537.cc: New test.

From-SVN: r262739
2018-07-16 18:13:41 +01:00
Andreas Krebbel 9c588dbeda S/390: libstdc++: 64 and 32 bit baseline update
libstdc++-v3/ChangeLog:

2018-07-16  Andreas Krebbel  <krebbel@linux.ibm.com>

	* config/abi/post/s390-linux-gnu/baseline_symbols.txt: Update.
	* config/abi/post/s390x-linux-gnu/32/baseline_symbols.txt: Update.
	* config/abi/post/s390x-linux-gnu/baseline_symbols.txt: Update.

From-SVN: r262681
2018-07-16 07:58:01 +00:00
François Dumont 1e736a9531 functions.h (__gnu_debug::__check_string): Move...
2018-07-06  François Dumont  <fdumont@gcc.gnu.org>

	* include/debug/functions.h (__gnu_debug::__check_string): Move...
	* include/debug/string (__gnu_debug::__check_string): ... here.
	(_GLIBCXX_DEBUG_VERIFY_STR_COND_AT): New.
	(__glibcxx_check_string_n_constructor): New.
	(__gnu_debug::basic_string<>(const _CharT*, size_type, const _Alloc&)):
	Use latter.
	(__glibcxx_check_string_constructor): New.
	(__gnu_debug::basic_string<>(const _CharT*, const _Alloc&)):
	Use latter.
	* testsuite/21_strings/basic_string/debug/1_neg.cc: New.
	* testsuite/21_strings/basic_string/debug/2_neg.cc: New.

From-SVN: r262480
2018-07-06 17:02:33 +00:00
Jonathan Wakely 5840e3b8ff PR libstdc++/84928 use std::move in <numeric> algorithms
P0616R0 altered the effects of the <numeric> algorithms to use std::move
on the accumulator values (resolving LWG 2055). This implements the
change for C++2a, but retains the previous behaviour for older
standards.

	* include/bits/stl_numeric.h (_GLIBCXX_MOVE_IF_20): Define macro to
	conditionally move, according to __cplusplus value.
	(accumulate, inner_product, partial_sum, adjacent_difference): Use
	_GLIBCXX_MOVE_IF_20.
	* testsuite/26_numerics/accumulate/lwg2055.cc: New test.
	* testsuite/26_numerics/adjacent_difference/lwg2055.cc: New test.
	* testsuite/26_numerics/inner_product/lwg2055.cc: New test.
	* testsuite/26_numerics/partial_sum/lwg2055.cc: New test.

From-SVN: r262477
2018-07-06 15:16:13 +01:00
Jonathan Wakely f1b3168d7f Simplify linker script patterns for std::exception_ptr
* config/abi/pre/gnu.ver: Use wildcards to combine related patterns.

From-SVN: r262475
2018-07-06 13:52:41 +01:00
Jonathan Wakely 97271bd88f P0935R0 Eradicating unnecessarily explicit default constructors
This is the last remaining piece of P0935R0. This adds a default
constructor to each of the streambuf and stream types in <sstream> so
that default construction does not use the 'explicit' constructor that
has a single, defaulted argument.

	P0935R0 Eradicating unnecessarily explicit default constructors
	* config/abi/pre/gnu.ver: Tighten existing patterns and export new
	default constructor symbols.
	* include/std/sstream (basic_stringbuf, basic_istringstream)
	(basic_ostringstream, basic_stringstream): Remove default arguments
	from explicit constructors taking ios_base::openmode and add separate
	non-explicit default constructors.
	* testsuite/27_io/basic_istringstream/cons/default.cc: New.
	* testsuite/27_io/basic_ostringstream/cons/default.cc: New.
	* testsuite/27_io/basic_stringstream/cons/default.cc: New.
	* testsuite/27_io/basic_stringbuf/cons/char/default.cc: New.
	* testsuite/27_io/basic_stringbuf/cons/wchar_t/default.cc: New.

From-SVN: r262474
2018-07-06 13:39:02 +01:00
Jonathan Wakely 4d023b5bd4 * include/std/variant (__accepted_index): Use void_t.
From-SVN: r262471
2018-07-06 11:20:38 +01:00
Jonathan Wakely d04dbb8ad3 PR libstdc++/85831 define move constructors and operators for exceptions
PR libstdc++/85831
	* config/abi/pre/gnu.ver: Export move constructors and move
	assignment operators for std::logic_error and std::runtime_error.
	* include/std/stdexcept: Use _GLIBCXX_NOTHROW instead of
	_GLIBCXX_USE_NOEXCEPT.
	(logic_error, runtime_error): Declare move constructors and move
	assignment operators. When not declared already, define copy
	constructors and copy assignment operators as explicit-defaulted.
	(domain_error, invalid_argument, length_error, out_of_range)
	(overflow_error, underflow_error): Define move constructors and move
	assignment operators as explicitly-defaulted.
	* libsupc++/exception.h (exception): Likewise.
	* src/c++11/cow-stdexcept.cc (logic_error, runtime_error): Define
	move constructors and move assignment operators as defaulted.
	* testsuite/19_diagnostics/stdexcept.cc: Check that constructors and
	assignment operators are defined.

From-SVN: r262456
2018-07-05 22:29:51 +01:00
Jonathan Wakely 339657d2d3 Add xfail-if to some tests that fail with COW strings
These tests fail when run with -D_GLIBCXX_USE_CXX11_ABI=0

	* testsuite/21_strings/basic_string/cons/char/deduction.cc: XFAIL for
	COW strings.
	* testsuite/21_strings/basic_string/cons/wchar_t/deduction.cc:
	Likewise.
	* testsuite/21_strings/basic_string/requirements/
	explicit_instantiation/debug.cc: Likewise.

From-SVN: r262448
2018-07-05 18:03:14 +01:00
Jonathan Wakely 30236791e0 PR libstdc++/58265 add noexcept to basic_string::assign(basic_string&&)
PR libstdc++/58265
	* include/bits/basic_string.h [!_GLIBCXX_USE_CXX11_ABI]
	(basic_string::assign(basic_string&&)): Add conditional noexcept
	depending on the allocator's is_always_equal property (LWG 2063).
	* testsuite/21_strings/basic_string/modifiers/assign/char/
	move_assign.cc: Check for non-throwing exception specification.
	* testsuite/21_strings/basic_string/modifiers/assign/wchar_t/
	move_assign.cc: Likewise.

From-SVN: r262447
2018-07-05 18:03:05 +01:00
Jonathan Wakely d8d9b83b33 PR libstdc++/58265 implement LWG 2063 for COW strings
For COW strings the default constructor does not allocate when
_GLIBCXX_FULLY_DYNAMIC_STRING == 0, so can be noexcept. The move
constructor and swap do not allocate when the allocators are equal, so
add conditional noexcept using allocator_traits::is_always_equal.

	PR libstdc++/58265
	* include/bits/basic_string.h [!_GLIBCXX_USE_CXX11_ABI]
	[_GLIBCXX_FULLY_DYNAMIC_STRING==0] (basic_string::basic_string()):
	Add GLIBCXX_NOEXCEPT.
	(basic_string::operator=(basic_string&&)): Add _GLIBCXX_NOEXCEPT_IF
	to depend on the allocator's is_always_equal property (LWG 2063).
	(basic_string::swap(basic_string&)): Likewise.
	* include/bits/basic_string.tcc [!_GLIBCXX_USE_CXX11_ABI]
	(basic_string::swap(basic_string&)): Likewise.
	* testsuite/21_strings/basic_string/allocator/char/move_assign.cc:
	Check is_nothrow_move_assignable.
	* testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc:
	Check is_nothrow_move_assignable.
	* testsuite/21_strings/basic_string/cons/char/
	noexcept_move_construct.cc: Likewise.
	* testsuite/21_strings/basic_string/cons/wchar_t/
	noexcept_move_construct.cc: Likewise.

From-SVN: r262443
2018-07-05 16:56:06 +01:00
François Dumont d3fc820eb9 Fix my yesterday ChangeLog entry.
From-SVN: r262429
2018-07-05 04:57:52 +00:00
Jonathan Wakely ef45724acd P0646R1 Improving the Return Value of Erase-Like Algorithms I
In C++2a the remove, remove_if and unique members of std::list and
std::forward_list have been changed to return the number of elements
removed. This is an ABI change for the remove members and the
non-template unique members, so an abi-tag is used to give those symbols
new mangled names in C++2a mode. For the function templates the return
type is part of the mangled name so no abi-tag is needed.

	* include/bits/forward_list.h (__cpp_lib_list_remove_return_type):
	Define.
	(forward_list::__remove_return_type): Define typedef as size_type or
	void, according to __cplusplus value.
	(_GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG): Define macro as abi-tag or
	empty, according to __cplusplus value.
	(forward_list::remove, forward_list::unique): Use typedef and macro
	to change return type and add abi-tag for C++2a.
	(forward_list::remove_if<Pred>, forward_list::unique<BinPred>): Use
	typedef to change return type for C++2a.
	* include/bits/forward_list.tcc (_GLIBCXX20_ONLY): Define macro.
	(forward_list::remove, forward_list::remove_if<Pred>)
	(forward_list::unique<BinPred>): Return number of removed elements
	for C++2a.
	* include/bits/list.tcc (_GLIBCXX20_ONLY): Define macro.
	(list::remove, list::unique, list::remove_if<Predicate>)
	(list::unique<BinaryPredicate>): Return number of removed elements
	for C++2a.
	* include/bits/stl_list.h (__cpp_lib_list_remove_return_type): Define.
	(list::__remove_return_type): Define typedef as size_type or
	void, according to __cplusplus value.
	(_GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG): Define macro as abi-tag or
	empty, according to __cplusplus value.
	(list::remove, list::unique): Use typedef and macro to change return
	type and add abi-tag for C++2a.
	(list::remove_if<Predicate>, list::unique<BinaryPredicate>): Use
	typedef to change return type for C++2a.
	* include/std/version (__cpp_lib_list_remove_return_type): Define.
	* testsuite/23_containers/forward_list/operations/
	remove_cxx20_return.cc: New.
	* testsuite/23_containers/forward_list/operations/
	unique_cxx20_return.cc: New.

From-SVN: r262423
2018-07-04 21:15:01 +01:00
Jonathan Wakely 3adea09eea P0458R2 Checking for Existence of an Element in Associative Containers
* include/bits/stl_map.h (map::contains): Add for C++2a.
	* include/bits/stl_multimap.h (multimap::contains): Likewise.
	* include/bits/stl_multiset.h (multiset::contains): Likewise.
	* include/bits/stl_set.h (set::contains): Likewise.
	* include/bits/stl_tree.h (__has_is_transparent_t): Define alias.
	(_Rb_tree::_M_find_tr, _Rb_tree::_M_count_tr)
	(_Rb_tree::_M_lower_bound_tr, _Rb_tree::_M_upper_bound_tr)
	(_Rb_tree::_M_equal_range_tr): Use __has_is_transparent_t.
	* include/bits/unordered_map.h (unordered_map::contains)
	(unordered_multimap::contains): Add for C++2a.
	* include/bits/unordered_set.h (unordered_set::contains)
	(unordered_multiset::contains): Likewise.
	* testsuite/23_containers/map/operations/contains.cc: New.
	* testsuite/23_containers/multimap/operations/contains.cc: New.
	* testsuite/23_containers/multiset/operations/contains.cc: New.
	* testsuite/23_containers/set/operations/contains.cc: New.
	* testsuite/23_containers/unordered_map/operations/contains.cc: New.
	* testsuite/23_containers/unordered_multimap/operations/contains.cc:
	New.
	* testsuite/23_containers/unordered_multiset/operations/contains.cc:
	New.
	* testsuite/23_containers/unordered_set/operations/contains.cc: New.

From-SVN: r262418
2018-07-04 19:16:26 +01:00
François Dumont 96eb9df619 re PR libstdc++/86272 (__gnu_debug::string uses undefined __glibcxx_check_insert_range2)
2018-07-04  François Dumont  <fdumont@gcc.gnu.org>

	PR libstdc++/86272
	* include/debug/string
	(__gnu_debug::basic_string<>::insert<_Ite>(const_iterator, _Ite, _Ite)):
	Use __glibcxx_check_insert_range.
	* 21_strings/basic_string/cons/char/1.cc: Adapt test to use
	__gnu_debug::string when _GLIBCXX_DEBUG.
	* 21_strings/basic_string/init-list.cc: Likewise.
	* 21_strings/basic_string/modifiers/insert/char/1.cc: Likewise.
	* 21_strings/basic_string/modifiers/insert/char/2.cc: Likewise.
	* 21_strings/basic_string/modifiers/insert/char/83328.cc: Likewise.
	* 21_strings/basic_string/types/1.cc: Likewise.

From-SVN: r262417
2018-07-04 18:13:11 +00:00
Jonathan Wakely 89bc4ab198 Define "random_device" effective target
Currently only matches targets where _GLIBCXX_USE_RANDOM_TR1 is defined,
which means /dev/random and /dev/urandom are usable.

	* testsuite/25_algorithms/make_heap/complexity.cc: Require effective
	target for std::random_device.
	* testsuite/26_numerics/random/random_device/cons/default.cc:
	Likewise.
	* testsuite/experimental/algorithm/sample-2.cc: Likewise.
	* testsuite/experimental/algorithm/shuffle.cc: Likewise.
	* testsuite/experimental/random/randint.cc: Likewise.
	* testsuite/lib/libstdc++.exp
	(check_effective_target_random_device): New proc.

From-SVN: r262415
2018-07-04 17:56:21 +01:00
Jonathan Wakely 4e4120a27a Fix std::__rotl and std::__rotr
2018-07-04  Jonathan Wakely  <jwakely@redhat.com>
	    Jakub Jelinek  <jakub@redhat.com>

	* include/std/bit (__rotl, __rotr): Fix for non-power of two sizes.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>

From-SVN: r262414
2018-07-04 15:31:56 +01:00
Jonathan Wakely e9029d55f2 PR libstdc++/86398 fix std::is_trivially_constructible regression
The intrinsic doesn't check for allowed conversions between scalar
types, so restore the std::is_constructible check.

Also make some trivial whitespace changes.

	PR libstdc++/86398
	* include/std/type_traits (is_trivially_constructible): Check
	is_constructible before __is_trivially_constructible.
	* testsuite/20_util/is_trivially_constructible/value.cc: Add more
	tests, including negative cases.
	* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Use
	zero for dg-error lineno.
	* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
	Likewise.

From-SVN: r262379
2018-07-04 10:03:18 +01:00
Jonathan Wakely 90fc44ecfa Optimize std::rotl and std::rotr, add test for std::popcount
* include/std/bit (__rotl, __rotr): Avoid branch.
	(_If_is_unsigned_integer): Use remove_cv_t.
	* testsuite/26_numerics/bit/bitops.count/popcount.cc: New.

From-SVN: r262378
2018-07-04 09:07:23 +01:00
Jonathan Wakely f3e91052bd P0556R3 Integral power-of-2 operations, P0553R2 Bit operations
P0553R2 is not in the C++2a working draft yet, but is likely to be
approved soon. Neither proposal supports std::byte but this adds
overloads of each function for std::byte, assuming that will also get
added.

	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/precompiled/stdc++.h: Include new header.
	* include/std/bit: New header.
	(__rotl, __rotr, __countl_zero, __countl_one, __countr_zero)
	(__countr_one, __popcount, __ispow2, __ceil2, __floor2, __log2p1):
	Define for C++14.
	[!__STRICT_ANSI__] (rotl, rotr, countl_zero, countl_one, countr_zero)
	(countr_one, popcount): Define for C++2a. Also overload for std::byte.
	(ispow2, ceil2, floor2, log2p1): Define for C++2a.
	[!__STRICT_ANSI__] (ispow2, ceil2, floor2, log2p1): Overload for
	std::byte.
	* testsuite/26_numerics/bit/bit.pow.two/ceil2.cc: New.
	* testsuite/26_numerics/bit/bit.pow.two/floor2.cc: New.
	* testsuite/26_numerics/bit/bit.pow.two/ispow2.cc: New.
	* testsuite/26_numerics/bit/bit.pow.two/log2p1.cc: New.
	* testsuite/26_numerics/bit/bitops.rot/rotl.cc: New.
	* testsuite/26_numerics/bit/bitops.rot/rotr.cc: New.
	* testsuite/26_numerics/bit/bitops.count/countl_one.cc: New.
	* testsuite/26_numerics/bit/bitops.count/countl_zero.cc: New.
	* testsuite/26_numerics/bit/bitops.count/countr_one.cc: New.
	* testsuite/26_numerics/bit/bitops.count/countr_zero.cc: New.

From-SVN: r262360
2018-07-03 22:04:45 +01:00
Jonathan Wakely cf3e6e9f15 Remove redundant #if conditional
The whole file is guarded by the same check already.

	* include/bits/alloc_traits.h: Remove redundant preprocessor
	condition.

From-SVN: r262359
2018-07-03 22:04:37 +01:00
François Dumont 315aadc864 stl_algobase.h (__niter_wrap): New.
2018-07-03  François Dumont  <fdumont@gcc.gnu.org>

	* include/bits/stl_algobase.h (__niter_wrap): New.
	(__copy_move_a2(_II, _II, _OI)): Use latter.
	(__copy_move_backward_a2(_BI1, _BI1, _BI2)): Likewise.
	(fill_n(_OI, _Size, const _Tp&)): Likewise.
	(equal(_II1, _II1, _II2)): Use __glibcxx_requires_can_increment.
	* include/debug/stl_iterator.h
	(std::__niter_base(const __gnu_cxx::_Safe_iterator<
	__gnu_cxx::__normal_iterator<>, _Sequence>&)): New declaration.
	* include/debug/vector (__niter_base(const __gnu_cxx::_Safe_iterator<
	__gnu_cxx::__normal_iterator<>, _Sequence>&)): New.

From-SVN: r262349
2018-07-03 15:50:12 +00:00
Jonathan Wakely 8df27fcb91 P0758R1 Implicit conversion traits
Extend __is_convertible_helper to also detect whether the conversion is
non-throwing, for std::is_nothrow_convertible in C++2a,

	* include/std/type_traits [__cplusplus > 201703]
	(__is_convertible_helper::__is_nothrow_type): Define new member.
	(__is_convertible_helper<_From, _To, false>::__test_aux1): Add
	noexcept.
	(__is_convertible_helper<_From, _To, false>::__test_nothrow)
	(__is_convertible_helper<_From, _To, false>::__is_nothrow_type): Add
	new members.
	(is_nothrow_convertible, is_nothrow_convertible_v): Define for C++2a.
	* testsuite/20_util/is_nothrow_convertible/value.cc: New.
	* testsuite/20_util/is_nothrow_convertible/requirements/
	explicit_instantiation.cc: New.
	* testsuite/20_util/is_nothrow_convertible/requirements/typedefs.cc:
	New.

From-SVN: r262322
2018-07-02 23:09:25 +01:00
Jonathan Wakely ee896276f6 P0887R1 The identity metafunction
* include/std/type_traits (type_identity, type_identity_t): Define
        for C++2a.
	* testsuite/20_util/type_identity/requirements/alias_decl.cc: New.
	* testsuite/20_util/type_identity/requirements/
	explicit_instantiation.cc:New.
	* testsuite/20_util/type_identity/requirements/typedefs.cc: New.

From-SVN: r262319
2018-07-02 22:05:08 +01:00