Commit Graph

10636 Commits

Author SHA1 Message Date
Jonathan Wakely 9e16052644 Overload std::distance and std::advance for path::iterator
Although filesystem::path::iterator is only a bidirectional iterator,
the underlying sequence has random access iterators (specifically, raw
pointers). This means std::distance and std::advance can be implemented
more efficiently than the generic versions which apply ++ and --
repeatedly.

	PR libstdc++/71044 (partial)
	* include/bits/fs_path.h (__path_iter_distance, __path_iter_advance):
	New friend functions to implement std::distance and std::advance more
	efficiently.
	(distance, advance): Add overloads for path::iterator.
	* testsuite/27_io/filesystem/path/itr/components.cc: Test new
	overload.

From-SVN: r267057
2018-12-12 16:13:49 +00:00
Jonathan Wakely 6b7c0b5559 PR libstdc++/80762 avoid ambiguous __constructible_from<void, void>
Ensure we don't try to instantiate __is_constructible_from<void, void>,
because there are two partial specializations that are equally good
matches.

	PR libstdc++/80762
	* include/bits/fs_path.h (path::_Path): Use remove_cv_t and is_void.
	* include/experimental/bits/fs_path.h (path::_Path): Likewise.
	* testsuite/27_io/filesystem/path/construct/80762.cc: New test.
	* testsuite/experimental/filesystem/path/construct/80762.cc: New test.

From-SVN: r267056
2018-12-12 16:13:43 +00:00
Jakub Jelinek 0d7924f2e7 P0595R2 - is_constant_evaluated
P0595R2 - is_constant_evaluated
	* include/bits/c++config (_GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED):
	Define if __builtin_is_constant_evaluated is available.
	* include/std/type_traits (std::is_constant_evaluated): New constexpr
	inline function.
	* testsuite/20_util/is_constant_evaluated/1.cc: New test.
	* testsuite/20_util/is_constant_evaluated/noexcept.cc: New test.

From-SVN: r267045
2018-12-12 09:31:01 +01:00
Gerald Pfeifer 72cfde41e5 documentation_hacking.xml: Update reference to epubcheck.
* doc/xml/manual/documentation_hacking.xml: Update reference
	to epubcheck.

From-SVN: r266970
2018-12-11 04:00:00 +00:00
Jonathan Wakely 87e4fbdd9a Make test for Filesystem TS actually use the Filesystem TS
This test was copied from 27_io/filesystem/path/query/is_absolute.cc but
should have been modified to test the path type from the TS instead of
std::filesystem::path.

	* testsuite/experimental/filesystem/path/query/is_absolute.cc: Fix
	test to use TS, not C++17.

From-SVN: r266957
2018-12-10 15:25:02 +00:00
Iain Sandoe c438ab79bf Darwin fix libstdc++ build warnings.
GCC does not export construction vtable symbols from shared libraries.

The symbols are marked hidden in the objects; for Darwin that makes
them also external (“private_extern” is Darwin’s hidden) which means
that they show up in the list of possible symbols for export from
libstdc++, and there are sufficiently relaxed match conditions that
they reach the exports list.   When Darwin’s static linker encounters
them it generates a warning that they cannot be exported.  This patch
prunes them from the list of symbols to be considered, thus
eliminating the warnings. No functional Change inended to the library
exports.

2018-12-06  Iain Sandoe  <iain@sandoe.co.uk>

	* scripts/make_exports.pl (check names): Don’t try to export
	construction vtable symbols.

From-SVN: r266864
2018-12-06 19:42:21 +00:00
Jonathan Wakely 881e947ebd Fix PR libstdc++/64883 Darwin headers use always_inline so don't test that
Because darwin system headers use always_inline rather than
    __always_inline__ the libstdc++ test will fail, even if our headers only
    use the reserved form of the attribute. Don't test it on Darwin, and
    assume that testing on other targets will catch any accidental misuses
    in libstdc++ headers.
 
2018-12-06  Jonathan Wakely  <jwakely@redhat.com>
	    Iain Sandoe  <iain@sandoe.co.uk>

            PR libstdc++/64883
            * testsuite/17_intro/headers/c++1998/all_attributes.cc: Don't test
            always_inline on Darwin.
            * testsuite/17_intro/headers/c++2011/all_attributes.cc: Likewise.
            * testsuite/17_intro/headers/c++2014/all_attributes.cc: Likewise.
            * testsuite/17_intro/headers/c++2017/all_attributes.cc: Likewise.
            * testsuite/17_intro/headers/c++2020/all_attributes.cc: Likewise.


Co-Authored-By: Iain Sandoe <iain@sandoe.co.uk>

From-SVN: r266863
2018-12-06 19:21:32 +00:00
Edward Smith-Rowland d012ab6057 PR libstdc++/88341 - Complex norm doesn't compile with C++11
2018-12-03  Edward Smith-Rowland  <3dw4rd@verizon.net>

	PR libstdc++/88341 - Complex norm doesn't compile with C++11
	* include/std/complex (_S_do_it): Make C++20 constexpr.
	* testsuite/26_numerics/complex/value_operations/pr88341.cc: New test.

From-SVN: r266788
2018-12-04 16:26:39 +00:00
Edward Smith-Rowland 5bd624fbde Implement P0457R2 String Prefix and Suffix Checking.
2018-11-30  Edward Smith-Rowland  <3dw4rd@verizon.net>

	Implement P0457R2 String Prefix and Suffix Checking.
	* include/bits/basic_string.h: Add starts_with, ends_with members.
	* include/std/string_view: Ditto.
	* testsuite/21_strings/basic_string/operations/starts_with/
	char/1.cc: New test.
	* testsuite/21_strings/basic_string/operations/starts_with/
	wchar_t/1.cc: New test.
	* testsuite/21_strings/basic_string/operations/ends_with/
	char/1.cc: New test.
	* testsuite/21_strings/basic_string/operations/ends_with/
	wchar_t/1.cc: New test.
	* testsuite/21_strings/basic_string_view/operations/starts_with/
	char/1.cc: New test.
	* testsuite/21_strings/basic_string_view/operations/starts_with/
	wchar_t/1.cc: New test.
	* testsuite/21_strings/basic_string_view/operations/ends_with/
	char/1.cc: New test.
	* testsuite/21_strings/basic_string_view/operations/ends_with/
	wchar_t/1.cc: New test.

From-SVN: r266674
2018-11-30 16:26:02 +00:00
Edward Smith-Rowland 32bbb362ef The remainder of the Pre-emptively support P0646R1 for std container erasure.
From-SVN: r266673
2018-11-30 16:13:29 +00:00
Edward Smith-Rowland 0b44b4b807 Pre-emptively support P0646R1 for std container erasure.
2018-11-30  Edward Smith-Rowland  <3dw4rd@verizon.net>

	Pre-emptively support P0646R1 for std container erasure.
	* include/bits/erase_if.h: Accumulate and return number of erased nodes.
	* include/std/forward_list (): Return number of erased items.
	* include/std/list (): Ditto.
	* include/std/map (): Ditto.
	* include/std/set (): Ditto.
	* include/std/string (): Ditto.
	* include/std/unordered_map (): Ditto.
	* include/std/unordered_set (): Ditto.
	* include/std/vector (): Ditto.
	* testsuite/21_strings/basic_string/erasure.cc: Test number of erasures.
	* testsuite/23_containers/deque/erasure.cc: Ditto.
	* testsuite/23_containers/forward_list/erasure.cc: Ditto.
	* testsuite/23_containers/list/erasure.cc: Ditto.
	* testsuite/23_containers/map/erasure.cc: Ditto.
	* testsuite/23_containers/set/erasure.cc: Ditto.
	* testsuite/23_containers/unordered_map/erasure.cc: Ditto.
	* testsuite/23_containers/unordered_set/erasure.cc: Ditto.
	* testsuite/23_containers/vector/erasure.cc: Ditto.

From-SVN: r266672
2018-11-30 16:12:13 +00:00
Edward Smith-Rowland 355c62ce02 Only include bits/stl_algo.h for C++20.
2018-11-29  Edward Smith-Rowland  <3dw4rd@verizon.net>

	Only include bits/stl_algo.h for C++20.
	* include/std/deque: Only include bits/stl_algo.h for C++20.
	* include/std/string: Ditto.
	* include/std/vector: Ditto.

From-SVN: r266624
2018-11-29 15:17:17 +00:00
Edward Smith-Rowland a62b871d65 Fix erasure goofs.
2018-11-29  Edward Smith-Rowland  <3dw4rd@verizon.net>

	Fix erasure goofs.
	* include/experimental/deque: Make inline.
	* include/std/deque: Include bits/stl_algo.h.
	(erase, erase_if): Make inline.
	* include/std/string: Include bits/stl_algo.h.
	* include/std/unordered_set: Add erase, erase_if!
	* include/std/vector: Include bits/stl_algo.h.
	* testsuite/21_strings/basic_string/erasure.cc:
	Add { dg-options "-std=gnu++2a" }.
	* testsuite/23_containers/deque/erasure.cc: Ditto.
	* testsuite/23_containers/forward_list/erasure.cc: Ditto.
	* testsuite/23_containers/list/erasure.cc: Ditto.
	* testsuite/23_containers/map/erasure.cc: Ditto.
	* testsuite/23_containers/set/erasure.cc: Ditto.
	* testsuite/23_containers/unordered_map/erasure.cc: Ditto.
	* testsuite/23_containers/unordered_set/erasure.cc: Ditto.
	* testsuite/23_containers/vector/erasure.cc: Ditto.

From-SVN: r266616
2018-11-29 13:43:55 +00:00
Jonathan Wakely 8c9b385288 PR libstdc++/88119 use alignof in std::alignment_of, not __alignof__
Now that __alignof__ and alignof sometimes disagree it matters which one
we use. The standard says that std::alignment_of<T>::value equals
alignof(T), so we need to use that.

Change the only uses of alignment_of to use __alignof__ to avoid a
change in alignment.

	PR libstdc++/88119
	* include/ext/aligned_buffer.h (__aligned_membuf): Add comment.
	(__aligned_buffer): Use __alignof__ instead of std::alignment_of.
	* include/std/type_traits (alignment_of): Use alignof instead of
	__alignof__.
	* testsuite/20_util/alignment_of/value.cc: Fix test to check values
	match alignof not __alignof__, as required by the standard.

From-SVN: r266613
2018-11-29 12:32:57 +00:00
Jonathan Wakely ffe2c05539 PR libstdc++/86910 fix filesystem::create_directories
Implement the proposed semantics from P1164R0, which reverts the changes
of LWG 2935. This means that failure to create a directory because a
non-directory already exists with that name will be reported as an
error.

While rewriting the function, also fix PR 87846, which is a result of
the C++17 changes to how a trailing slash on a path affects the last
component of a path.

	PR libstdc++/86910
	PR libstdc++/87846
	* src/filesystem/ops.cc (experimental::create_directories): Report
	an error when the path resolves to an existing non-directory (P1164).
	* src/filesystem/std-ops.cc (create_directories): Likewise. Handle
	empty filenames due to trailing slashes.
	* testsuite/27_io/filesystem/operations/create_directories.cc: Test
	when some component of the path exists and is not a directory. Test
	trailing slashes.
	* testsuite/experimental/filesystem/operations/create_directories.cc:
	Likewise.

From-SVN: r266598
2018-11-29 00:39:37 +00:00
Jonathan Wakely 345d2d0349 Fix undefined references in libstdc++fs.a
The recent patch for PR 83306 removed the fs_err_concat functions that
were used by the experimental::filesystem::filesystem_error class as
well. This fixes it by doing the string generation directly in
filesystem_error::_M_gen_what() instead of using the removed function.

	PR libstdc++/83306
	* src/filesystem/path.cc (filesystem_error::_M_gen_what()): Create
	string directly, instead of calling fs_err_concat.

From-SVN: r266569
2018-11-28 17:07:22 +00:00
Jonathan Wakely 0a1369fa95 PR libstdc++/83511 add default argument to basic_string_view::substr
PR libstdc++/83511
	* include/std/string_view (basic_string_view::substr): Add default
	argument to first parameter.
	* include/experimental/string_view (basic_string_view::substr):
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/substr/char/
	83511.cc: New test.
	* testsuite/21_strings/basic_string_view/operations/substr/wchar_t/
	83511.cc: New test.
	* testsuite/experimental/string_view/operations/substr/char/83511.cc:
	New test.
	* testsuite/experimental/string_view/operations/substr/wchar_t/83511.cc:
	New test.

From-SVN: r266568
2018-11-28 16:53:35 +00:00
Edward Smith-Rowland 188588e443 Implement uniform container erasure for C++20.
2018-11-28  Edward Smith-Rowland  <3dw4rd@verizon.net>

	Implement uniform container erasure for C++20.
	* include/Makefile.am: Move erase_if.h.
	* include/Makefile.in: Move erase_if.h.
	* include/experimental/bits/erase_if.h: Move ...
	* include/bits/erase_if.h: ... here.
	* include/experimental/map: Move erase_if.h.
	* include/experimental/set: Move erase_if.h.
	* include/experimental/unordered_map: Move erase_if.h.
	* include/experimental/unordered_set: Move erase_if.h.
	* include/std/deque (erase_if, erase): New functions.
	* include/std/forward_list: Ditto.
	* include/std/list: Ditto.
	* include/std/map: Ditto.
	* include/std/set: Ditto.
	* include/std/string: Ditto.
	* include/std/unordered_map: Ditto.
	* include/std/unordered_set: Ditto.
	* include/std/vector: Ditto.
	* testsuite/21_strings/basic_string/erasure.cc: New test.
	* testsuite/23_containers/deque/erasure.cc: New test.
	* testsuite/23_containers/forward_list/erasure.cc: New test.
	* testsuite/23_containers/list/erasure.cc: New test.
	* testsuite/23_containers/map/erasure.cc: New test.
	* testsuite/23_containers/set/erasure.cc: New test.
	* testsuite/23_containers/unordered_map/erasure.cc: New test.
	* testsuite/23_containers/unordered_set/erasure.cc: New test.
	* testsuite/23_containers/vector/erasure.cc: New test.

From-SVN: r266567
2018-11-28 16:44:25 +00:00
Jonathan Wakely bd6ccc290a Apply resolution for LWG DR 3096
Add fix for "path::lexically_relative is confused by trailing slashes".

	* doc/xml/manual/intro.xml: Document LWG 3096 change.
	* src/filesystem/std-path.cc (path::lexically_relative(const path&)):
	Treat a final empty element equivalently to a final dot element.
	* testsuite/27_io/filesystem/path/generation/relative.cc: Add checks
	for the examples in the DR.

From-SVN: r266566
2018-11-28 15:36:56 +00:00
Jonathan Wakely 24d9b090fb PR libstdc++/83306 make filesystem_error no-throw copyable
The class API provides no way to modify the members, so we can share
them between copies of the same object. Copying becomes a simple
reference count update, which doesn't throw.

Also adjust the what() string to allow distinguishing between an empty
path passed to the constructor, and no path.

	PR libstdc++/83306
	* include/bits/fs_path.h (filesystem_error): Move data members into
	pimpl class owned by shared_ptr. Remove inline definitions of member
	functions.
	* src/filesystem/std-path.cc (filesystem_error::_Impl): Define.
	(filesystem_error): Define member functions.
	* testsuite/27_io/filesystem/filesystem_error/cons.cc: New test.
	* testsuite/27_io/filesystem/filesystem_error/copy.cc: New test.

From-SVN: r266565
2018-11-28 15:27:11 +00:00
Jonathan Wakely 5916922e34 Update C++17 library status docs
* doc/xml/manual/status_cxx2017.xml: Update C++17 status.
	* doc/html/*: Regenerate.

From-SVN: r266559
2018-11-28 13:49:47 +00:00
Jonathan Wakely c718ff4183 Clean up temporary files created by std::filesystem testsuite
* testsuite/27_io/filesystem/operations/canonical.cc: Remove
	directory created by test.
	* testsuite/27_io/filesystem/operations/symlink_status.cc: Remove
	symlink created by test.

From-SVN: r266535
2018-11-27 23:35:17 +00:00
Jonathan Wakely da29d2a36e PR libstdc++/67843 set shared_ptr lock policy at build-time
This resolves a longstanding issue where the lock policy for shared_ptr
reference counting depends on compilation options when the header is
included, so that different -march options can cause ABI changes. For
example, objects compiled with -march=armv7 will use atomics to
synchronize reference counts, and objects compiled with -march=armv5t
will use a mutex. That means the shared_ptr control block will have a
different layout in different objects, causing ODR violations and
undefined behaviour. This was the root cause of PR libstdc++/42734 as
well as PR libstdc++/67843.

The solution is to decide on the lock policy at build time, when
libstdc++ is configured. The configure script checks for the
availability of the necessary atomic built-ins for the target and fixes
that choice permanently. Different -march flags used to compile user
code will not cause changes to the lock policy. This results in an ABI
change for certain compilations, but only where there was already an ABI
incompatibility between the libstdc++.so library and objects built with
an incompatible -march option. In general, this means a more stable ABI
that isn't silently altered when -march flags make addition atomic ops
available.

To force a target to use "atomic" or "mutex" the new configure option
--with-libstdcxx-lock-policy can be used.

In order to turn ODR violations into linker errors, the uses of
shared_ptr in filesystem directory iterators have been replaced
with __shared_ptr, and explicit instantiations are declared. This
ensures that object files using those types cannot link to libstdc++
libs unless they use the same lock policy.

	PR libstdc++/67843
	* acinclude.m4 (GLIBCXX_ENABLE_LOCK_POLICY): Add new macro
	that defines _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Use GLIBCXX_ENABLE_LOCK_POLICY.
	* doc/xml/manual/configure.xml: Document new configure option.
	* include/bits/fs_dir.h (directory_iterator): Use __shared_ptr
	instead of shared_ptr.
	(recursive_directory_iterator): Likewise.
	(__shared_ptr<_Dir>): Add explicit instantiation declaration.
	(__shared_ptr<recursive_directory_iterator::_Dir_stack>): Likewise.
	* include/bits/shared_ptr_base.h (__allocate_shared, __make_shared):
	Add default template argument for _Lock_policy template parameter.
	* include/ext/concurrence.h (__default_lock_policy): Check macro
	_GLIBCXX_HAVE_ATOMIC_LOCK_POLICY instead of checking if the current
	target supports the builtins for compare-and-swap.
	* src/filesystem/std-dir.cc (__shared_ptr<_Dir>): Add explicit
	instantiation definition.
	(__shared_ptr<recursive_directory_iterator::_Dir_stack>): Likewise.
	(directory_iterator, recursive_directory_iterator): Use __make_shared
	instead of make_shared.

From-SVN: r266533
2018-11-27 23:25:56 +00:00
François Dumont 010211394d re PR libstdc++/88199 (memory leak on unordered container move assignment)
2018-11-27  François Dumont  <fdumont@gcc.gnu.org>

	PR libstdc++/88199
	* include/bits/hashtable.h (_Hashtable<>::_M_assign_elements): New.
	(_Hashtable<>::operator=(const _Hashtable&)): Use latter.
	(_Hashtable<>::_M_move_assign(_Hashtable&&, false_type)): Likewise.
	* testsuite/23_containers/unordered_set/allocator/move_assign.cc
	(test03): New.

From-SVN: r266528
2018-11-27 21:21:51 +00:00
Jonathan Wakely f4d3e3cca5 Only use __float128 in test if available
* testsuite/26_numerics/complex/requirements/more_constexpr.cc: Fix
	failure on targets without __float128.

From-SVN: r266450
2018-11-26 11:12:11 +00:00
Edward Smith-Rowland e987fb1ebe Implement P0415 More constexpr for std::complex.
2018-11-23  Edward Smith-Rowland  <3dw4rd@verizon.net>

	Implement P0415 More constexpr for std::complex.
	* include/std/complex (conj(complex<Tp>), norm(complex<Tp>)): Constexpr;
	(real(Tp), imag(Tp)): Constexpr;
	(operator@=(Tp), operator@=(complex<Tp>)): Constexpr;
	(operator@(Tp,complex<Tp>), operator@(complex<Tp>,Tp)
	operator@(complex<Tp>,complex<Tp>)): Constexpr.
	* testsuite/26_numerics/complex/comparison_operators/
	more_constexpr.cc: New test.
	* testsuite/26_numerics/complex/operators/more_constexpr.cc: New test.
	* testsuite/26_numerics/complex/requirements/
	more_constexpr.cc: New test.
	* testsuite/26_numerics/complex/value_operations/
	more_constexpr.cc: New test.
	* testsuite/26_numerics/headers/complex/synopsis.cc:
	Add _GLIBCXX20_CONSTEXPR to applicable operators; Add missing proj().
	* testsuite/26_numerics/headers/complex/synopsis.cc:
	Add _GLIBCXX20_CONSTEXPR to relevant decls.

From-SVN: r266416
2018-11-23 18:17:04 +00:00
Martin Sebor 14a9206d0c PR libstdc++/65229 fix pretty printer for std::bitset<0>
2018-11-23  Martin Sebor  <msebor@redhat.com>
	    Jonathan Wakely  <jwakely@redhat.com>

	PR libstdc++/65229
	* python/libstdcxx/v6/printers.py (StdBitsetPrinter): Handle
	exception thrown for std::bitset<0>.
	* testsuite/libstdc++-prettyprinters/simple.cc: Test std::bitset<0>.

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

From-SVN: r266409
2018-11-23 16:12:03 +00:00
Jonathan Wakely 11aa881f98 PR libstdc++/87308 adjust regex used in std::any pretty printer
The pretty printer for std::any fails when the contained value is a
locally-defined type, because the name in the debuginfo has
cv-qualifiers and ptr-declarators in different positions. The unexpected
format confuses the printer. This makes the printer's regex handle
either format.

This isn't a complete fix because looking up the contained type fails
when there are two types with the same name (defined in different local
scopes). This applies to all closure types defined in a given function,
as they all appear as "func()::lambda" in the debuginfo names.

	PR libstdc++/87308 (partial)
	* python/libstdcxx/v6/printers.py (StdExpAnyPrinter): Adjust regex to
	work around PR 88166.
	* testsuite/libstdc++-prettyprinters/cxx17.cc: Test std::any
	containing a local type.

From-SVN: r266408
2018-11-23 15:48:56 +00:00
Marc Glisse ff2e7f1973 Improve relocation
2018-11-22  Marc Glisse  <marc.glisse@inria.fr>

	PR libstdc++/87106
	* include/bits/stl_algobase.h: Include <type_traits>.
	(__niter_base): Add noexcept specification.
	* include/bits/stl_deque.h: Include <bits/stl_uninitialized.h>.
	(__is_trivially_relocatable): Specialize for deque.
	* include/bits/stl_iterator.h: Include <type_traits>.
	(__niter_base): Add noexcept specification.
	* include/bits/stl_uninitialized.h (__is_trivially_relocatable):
	Add parameter for meta-programming.
	(__relocate_a_1, __relocate_a): Add noexcept specification.
	* include/bits/stl_vector.h (__use_relocate): Test __relocate_a.

From-SVN: r266386
2018-11-22 18:10:05 +00:00
Jonathan Wakely a942dfca6a PR libstdc++/87520 Always pass type-punned type_info reference
The implementations of std::make_shared for -frtti and -fno-rtti are not
compatible, because they pass different arguments to
_Sp_counted_ptr_inplace::_M_get_deleter and so can't interoperate.
Either the argument doesn't match the expected value, and so the
shared_ptr::_M_ptr member is never set, or the type-punned reference is
treated as a real std::type_info object and gets dereferenced.

This patch removes the differences between -frtti and -fno-rtti, so that
typeid is never used, and the type-punned reference is used in both
cases. For backwards compatibility with existing code that passes
typeid(_Sp_make_shared_tag) that still needs to be handled, but only
after checking that the argument is not the type-punned reference (so
it's safe to treat as a real std::type_info object). The reference is
bound to an object of literal type, so that it doesn't need a guard
variable to make its initialization thread-safe.

This patch also fixes 87520 by ensuring that the type-punned reference
is bound to "a region of storage of suitable size and alignment to
contain an object of the reference's type" (as per the proposed
resolution of Core DR 453).

If all objects are built with the fixed version of GCC then -frtti and
-fno-rtti can be mixed freely and std::make_shared will work correctly.
If some objects are built with unfixed GCC versions then problems can
still arise, depending on which template instantiations are kept by the
linker.

	PR libstdc++/85930
	PR libstdc++/87520
	* include/bits/shared_ptr_base.h (_Sp_make_shared_tag::_S_ti)
	[__cpp_rtti]: Define even when RTTI is enabled. Use array of
	sizeof(type_info) so that type-punned reference binds to an object
	of the correct size as well as correct alignment.
	(_Sp_counted_ptr_inplace::_M_get_deleter) [__cpp_rtti]: Check for
	_S_ti() reference even when RTTI is enabled.
	(__shared_ptr(_Sp_make_shared_tag, const _Alloc&, _Args&&...))
	[__cpp_rtti]: Pass _S_ti() instead of typeid(_Sp_make_shared_tag).

From-SVN: r266376
2018-11-22 13:42:39 +00:00
Jakub Jelinek e1389417f9 re PR c++/87386 (Error message for static_assert show wrong range)
PR c++/87386
	* parser.c (cp_parser_primary_expression): Use
	id_expression.get_location () instead of id_expr_token->location.
	Adjust the range from id_expr_token->location to
	id_expressio.get_finish ().
	(cp_parser_operator_function_id): Pass location of the operator
	token down to cp_parser_operator.
	(cp_parser_operator): Add start_loc argument, always construct a
	location with caret at start_loc and range from start_loc to the
	finish of the last token.
gcc/testsuite/
	* g++.dg/diagnostic/pr87386.C: New test.
	* g++.dg/parse/error17.C: Adjust expected diagnostics.
libstdc++-v3/
	* testsuite/20_util/scoped_allocator/69293_neg.cc: Adjust expected
	line.
	* testsuite/20_util/uses_allocator/cons_neg.cc: Likewise.
	* testsuite/20_util/uses_allocator/69293_neg.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements2.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements3.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements4.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements5.cc: Likewise.

From-SVN: r266359
2018-11-21 23:41:07 +01:00
Jonathan Wakely 36d2acbd78 PR libstdc++/88111 Make maximum block size depend on size_t width
PR libstdc++/88111
	* include/std/memory_resource (pool_options): Add Doxygen comments.
	* src/c++17/memory_resource.cc (pool_sizes): Only use suitable values
	on targets with 16-bit or 20-bit size_t type.
	(munge_options): Make default values depend on width of size_t type.

From-SVN: r266353
2018-11-21 18:40:55 +00:00
Jonathan Wakely afd02e4c67 PR libstdc++/88113 use size_type consistently instead of size_t
On 16-bit msp430-elf size_t is either 16 bits or 20 bits, and so can't
represent all values of the uint32_t type used for bitset::size_type.
Using the smaller of size_t and uint32_t for size_type ensures it fits
in size_t.

	PR libstdc++/88113
	* src/c++17/memory_resource.cc (bitset::size_type): Use the smaller
	of uint32_t and size_t.
	(bitset::size(), bitset::free(), bitset::update_next_word())
	(bitset::max_blocks_per_chunk(), bitset::max_word_index()): Use
	size_type consistently instead of size_t.
	(chunk): Adjust static_assert checking sizeof(chunk).

From-SVN: r266352
2018-11-21 18:40:37 +00:00
Ville Voutilainen 47df7e197b Housekeeping for the effective targets of optional's tests.
* testsuite/20_util/optional/77288.cc: Adjust.
* testsuite/20_util/optional/84601.cc: Likewise.
* testsuite/20_util/optional/assignment/1.cc: Likewise.
* testsuite/20_util/optional/assignment/2.cc: Likewise.
* testsuite/20_util/optional/assignment/3.cc: Likewise.
* testsuite/20_util/optional/assignment/4.cc: Likewise.
* testsuite/20_util/optional/assignment/5.cc: Likewise.
* testsuite/20_util/optional/assignment/6.cc: Likewise.
* testsuite/20_util/optional/assignment/7.cc: Likewise.
* testsuite/20_util/optional/assignment/8.cc: Likewise.
* testsuite/20_util/optional/cons/77727.cc: Likewise.
* testsuite/20_util/optional/cons/copy.cc: Likewise.
* testsuite/20_util/optional/cons/deduction.cc: Likewise.
* testsuite/20_util/optional/cons/default.cc: Likewise.
* testsuite/20_util/optional/cons/move.cc: Likewise.
* testsuite/20_util/optional/cons/trivial.cc: Likewise.
* testsuite/20_util/optional/cons/value.cc: Likewise.
* testsuite/20_util/optional/cons/value_neg.cc: Likewise.
* testsuite/20_util/optional/constexpr/cons/default.cc: Likewise.
* testsuite/20_util/optional/constexpr/cons/value.cc: Likewise.
* testsuite/20_util/optional/constexpr/in_place.cc: Likewise.
* testsuite/20_util/optional/constexpr/nullopt.cc: Likewise.
* testsuite/20_util/optional/constexpr/observers/1.cc: Likewise.
* testsuite/20_util/optional/constexpr/observers/4.cc: Likewise.
* testsuite/20_util/optional/constexpr/observers/5.cc: Likewise.
* testsuite/20_util/optional/constexpr/relops/1.cc: Likewise.
* testsuite/20_util/optional/constexpr/relops/2.cc: Likewise.
* testsuite/20_util/optional/constexpr/relops/3.cc: Likewise.
* testsuite/20_util/optional/constexpr/relops/4.cc: Likewise.
* testsuite/20_util/optional/constexpr/relops/5.cc: Likewise.
* testsuite/20_util/optional/constexpr/relops/6.cc: Likewise.
* testsuite/20_util/optional/in_place.cc: Likewise.
* testsuite/20_util/optional/make_optional.cc: Likewise.
* testsuite/20_util/optional/nullopt.cc: Likewise.
* testsuite/20_util/optional/observers/1.cc: Likewise.
* testsuite/20_util/optional/observers/2.cc: Likewise.
* testsuite/20_util/optional/observers/3.cc: Likewise.
* testsuite/20_util/optional/observers/4.cc: Likewise.
* testsuite/20_util/optional/observers/5.cc: Likewise.
* testsuite/20_util/optional/observers/6.cc: Likewise.
* testsuite/20_util/optional/relops/1.cc: Likewise.
* testsuite/20_util/optional/relops/2.cc: Likewise.
* testsuite/20_util/optional/relops/3.cc: Likewise.
* testsuite/20_util/optional/relops/4.cc: Likewise.
* testsuite/20_util/optional/relops/5.cc: Likewise.
* testsuite/20_util/optional/relops/6.cc: Likewise.
* testsuite/20_util/optional/relops/7.cc: Likewise.
* testsuite/20_util/optional/requirements.cc: Likewise.
* testsuite/20_util/optional/swap/1.cc: Likewise.
* testsuite/20_util/optional/swap/2.cc: Likewise.
* testsuite/20_util/optional/typedefs.cc: Likewise.

From-SVN: r266310
2018-11-20 12:42:28 +02:00
François Dumont 0da4824836 2018-11-19 François Dumont <fdumont@gcc.gnu.org>
* include/ext/throw_allocator.h
	(annotate_base::insert(void*, size_t)): Use insert result to check for
	double insert attempt.
	(annotate_base::insert_construct(void*)): Likewise.
	(annotate_base::check_allocated(void*, size_t)): Return found iterator.
	(annotate_base::erase(void*, size_t)): Use latter method returned
	iterator.
	(annotate_base::check_constructed(void*, size_t)): Return found iterator.
	(annotate_base::erase_construct(void*)): Use latter method returned
	iterator.

From-SVN: r266284
2018-11-19 21:02:17 +00:00
Ville Voutilainen 4fea820523 re PR libstdc++/87855 (std::optional<T> only copy-constructible if T is trivially copy-constructible)
PR libstdc++/87855

Also implement P0602R4 (variant and optional
should propagate copy/move triviality) for std::optional.
* include/std/optional (_Optional_payload): Change
the main constraints to check constructibility in
addition to assignability.
(operator=): Make constexpr.
(_M_reset): Likewise.
(_M_construct): Likewise.
(operator->): Likewise.
* testsuite/20_util/optional/assignment/8.cc: Adjust.
* testsuite/20_util/optional/assignment/9.cc: New.

From-SVN: r266278
2018-11-19 17:05:18 +02:00
Jonathan Wakely d86b600d89 PR libstdc++/88084 - Implement LWG 2777
* include/std/string_view (basic_string_view::copy): Use traits to
	copy.
	* testsuite/21_strings/basic_string_view/operations/copy/char/2.cc:
	New test.
	* testsuite/21_strings/basic_string_view/operations/copy/wchar_t/2.cc:
	New test.

From-SVN: r266269
2018-11-19 10:53:59 +00:00
Michele Pezzutti bee39274cb PR libstdc++/83566 - cyl_bessel_j returns wrong result for x>1000
2018-11-16  Michele Pezzutti <mpezz@tiscali.it>
	    Edward Smith-Rowland  <3dw4rd@verizon.net>

	PR libstdc++/83566 - cyl_bessel_j returns wrong result for x>1000
	for high orders.
	* include/tr1/bessel_function.tcc: Perform no fewer than nu/2 iterations
	of the asymptotic series (nu is the Bessel order).
	* testsuite/tr1/5_numerical_facilities/special_functions/
	09_cyl_bessel_j/check_value.cc: Add tests at nu=100, 1000<=x<=2000.
	* testsuite/tr1/5_numerical_facilities/special_functions/	
	11_cyl_neumann/check_value.cc: Ditto.
	* testsuite/special_functions/08_cyl_bessel_j/check_value.cc: Ditto.
	* testsuite/special_functions/10_cyl_neumann/check_value.cc: Ditto.


Co-Authored-By: Edward Smith-Rowland <3dw4rd@verizon.net>

From-SVN: r266252
2018-11-18 18:32:26 +00:00
Jonathan Wakely c5be64810c Implement std::pmr::synchronized_pool_resource
Define the thread-safe pool resource, using a shared_mutex to allow
multiple threads to concurrently allocate from thread-specific pools.

Define new weak symbols for the pthread_rwlock_t functions, to avoid
making libstdc++.so depend on libpthread.so

When the necessary Gthread support is absent only define the
feature-test macro to 1, rather than 201603. This is intended to imply
incomplete support, because everything except synchronized_pool_resource
works.

	Implement std::pmr::synchronized_pool_resource
	* config/abi/pre/gnu.ver: Add new symbols.
	* include/std/memory_resource [_GLIBCXX_HAS_GTHREADS]
	(__cpp_lib_memory_resource): Define to expected value, 201603.
	(synchronized_pool_resource): New class.
	[!_GLIBCXX_HAS_GTHREADS] (__cpp_lib_memory_resource): Define to 1.
	* include/std/shared_mutex (__glibcxx_rwlock_rdlock)
	(__glibcxx_rwlock_tryrdlock, __glibcxx_rwlock_wrlock)
	(__glibcxx_rwlock_trywrlock, __glibcxx_rwlock_unlock)
	(__glibcxx_rwlock_destroy, __glibcxx_rwlock_init)
	(__glibcxx_rwlock_timedrdlock, __glibcxx_rwlock_timedwrlock): Define
	weak symbols for POSIX rwlock functions.
	(__shared_mutex_pthread): Use weak symbols.
	* include/std/version (__cpp_lib_memory_resource): Define.
	* src/c++17/memory_resource.cc [_GLIBCXX_HAS_GTHREADS]
	(synchronized_pool_resource::_TPools): New class.
	(destroy_TPools): New function for pthread_key_create destructor.
	(synchronized_pool_resource::synchronized_pool_resource)
	(synchronized_pool_resource::~synchronized_pool_resource)
	(synchronized_pool_resource::release)
	(synchronized_pool_resource::do_allocate)
	(synchronized_pool_resource::do_deallocate): Define public members.
	(synchronized_pool_resource::_M_thread_specific_pools)
	(synchronized_pool_resource::_M_alloc_tpools)
	(synchronized_pool_resource::_M_alloc_shared_tpools): Define private
	members.
	* testsuite/20_util/synchronized_pool_resource/allocate.cc: New test.
	* testsuite/20_util/synchronized_pool_resource/cons.cc: New test.
	* testsuite/20_util/synchronized_pool_resource/is_equal.cc: New test.
	* testsuite/20_util/synchronized_pool_resource/multithreaded.cc: New
	test.
	* testsuite/20_util/synchronized_pool_resource/release.cc: New test.
	* testsuite/performance/20_util/memory_resource/pools.cc: Add
	multithreaded tests using pmr::synchronized_pool_resource.

From-SVN: r266242
2018-11-17 23:35:44 +00:00
Renlin Li ac28df7e53 [Patch][libstdc++.exp] Update the usage of cached result.
This patch replaces the usage of cached results with a global dictionary.

Additionally, check_v3_target_namedlocale is updated to check on every variant.
Originally, it is only checked once.


gcc/libstdc++-v3/:
2018-11-16  Renlin Li  <renlin.li@arm.com>
	    Tejas Belagod  <tejas.belagod@arm.com>

	testsuite/lib/libstdc++.exp (check_v3_target_prop_cached): New proc.
	(check_v3_target): Use check_v3_target_prop_cached.


Co-Authored-By: Tejas Belagod <tejas.belagod@arm.com>

From-SVN: r266209
2018-11-16 14:36:40 +00:00
Jonathan Wakely a15032ee7b Optimize pool resource allocation
A recent change caused a performance regression. This restores the
previous performance and adds a performance test.

	* scripts/check_performance: Allow tests to choose a -std flag.
	* src/c++17/memory_resource.cc (bitset::get_first_unset()): Use local
	variables of the right types. Call update_next_word() unconditionally.
	* testsuite/20_util/unsynchronized_pool_resource/cons.cc: New test.
	* testsuite/performance/20_util/memory_resource/pools.cc: New test.
	* testsuite/util/testsuite_performance.h (time_counter): Allow
	timer to be restarted.

From-SVN: r266164
2018-11-15 00:04:19 +00:00
Jonathan Wakely aeb2b1f7fb Fix test that does undefined shifts greater than width of size_t
* testsuite/20_util/unsynchronized_pool_resource/allocate.cc: Fix
	test for 32-bit targets. Test additional allocation sizes.

From-SVN: r266163
2018-11-15 00:04:12 +00:00
Jonathan Wakely 78ef03b7c3 Add missing dir to create_testsuite_files script
* scripts/create_testsuite_files: Add special_functions to the list
	of directories to search. Add comment referring to conformance.exp.
	* testsuite/libstdc++-dg/conformance.exp: Add comment referring
	to create_testsuite_files.

From-SVN: r266146
2018-11-14 14:25:00 +00:00
Jonathan Wakely b76a1b3604 Fix error when selecting number of memory pools
* src/c++17/memory_resource.cc (select_num_pools): Fix off-by-one
	error when block_size is equal to one of the values in the array.

From-SVN: r266092
2018-11-13 23:44:39 +00:00
Jonathan Wakely 6c4a1d38ba Fix unused parameter warnings introduced in earlier patch
* src/c++17/memory_resource.cc (_Pool::deallocate): Restore
	attributes to parameters that are only used in assertions.

From-SVN: r266091
2018-11-13 23:02:22 +00:00
Jonathan Wakely b6b1827107 Remove redundant loop in unsynchronized_pool_resource code
* src/c++17/memory_resource.cc (bitset::find_first_unset()): Remove
	unused function.
	(bitset::get_first_unset()): Remove loop, if there's are unset bits
	then _M_next_word refers to the first one and there's no need to loop.
	(_Pool::_Pool(size_t, size_t), _Pool::block_size()): Remove dead code.

From-SVN: r266090
2018-11-13 22:58:00 +00:00
Jonathan Wakely f2e005857e Improve handling of pool_options::largest_required_pool_block
Make the munge_options function round the largest_required_pool_block
value to a multiple of the smallest pool size (currently 8 bytes) to
avoid pools with odd sizes.

Ensure there is a pool large enough for blocks of the requested size.
Previously when largest_required_pool_block was exactly equal to one of
the pool_sizes[] values there would be no pool of that size. This patch
increases _M_npools by one, so there is a pool at least as large as the
requested value. It also reduces the size of the largest pool to be no
larger than needed.

	* src/c++17/memory_resource.cc (munge_options): Round up value of
	largest_required_pool_block to multiple of smallest pool size. Round
	excessively large values down to largest pool size.
	(select_num_pools): Increase number of pools by one unless it exactly
	matches requested largest_required_pool_block.
	(__pool_resource::_M_alloc_pools()): Make largest pool size equal
	largest_required_pool_block.
	* testsuite/20_util/unsynchronized_pool_resource/options.cc: Check
	that pool_options::largest_required_pool_block is set appropriately.

From-SVN: r266089
2018-11-13 22:57:53 +00:00
Jonathan Wakely d3306a84a6 Fix incorrect assertion when deallocating big block
Since a big_block rounds up the size to a multiple of big_block::min it
is wrong to assert that the supplied number of bytes equals the
big_block's size(). Add big_block::alloc_size(size_t) to calculate the
allocated size consistently, and add comments to the code.

	* src/c++17/memory_resource.cc (big_block): Improve comments.
	(big_block::all_ones): Remove.
	(big_block::big_block(size_t, size_t)): Use alloc_size.
	(big_block::size()): Add comment, replace all_ones with equivalent
	expression.
	(big_block::align()): Shift value of correct type.
	(big_block::alloc_size(size_t)): New function to round up size.
	(__pool_resource::allocate(size_t, size_t)): Add comment.
	(__pool_resource::deallocate(void*, size_t, size_t)): Likewise. Fix
	incorrect assertion by using big_block::alloc_size(size_t).
	* testsuite/20_util/unsynchronized_pool_resource/allocate.cc: Add
	more tests for unpooled allocations.

From-SVN: r266088
2018-11-13 22:57:48 +00:00
Jonathan Wakely 6bdd58f73a Fix overflows in std::pmr::unsynchonized_pool_resource
* src/c++17/memory_resource.cc (bitset::full()): Handle edge case
	for _M_next_word maximum value.
	(bitset::get_first_unset(), bitset::set(size_type)): Use
	update_next_word() to update _M_next_word.
	(bitset::update_next_word()): New function, avoiding wraparound of
	unsigned _M_next_word member.
	(bitset::max_word_index()): New function.
	(chunk::chunk(void*, uint32_t, void*, size_t)): Add assertion.
	(chunk::max_bytes_per_chunk()): New function.
	(pool::replenish(memory_resource*, const pool_options&)): Prevent
	_M_blocks_per_chunk from exceeding max_blocks_per_chunk or from
	causing chunk::max_bytes_per_chunk() to be exceeded.
	* testsuite/20_util/unsynchronized_pool_resource/allocate-max-chunks.cc:
	New test.

From-SVN: r266087
2018-11-13 22:57:44 +00:00
Jason Merrill a6bb6b07f7 Implement P0722R3, destroying operator delete.
A destroying operator delete takes responsibility for calling the destructor
for the object it is deleting; this is intended to be useful for sized
delete of a class allocated with a trailing buffer, where the compiler can't
know the size of the allocation, and so would pass the wrong size to the
non-destroying sized operator delete.

gcc/c-family/
	* c-cppbuiltin.c (c_cpp_builtins): Define
	__cpp_impl_destroying_delete.
gcc/cp/
	* call.c (std_destroying_delete_t_p, destroying_delete_p): New.
	(aligned_deallocation_fn_p, usual_deallocation_fn_p): Use
	destroying_delete_p.
	(build_op_delete_call): Handle destroying delete.
	* decl2.c (coerce_delete_type): Handle destroying delete.
	* init.c (build_delete): Don't call dtor with destroying delete.
	* optimize.c (build_delete_destructor_body): Likewise.
libstdc++-v3/
	* libsupc++/new (std::destroying_delete_t): New.

From-SVN: r266053
2018-11-12 23:40:01 -05:00
Jonathan Wakely d5cc6de1be PR libstdc++/87963 fix build for 64-bit mingw
PR libstdc++/87963
	* src/c++17/memory_resource.cc (chunk::_M_bytes): Change type from
	unsigned to uint32_t.
	(chunk): Fix static assertion for 64-bit targets that aren't LP64.
	(bigblock::all_ones): Fix undefined shift.

From-SVN: r266032
2018-11-12 15:25:40 +00:00
Hans-Peter Nilsson b5dda6c13b Fix copypasto in las ChangeLog.
From-SVN: r266019
2018-11-11 22:21:28 +00:00
Hans-Peter Nilsson 63100c5433 re PR libstdc++/54005 (Use __atomic_always_lock_free in libstdc++ is_lock_free instead of __atomic_is_lock_free)
PR libstdc++-v3/54005
	* include/bits/atomic_base.h (__atomic_base<_TTp>::is_lock_free(),
	__atomic_base<_PTp*>::is_lock_free()): Call __atomic_always_lock_free
	with the type-derived _S_alignment instead of __alignof the object.
	* include/std/atomic (atomic<T>::is_lock_free()): Likewise.

From-SVN: r266018
2018-11-11 22:20:19 +00:00
Jonathan Wakely 3d18dc9db0 Implement P0318R1 unwrap_ref_decay and unwrap_reference
Implement P0318R1 unwrap_ref_decay and unwrap_reference
	* include/std/type_traits (unwrap_reference, unwrap_reference_t)
	(unwrap_ref_decay, unwrap_ref_decay_t): New traits and aliases.
	* testsuite/20_util/unwrap_reference/1.cc: New test.
	* testsuite/20_util/unwrap_reference/2.cc: New test.

From-SVN: r266010
2018-11-11 05:17:03 +00:00
Jonathan Wakely 37b736f6bd Implement P1007R3 std::assume_aligned
Implement P1007R3 std::assume_aligned
	* include/std/memory (assume_aligned): Implement for C++17.
	* testsuite/20_util/assume_aligned/1.cc: New test.
	* testsuite/20_util/assume_aligned/2_neg.cc: New test.
	* testsuite/20_util/assume_aligned/3.cc: New test.

From-SVN: r266009
2018-11-11 05:16:51 +00:00
Jonathan Wakely 213fd71709 PR libstdc++/87787 fix UBsan error in std::vector
PR libstdc++/87787
	* include/bits/stl_uninitialized.h (__relocate_a_1): Do not call
	memmove when there's nothing to copy (and pointers could be null).

From-SVN: r265984
2018-11-09 20:14:07 +00:00
Jonathan Wakely fcc499722b Fix whitespace in ChangeLog
From-SVN: r265983
2018-11-09 20:13:58 +00:00
Hafiz Abid Qadeer e9f3803db3 iconv.m4 (AM_ICONV_LINK): Don't overwrite CPPFLAGS.
2018-11-06  Hafiz Abid Qadeer  <abidh@codesourcery.com>

	* config/iconv.m4 (AM_ICONV_LINK): Don't overwrite CPPFLAGS.
	Append $INCICONV to it.

gcc/
	* configure: Regenerated.

libcpp/
	* configure: Likewise.

libstdc++-v3/
	* configure: Likewise.

intl/
	* configure: Likewise.

From-SVN: r265896
2018-11-07 15:41:21 -07:00
Jonathan Wakely 285556b559 Fix linker script to use [jmy] to match size_t parameters
* config/abi/pre/gnu.ver: Fix patterns for size_t parameters.

From-SVN: r265884
2018-11-07 19:08:52 +00:00
Jonathan Wakely 852a971c26 Implement std::pmr::unsynchronized_pool_resource
Implement std::pmr::unsynchronized_pool_resource
	* config/abi/pre/gnu.ver: Add new symbols.
	* include/std/memory_resource (std::pmr::__pool_resource): New class.
	(std::pmr::unsynchronized_pool_resource): New class.
	* src/c++17/Makefile.am: Add -fimplicit-templates to flags for
	memory_resource.cc
	* src/c++17/Makefile.in: Regenerate.
	* src/c++17/memory_resource.cc (bitset, chunk, big_block): New
	internal classes.
	(__pool_resource::_Pool): Define new class.
	(munge_options, pool_index, select_num_pools): New internal functions.
	(__pool_resource::__pool_resource, __pool_resource::~__pool_resource)
	(__pool_resource::allocate, __pool_resource::deallocate)
	(__pool_resource::_M_alloc_pools): Define member functions.
	(unsynchronized_pool_resource::unsynchronized_pool_resource)
	(unsynchronized_pool_resource::~unsynchronized_pool_resource)
	(unsynchronized_pool_resource::release)
	(unsynchronized_pool_resource::_M_find_pool)
	(unsynchronized_pool_resource::do_allocate)
	(unsynchronized_pool_resource::do_deallocate): Define member
	functions.
	* testsuite/20_util/unsynchronized_pool_resource/allocate.cc: New
	test.
	* testsuite/20_util/unsynchronized_pool_resource/is_equal.cc: New
	test.
	* testsuite/20_util/unsynchronized_pool_resource/options.cc: New
	test.
	* testsuite/20_util/unsynchronized_pool_resource/release.cc: New
	test.

From-SVN: r265853
2018-11-06 21:35:27 +00:00
John Bytheway cdc71993cf re PR libstdc++/87872 (debug list::splice should not call _M_transfer_from_if on self-splices)
2018-11-06  John Bytheway  <jbytheway@gmail.com>

	PR libstdc++/87872
	* include/debug/safe_sequence.tcc
	(_Safe_sequence<>::_M_transfer_from_if): Skip transfer to self.

From-SVN: r265851
2018-11-06 20:20:06 +00:00
Joseph Myers 22e0527251 Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856).
This patch updates GCC to use autoconf 2.69 and automake 1.15.1.
(That's not the latest automake version, but it's the one used by
binutils-gdb, with which consistency is desirable, and in any case
seems a useful incremental update that should make a future update to
1.16.1 easier.)

The changes are generally similar to the binutils-gdb ones, and are
copied from there where shared files and directories are involved
(there are some further changes to such shared directories, however,
which I'd expect to apply to binutils-gdb once this patch is in GCC).
Largely, obsolete AC_PREREQ calls are removed, while many
AC_LANG_SOURCE calls are added to avoid warnings from aclocal and
autoconf.  Multilib support is no longer included in core automake,
meaning that multilib.am needs copying from automake's contrib
directory into the GCC source tree.  Autoconf 2.69 has Go support, so
local copies of that support are removed.  I hope the D support will
soon be submitted to upstream autoconf so the local copy of that can
be removed in a future update.  Changes to how automake generates
runtest calls mean quotes are removed from RUNTEST definitions in five
lib*/testsuite/Makefile.am files (libatomic, libgomp, libitm,
libphobos, libvtv; some others have RUNTEST definitions without
quotes, which are still OK); libgo and libphobos also get
-Wno-override added to AM_INIT_AUTOMAKE so those overrides of RUNTEST
do not generate automake warnings.

Note that the regeneration did not include regeneration of
fixincludes/config.h.in (attempting such regeneration resulted in all
the USED_FOR_TARGET conditionals disappearing; and I don't see
anything in the fixincludes/ directory that would result in such
conditionals being generated, unlike in the gcc/ directory).  Also
note that libvtv/testsuite/other-tests/Makefile.in was not
regenerated; that directory is not listed as a subdirectory for which
Makefile.in gets regenerated by calling "automake" in libvtv/, so I'm
not sure how it's meant to be regenerated.

While I mostly fixed warnings should running aclocal / automake /
autoconf, there were various such warnings from automake in the
libgfortran, libgo, libgomp, liboffloadmic, libsanitizer, libphobos
directories that I did not fix, preferring to leave those to the
relevant subsystem maintainers.  Specifically, most of those warnings
were of the following form (example from libgfortran):

Makefile.am:48: warning: source file 'caf/single.c' is in a subdirectory,
Makefile.am:48: but option 'subdir-objects' is disabled
automake: warning: possible forward-incompatibility.
automake: At least a source file is in a subdirectory, but the 'subdir-objects'
automake: automake option hasn't been enabled.  For now, the corresponding output
automake: object file(s) will be placed in the top-level directory.  However,
automake: this behaviour will change in future Automake versions: they
will
automake: unconditionally cause object files to be placed in the same subdirectory
automake: of the corresponding sources.
automake: You are advised to start using 'subdir-objects' option throughout your
automake: project, to avoid future incompatibilities.

I think it's best for the relevant maintainers to add subdir-objects
and do any other associated Makefile.am changes needed.  In some cases
the paths in the warnings involved ../; I don't know if that adds any
extra complications to the use of subdir-objects.

I've tested this with native, cross and Canadian cross builds.  The
risk of any OS-specific issues should I hope be rather lower than if a
libtool upgrade were included (we *should* do such an upgrade at some
point, but it's more complicated - it involves identifying all our
local libtool changes to see if any aren't included in the upstream
version we update to, and reverting an upstream libtool patch that's
inappropriate for use in GCC); I think it would be better to get this
update into GCC so that people can test in different configurations
and we can fix any issues found, rather than to try to get more and
more testing done before it goes in.

top level:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* multilib.am: New file.  From automake.

	Merge from binutils-gdb:
	2018-06-19  Simon Marchi  <simon.marchi@ericsson.com>

	* libtool.m4: Use AC_LANG_SOURCE.
	* configure.ac: Remove AC_PREREQ, use AC_LANG_SOURCE.
	* ar-lib: New file.
	* test-driver: New file.
	* configure: Re-generate.

config:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* math.m4, tls.m4: Use AC_LANG_SOURCE.

	Merge from binutils-gdb:
	2018-06-19  Simon Marchi  <simon.marchi@ericsson.com>

	* override.m4 (_GCC_AUTOCONF_VERSION): Bump from 2.64 to 2.69.

fixincludes:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* configure.ac: Remove AC_PREREQ.
	* aclocal.m4, configure: Regenerate.

gcc:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* configure.ac: Remove AC_PREREQ.  Use AC_LANG_SOURCE.  Use single
	line for second argument of AC_DEFINE_UNQUOTED.
	* doc/install.texi (Tools/packages necessary for modifying GCC):
	Update to autoconf 2.69 and automake 1.15.1.
	* aclocal.m4, config.in, configure: Regenerate.

gnattools:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* configure.ac: Remove AC_PREREQ.
	* configure: Regenerate.

gotools:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* config/go.m4: Remove file.
	* Makefile.am (ACLOCAL_AMFLAGS): Do not use -I ./config.
	* configure.ac:  Remove AC_PREREQ.  Do not include config/go.m4.
	* Makefile.in, aclocal.m4, configure: Regenerate.

intl:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	Merge from binutils-gdb:
	2018-06-19  Simon Marchi  <simon.marchi@ericsson.com>

	* configure.ac: Add AC_USE_SYSTEM_EXTENSIONS, remove AC_PREREQ.
	* configure: Re-generate.
	* config.h.in: Re-generate.
	* aclocal.m4: Re-generate.

libada:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* configure.ac: Remove AC_PREREQ.
	* configure: Regenerate.

libatomic:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* Makefile.am: Include multilib.am.
	* acinclude.m4: Use AC_LANG_SOURCE.
	* configure.ac: Remove AC_PREREQ.
	* testsuite/Makefile.am (RUNTEST): Remove quotes.
	* Makefile.in, aclocal.m4, configure, testsuite/Makefile.in:
	Regenerate.

libbacktrace:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* Makefile.am: Include multilib.am.
	* configure.ac: Remove AC_PREREQ.  Use AC_LANG_SOURCE.
	* Makefile.in, aclocal.m4, config.h.in, configure: Regenerate.

libcc1:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* configure.ac: Remove AC_PREREQ.
	* Makefile.in, aclocal.m4, configure: Regenerate.

libcpp:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* configure.ac: Remove AC_PREREQ.  Use AC_LANG_SOURCE.
	* aclocal.m4, config.in, configure: Regenerate.

libdecnumber:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	Merge from binutils-gdb:
	2018-06-19  Simon Marchi  <simon.marchi@ericsson.com>

	* configure.ac: Remove AC_PREREQ.
	* configure: Re-generate.
	* aclocal.m4.

libffi:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* Makefile.am: Include multilib.am.
	(AUTOMAKE_OPTIONS): Add info-in-builddir.
	(CLEANFILES): Remove doc/libffi.info.
	* configure.ac: Remove AC_PREREQ.
	* Makefile.in, aclocal.m4, configure, fficonfig.h.in,
	include/Makefile.in, man/Makefile.in, testsuite/Makefile.in:
	Regenerate.

libgcc:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* configure.ac: Remove AC_PREREQ.  Use AC_LANG_SOURCE.
	* configure: Regenerate.

libgfortran:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* Makefile.am: Include multilib.am.
	* configure.ac: Remove AC_PREREQ.
	* Makefile.in, aclocal.m4, config.h.in, configure: Regenerate.

libgo [logically part of this change but omitted from the commit]:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* Makefile.am: Include multilib.am.
	* config/go.m4: Remove file.
	* config/libtool.m4: Use AC_LANG_SOURCE.
	* configure.ac: Remove AC_PREREQ.  Use AC_LANG_SOURCE.  Use
	-Wno-override in AM_INIT_AUTOMAKE call.
	* Makefile.in, aclocal.m4, configure, testsuite/Makefile.in:
	Regenerate.

libgomp:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* Makefile.am: Include multilib.am
	(AUTOMAKE_OPTIONS): Add info-in-builddir.
	(CLEANFILES): Remove libgomp.info.
	* configure.ac: Remove AC_PREREQ.
	* testsuite/Makefile.am (RUNTEST): Remove quotes.
	* Makefile.in, aclocal.m4, configure, testsuite/Makefile.in:
	Regenerate.

libhsail-rt:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* configure.ac: Remove AC_PREREQ.
	* Makefile.in, aclocal.m4, configure: Regenerate.

libiberty:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	Merge from binutils-gdb:
	2018-06-19  Simon Marchi  <simon.marchi@ericsson.com>

	* configure.ac: Remove AC_PREREQ.
	* configure: Re-generate.
	* config.in: Re-generate.

libitm:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* Makefile.am: Include multilib.am.
	(AUTOMAKE_OPTIONS): Add info-in-builddir.
	(CLEANFILES): Remove libitm.info.
	* configure.ac: Remove AC_PREREQ.
	* testsuite/Makefile.am (RUNTEST): Remove quotes.
	* Makefile.in, aclocal.m4, configure, testsuite/Makefile.in:
	Regenerate.

libobjc:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* configure.ac: Remove AC_PREREQ.
	* aclocal.m4, config.h.in, configure: Regenerate.

liboffloadmic:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* Makefile.am: Include multilib.am.
	* configure.ac: Remove AC_PREREQ.
	* plugin/Makefile.am: Include multilib.am.
	* plugin/configure.ac: Remove AC_PREREQ.
	* Makefile.in, aclocal.m4, configure, plugin/Makefile.in,
	plugin/aclocal.m4, plugin/configure: Regenerate.

libphobos:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* Makefile.am: Include multilib.am.
	* configure.ac: Remove AC_PREREQ.  Use -Wno-override in
	AM_INIT_AUTOMAKE call.
	* m4/autoconf.m4: Add extra argument to AC_LANG_DEFINE call.
	* m4/druntime/os.m4: Use AC_LANG_SOURCE.
	* testsuite/Makefile.am (RUNTEST): Remove quotes.
	* Makefile.in, aclocal.m4, configure, libdruntime/Makefile.in,
	src/Makefile.in, testsuite/Makefile.in: Regenerate.

libquadmath:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* Makefile.am: Include multilib.am.
	(AUTOMAKE_OPTIONS): Remove 1.8.  Add info-in-builddir.
	(all-local): Define outside conditional code.
	(CLEANFILES): Remove libquadmath.info.
	* configure.ac: Remove AC_PREREQ.
	* Makefile.in, aclocal.m4, config.h.in, configure: Regenerate.

libsanitizer:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* Makefile.am: Include multilib.am.
	* configure.ac: Remove AC_PREREQ.  Use AC_LANG_SOURCE.
	* Makefile.in, aclocal.m4, asan/Makefile.in, configure,
	interception/Makefile.in, libbacktrace/Makefile.in,
	lsan/Makefile.in, sanitizer_common/Makefile.in, tsan/Makefile.in,
	ubsan/Makefile.in: Regenerate.

libssp:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* Makefile.am: Include multilib.am.
	(AUTOMAKE_OPTIONS): Remove 1.9.5.
	* configure.ac: Remove AC_PREREQ.  Quote argument to
	AC_RUN_IFELSE.
	* Makefile.in, aclocal.m4, configure: Regenerate.

libstdc++-v3:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* Makefile.am: Include multilib.am.
	* configure.ac: Remove AC_PREREQ.
	* Makefile.in, aclocal.m4, configure, doc/Makefile.in,
	include/Makefile.in, libsupc++/Makefile.in, po/Makefile.in,
	python/Makefile.in, src/Makefile.in, src/c++11/Makefile.in,
	src/c++17/Makefile.in, src/c++98/Makefile.in,
	src/filesystem/Makefile.in, testsuite/Makefile.in: Regenerate.

libvtv:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* Makefile.am: Include multilib.am.
	* configure.ac: Remove AC_PREREQ.
	* testsuite/Makefile.am (RUNTEST): Remove quotes.
	* Makefile.in, aclocal.m4, configure, testsuite/Makefile.in:
	Regenerate.

lto-plugin:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* configure.ac: Remove AC_PREREQ.  Use AC_LANG_SOURCE.
	* Makefile.in, aclocal.m4, config.h.in, configure: Regenerate.

zlib:
2018-10-31  Joseph Myers  <joseph@codesourcery.com>

	PR bootstrap/82856
	* Makefile.am: Include multilib.am.

	Merge from binutils-gdb:
	2018-06-19  Simon Marchi  <simon.marchi@ericsson.com>

	* configure.ac: Modernize AC_INIT call, remove AC_PREREQ.
	* Makefile.am (AUTOMAKE_OPTIONS): Remove 1.8, cygnus, add foreign.
	* Makefile.in: Re-generate.
	* aclocal.m4: Re-generate.
	* configure: Re-generate.

From-SVN: r265695
2018-10-31 17:03:16 +00:00
Jonathan Wakely d5e33619bf More testing for std::pair layout change
* testsuite/20_util/pair/87822.cc: Test deeper nesting.

From-SVN: r265680
2018-10-31 12:58:45 +00:00
Jonathan Wakely 0db78d0a5e PR libstdc++/87822 fix layout change for nested std::pair
The introduction of the empty __pair_base base class for PR 86751
changed the layout of std::pair<std::pair<...>, ...>. The outer pair and
its first member both have a base class of the same type, which cannot
exist at the same address. This causes the first member to be at a
non-zero offset.

The solution is to make the base class depend on the template
parameters, so that each pair type has a different base class type,
which allows the base classes of the outer pair and its first member to
have the same address.

	PR libstdc++/87822
	* include/bits/stl_pair.h (__pair_base): Change to class template.
	(pair): Make base class type depend on template parameters.
	* testsuite/20_util/pair/87822.cc: New test.

From-SVN: r265678
2018-10-31 12:29:02 +00:00
Marek Polacek b5ff4f5c0d Implement P0892R2, explicit(bool).
* c-cppbuiltin.c (c_cpp_builtins): Define __cpp_explicit_bool.

	* call.c (add_template_candidate_real): Return if the declaration is
	explicit and we're only looking for non-converting constructor.
	* cp-tree.h (lang_decl_fn): Add has_dependent_explicit_spec_p bit.
	(DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P): New macro.
	(cp_decl_specifier_seq): Add explicit_specifier field.
	(build_explicit_specifier, store_explicit_specifier): Declare.
	* decl.c (grokdeclarator): Call store_explicit_specifier.
	(build_explicit_specifier): New function.
	* parser.c (cp_parser_function_specifier_opt) <case RID_EXPLICIT>:
	Parse C++20 explicit(bool).
	* pt.c (store_explicit_specifier, lookup_explicit_specifier): New.
	(tsubst_function_decl): Handle explicit(dependent-expr).

	* g++.dg/cpp2a/explicit1.C: New test.
	* g++.dg/cpp2a/explicit10.C: New test.
	* g++.dg/cpp2a/explicit11.C: New test.
	* g++.dg/cpp2a/explicit12.C: New test.
	* g++.dg/cpp2a/explicit13.C: New test.
	* g++.dg/cpp2a/explicit2.C: New test.
	* g++.dg/cpp2a/explicit3.C: New test.
	* g++.dg/cpp2a/explicit4.C: New test.
	* g++.dg/cpp2a/explicit5.C: New test.
	* g++.dg/cpp2a/explicit6.C: New test.
	* g++.dg/cpp2a/explicit7.C: New test.
	* g++.dg/cpp2a/explicit8.C: New test.
	* g++.dg/cpp2a/explicit9.C: New test.

	* testsuite/20_util/any/cons/explicit.cc: Adjust dg-error.
	* testsuite/20_util/pair/cons/explicit_construct.cc: Likewise.
	* testsuite/20_util/tuple/cons/explicit_construct.cc: Likewise.

From-SVN: r265641
2018-10-30 19:59:41 +00:00
Jonathan Wakely 0321d9fac6 PR libstdc++/87809 avoid invalid expressions in exception specifications
If the allocator isn't default constructible then checking if the
default constructor throws in an exception specification makes the
declaration invalid. Use the type trait instead.

	PR libstdc++/87809
	* include/bits/forward_list.h (_Fwd_list_impl::_Fwd_list_impl()): Use
	trait in exception-specification instead of possibly invalid
	expression.
	* include/bits/stl_bvector.h (_Bvector_impl::_Bvector_impl()):
	Likewise.
	* include/bits/stl_list.h (_List_impl::_List_impl()): Likewise.
	* include/bits/stl_vector.h (_Vector_impl::_Vector_impl()): Likewise.
	* testsuite/23_containers/forward_list/cons/87809.cc: New test.
	* testsuite/23_containers/list/cons/87809.cc: New test.
	* testsuite/23_containers/vector/bool/cons/87809.cc: New test.
	* testsuite/23_containers/vector/cons/87809.cc: New test.

From-SVN: r265626
2018-10-30 14:49:43 +00:00
Jonathan Wakely c397f267f1 PR libstdc++/87784 fix dynamic_bitset::push_back
Previously the _M_Nb member was incremented before calling
_M_unchecked_set which meant that the bit being set was out of bounds.
It either set the wrong bit in an allocated word, or accessed beyond the
end of the allocated memory in the _M_w vector. The fix for the bug is
to update the _M_Nb member after using it as an index.

As an optimisation, when a new block needs to be appended the call to
_M_unchecked_set can be avoided by appending a block with the least
significant bit already set to the desired value.

	PR libstdc++/87784
	* include/tr2/dynamic_bitset (dynamic_bitset::push_back): When there
	are no unused bits in the last block, append a new block with the
	right value so the bit doesn't need to be set. Only increment size
	after setting the new bit, not before.
	* testsuite/tr2/dynamic_bitset/pr87784.cc: New test.

From-SVN: r265625
2018-10-30 14:49:32 +00:00
David Malcolm 7e2de6df10 C++: simplify output from suggest_alternatives_for
In the C++ FE, after emitting various errors about unrecognized names,
the parser can call
  suggest_alternatives_for
and/or
  suggest_alternative_in_explicit_scope.
These can issue zero or more suggestions for the unrecognized name,
or various other "note" diagnostics suggesting how to fix the problem.

For example, currently g++ emits:

t.cc:12:3: error: 'gtk_widget_showall' was not declared in this scope
12 |   gtk_widget_showall (w);
   |   ^~~~~~~~~~~~~~~~~~
t.cc:12:3: note: suggested alternative: 'gtk_widget_show_all'
12 |   gtk_widget_showall (w);
   |   ^~~~~~~~~~~~~~~~~~
   |   gtk_widget_show_all

This patch consolidates the common case when there is a single
candidate, so that the error can issue a fix-it hint directly.

This simplifies the above to:

t.cc:12:3: error: 'gtk_widget_showall' was not declared in this scope;
 did you mean 'gtk_widget_show_all'?
12 |   gtk_widget_showall (w);
   |   ^~~~~~~~~~~~~~~~~~
   |   gtk_widget_show_all

omitting the second "note" diagnostic.

Doing so requires changing the above "suggest_" functions so that
rather than being called after "error" and emitting a note directly,
they are called before the "error", and return a name_hint, which
can contain a suggestion and/or a deferred diagnostic.  The "single
candidate" case is handled via a suggestion, and the "multiple
candidates" case via a new subclass of deferred_diagnostic.

There was some complication due to the fact that we don't always have
enough location information to issue a fix-it hint.  Specifically,
for the case in qualified_name_lookup_error, the location is that of
the name, but the location of the qualifier prefix isn't reliably
available.  For some hints, e.g. spell-corrections, the replacement
is of the name, and for others, e.g. parent namespaces, it's for the
qualified name.  The patch addresses this by splitting this case out
into a new "suggest_alternatives_in_other_namespaces" function, for
which fix-it hints aren't issued.

Another complication is that of emitting a note when
  --param cxx-max-namespaces-for-diagnostic-help
is reached.  The patch emulates the existing behavior by emitting
the note from a deferred_diagnostic.  This potentially needs to
co-exist with another deferred_diagnostic, so it works as a decorator
around any other such deferred_diagnostic.  Doing so requires slightly
extending class name_hint.

On adding test coverage for the various cases, I discovered that
after emitting a "FOO is not a namespace-name" error, we also emit
a "expected namespace-name before" error.  The patch removes this
second error for the case where it's redundant, simplifying this case
from e.g.:

spellcheck-ns.C:10:24: error: 'inner_ms' is not a namespace-name
10 | using namespace outer::inner_ms;
   |                        ^~~~~~~~
spellcheck-ns.C:10:24: note: suggested alternative: 'inner_ns'
10 | using namespace outer::inner_ms;
   |                        ^~~~~~~~
   |                        inner_ns
spellcheck-ns.C:10:32: error: expected namespace-name before ';' token
10 | using namespace outer::inner_ms;
   |                                ^

to:

spellcheck-ns.C:10:24: error: 'inner_ms' is not a namespace-name;
 did you mean 'inner_ns'?
10 | using namespace outer::inner_ms;
   |                        ^~~~~~~~
   |                        inner_ns

include/ChangeLog:
	* unique-ptr.h (gnu::move): Generalize so it applies to all
	lvalue references, rather than just to unique_ptr values.

gcc/c-family/ChangeLog:
	* name-hint.h (name_hint::take_deferred): New member function.

gcc/c/ChangeLog:
	* c-decl.c (implicit_decl_warning): Update "is there a suggestion"
	logic for change to name_hint::operator bool.
	(undeclared_variable): Likewise.
	* c-parser.c (c_parser_declaration_or_fndef): Likewise.
	(c_parser_parameter_declaration): Likewise.

gcc/cp/ChangeLog:
	* cp-name-hint.h: New file.
	* cp-tree.h (expr_to_string): New decl.
	(suggest_alternatives_for): Move to cp-name-hint.h, changing
	return type from bool to name_hint.
	(suggest_alternative_in_explicit_scope): Likewise.
	* error.c: Define INCLUDE_UNIQUE_PTR.  Include "cp-name-hint.h".
	(expr_to_string): Make non-static.
	(qualified_name_lookup_error): For the non-"::" case, take
	responsibity for issuing any suggestion from
	suggest_alternative_in_explicit_scope, as it changes from
	returning a bool to returning a name_hint.  Replace fallback call
	to suggest_alternatives_for to a call to
	suggest_alternatives_in_other_namespaces, capturing the fact that
	we don't have enough location information to issue a fix-it hint
	for this case.  Update the error to support emitting a fix-it hint
	where appropriate.  For the "::" case, take responsibility for
	issuing any suggestion from suggest_alternatives_for, supporting
	emitting a fix-it hint.
	* lex.c: Define INCLUDE_UNIQUE_PTR.  Include "gcc-rich-location.h"
	and "cp-name-hint.h".
	(unqualified_name_lookup_error): Take responsibility for issuing
	any suggestion from suggest_alternatives_for, supporting emitting
	a fix-it hint.
	* name-lookup.c (class namespace_limit_reached): New subclass of
	deferred_diagnostic.
	(class show_candidate_location): Likewise.
	(class suggest_alternatives): Likewise.
	(class namespace_hints): New class.
	(suggest_alternatives_for): Convert return type from bool to
	name_hint, replacing all direct diagnostic emission by setting
	suggestions on the return value, or creating deferred diagnostics.
	Specifically, split out initial traversal of namespaces into
	namespace_hints' ctor, and maybe_decorate_with_limit, and move the
	rest of the implementation to
	namespace_hints::convert_candidates_to_name_hint and
	suggest_alternatives_for_1.
	(namespace_hints::namespace_hints): New ctor, adapted from
	suggest_alternatives_for's initial namespace traversal, storing
	location and name, and converting locals "candidates", "limited"
	and "limit" into members.
	(namespace_hints::convert_candidates_to_name_hint): New member
	function.
	(namespace_hints::maybe_decorate_with_limit): New member function.
	(suggest_alternatives_for_1): New function, based on second half
	of old implementation of suggest_alternatives_for, converting from
	immediate emission of suggestions to using name_hint.
	(suggest_alternatives_in_other_namespaces): New function.
	(maybe_suggest_missing_std_header): Convert from immediate
	emission of suggestions to using name_hint, moving emission
	implementation to...
	(class missing_std_header): New subclass of deferred_diagnostic.
	(maybe_suggest_missing_header): Convert return type from bool to
	name_hint.
	(suggest_alternative_in_explicit_scope): Convert from immediate
	emission of suggestions to using name_hint.
	* parser.c: Replace include of "c-family/name-hint.h" with
	"cp-name-hint.h".
	(cp_parser_diagnose_invalid_type_name): Update
	"is there a suggestion" logic for change to
	name_hint::operator bool.  Take responsibility for emitting
	fix-it hints from suggest_alternative_in_explicit_scope.
	(cp_parser_namespace_name): Take responsibility for emitting
	fix-it hints from suggest_alternative_in_explicit_scope.  Don't
	emit the "expected namespace-name" error if we've already emitted
	an "is not a namespace-name" error.

gcc/testsuite/ChangeLog:
	* c-c++-common/spellcheck-reserved.c: Update expected output for
	C++ for merger of "did you mean" suggestions into the error
	message.
	* g++.dg/ext/builtin3.C: Update expected output for merger of "did
	you mean" suggestion into the error.
	* g++.dg/lookup/error1.C: Likewise.
	* g++.dg/lookup/pr77549.C: Likewise.
	* g++.dg/lookup/pr80913.C: Likewise.
	* g++.dg/lookup/suggestions1.C: Likewise.
	* g++.dg/lookup/suggestions2.C: New test.
	* g++.dg/overload/koenig1.C: Update expected output as above.
	* g++.dg/spellcheck-identifiers-2.C: Likewise.
	* g++.dg/spellcheck-identifiers.C: Likewise.
	* g++.dg/spellcheck-ns.C: New test.
	* g++.dg/spellcheck-pr77829.C: Update expected output as above.
	* g++.dg/spellcheck-pr78656.C: Likewise.
	* g++.dg/spellcheck-pr79298.C: Likewise, adding
	-fdiagnostics-show-caret to options.
	* g++.dg/spellcheck-pr80177.C: Likewise.
	* g++.dg/spellcheck-single-vs-multiple.C: New test.
	* g++.dg/spellcheck-typenames.C: Update expected output as above.
	* g++.dg/template/static10.C: Likewise.
	* g++.old-deja/g++.mike/ns5.C: Likewise.
	* g++.old-deja/g++.mike/ns7.C: Likewise.
	* g++.old-deja/g++.ns/koenig5.C: Likewise.
	* g++.old-deja/g++.other/lineno5.C: Likewise.

libstdc++-v3/ChangeLog:
	* testsuite/17_intro/using_namespace_std_exp_neg.cc: Remove
	"expected namespace-name before" error.
	* testsuite/17_intro/using_namespace_std_tr1_neg.cc: Likewise.

From-SVN: r265610
2018-10-29 23:53:50 +00:00
François Dumont 881eaae688 48101_neg.cc: Remove dg-prune-output 'std' from regex pattern for versioned namespace...
2018-10-28  François Dumont  <fdumont@gcc.gnu.org>

	* testsuite/23_containers/deque/48101_neg.cc: Remove dg-prune-output
	'std' from regex pattern for versioned namespace compatibility.
	* testsuite/23_containers/vector/48101_neg.cc: Likewise.
	* testsuite/27_io/filesystem/path/io/dr2989.cc: Likewise.

From-SVN: r265575
2018-10-28 20:57:04 +00:00
Jonathan Wakely 71e093897c PR libstdc++/87749 fix (and optimize) string move construction
The move constructor for the SSO string uses assign(const basic_string&)
when either:

(1) the source string is "local" and so the contents of the small string
buffer need to be copied, or

(2) the allocator does not propagate and is_always_equal is false.

Case (1) is suboptimal, because the assign member is not noexcept and
the compiler isn't smart enough to see it won't actually throw in this
case. This causes extra code in the move assignment operator so that any
exception will be turned into a call to std::terminate. This can be
fixed by copying small strings inline instead of calling assign.

Case (2) is a bug, because the specific instances of the allocators
could be equal even if is_always_equal is false. This can result in an
unnecessary deep copy (and potentially-throwing allocation) when the
storage should be moved. This can be fixed by simply checking if the
allocators are equal.

	PR libstdc++/87749
	* include/bits/basic_string.h [_GLIBCXX_USE_CXX11_ABI]
	(basic_string::operator=(basic_string&&)): For short strings copy the
	buffer inline. Only fall back to using assign(const basic_string&) to
	do a deep copy when reallocation is needed.
	* testsuite/21_strings/basic_string/modifiers/assign/char/87749.cc:
	New test.
	* testsuite/21_strings/basic_string/modifiers/assign/char/
	move_assign_optim.cc: New test.
	* testsuite/21_strings/basic_string/modifiers/assign/wchar_t/87749.cc:
	New test.
	* testsuite/21_strings/basic_string/modifiers/assign/wchar_t/
	move_assign_optim.cc: New test.

From-SVN: r265493
2018-10-25 16:34:04 +01:00
Marc Glisse 0f317ef762 Relocation (= move+destroy)
2018-10-25  Marc Glisse  <marc.glisse@inria.fr>

	PR libstdc++/87106
	* include/bits/alloc_traits.h (_S_construct, _S_destroy, construct,
	destroy): Add noexcept specification.
	* include/bits/allocator.h (construct, destroy): Likewise.
	* include/ext/alloc_traits.h (construct, destroy): Likewise.
	* include/ext/malloc_allocator.h (construct, destroy): Likewise.
	* include/ext/new_allocator.h (construct, destroy): Likewise.
	* include/bits/stl_uninitialized.h (__relocate_object_a, __relocate_a,
	__relocate_a_1): New functions.
	(__is_trivially_relocatable): New class.
	* include/bits/stl_vector.h (__use_relocate): New static member.
	* include/bits/vector.tcc (reserve, _M_realloc_insert,
	_M_default_append): Use __relocate_a.
	(reserve, _M_assign_aux, _M_realloc_insert, _M_fill_insert,
	_M_default_append, _M_range_insert): Move _GLIBCXX_ASAN_ANNOTATE_REINIT
	after _Destroy.
	* testsuite/23_containers/vector/modifiers/push_back/49836.cc:
	Replace CopyConsOnlyType with DelAnyAssign.

From-SVN: r265485
2018-10-25 13:03:13 +00:00
François Dumont 4b763deedb 2018-10-24 François Dumont <fdumont@gcc.gnu.org>
* include/debug/safe_unordered_container.h
	(_Safe_unordered_container<>::_M_invalidate_locals): Take lambda
	parameter type from local end variable.
	(_Safe_unordered_container<>::_M_invalidate_all): Likewise.
	* include/debug/unordered_map
	(unordered_map<>::begin()): Use C++11 direct initialization.
	(unordered_map<>::end()): Likewise.
	(unordered_map<>::cbegin()): Likewise.
	(unordered_map<>::cend()): Likewise.
	(unordered_map<>::begin(size_type)): Likewise.
	(unordered_map<>::end(size_type)): Likewise.
	(unordered_map<>::cbegin(size_type)): Likewise.
	(unordered_map<>::cend(size_type)): Likewise.
	(unordered_map<>::emplace<>(_Args&&...)): Likewise.
	(unordered_map<>::emplace_hint<>(const_iterator, _Args&&...)): Likewise.
	(unordered_map<>::insert(const value_type&)): Likewise.
	(unordered_map<>::insert(value_type&&)): Likewise.
	(unordered_map<>::insert<>(_Pair&&)): Likewise.
	(unordered_map<>::insert(const_iterator, const value_type&)): Likewise.
	(unordered_map<>::insert(const_iterator, value_type&&)): Likewise.
	(unordered_map<>::insert<>(const_iterator, _Pair&&)): Likewise.
	(unordered_map<>::try_emplace<>(const key_type&, _Args&&...)): Likewise.
	(unordered_map<>::try_emplace<>(key_type&&, _Args&&...)): Likewise.
	(unordered_map<>::try_emplace<>(const_iterator, const key_type&,
	_Args&&...)): Likewise.
	(unordered_map<>::try_emplace<>(const_iterator, key_type&&,
	_Args&&...)): Likewise.
	(unordered_map<>::insert_or_assign<>(const key_type&, _Obj&&)): Likewise.
	(unordered_map<>::insert_or_assign<>(key_type&&, _Obj&&)): Likewise.
	(unordered_map<>::insert_or_assign<>(const_iterator, const key_type&,
	_Obj&&)): Likewise.
	(unordered_map<>::insert_or_assign<>(const_iterator, key_type&&,
	_Obj&&)): Likewise.
	(unordered_map<>::insert(note_type&&)): Likewise.
	(unordered_map<>::find(const key_type&)): Likewise.
	(unordered_map<>::equal_range(const key_type&)): Likewise.
	(unordered_map<>::_M_extract): New.
	(unordered_map<>::extract(const_iterator)): Use latter.
	(unordered_map<>::extract(const key_type&)): Likewise.
	(unordered_map<>::_M_erase): New.
	(unordered_map<>::erase(const key_type&)): Use latter.
	(unordered_map<>::erase(const_iterator)): Likewise.
	(unordered_map<>::erase(iterator)): Likewise.
	(unordered_map<>::_M_invalidate): New.
	(unordered_map<>::erase(const_iterator, const_iterator)): Use latter.
	(unordered_multimap<>::begin()): Use C++11 direct initialization.
	(unordered_multimap<>::end()): Likewise.
	(unordered_multimap<>::cbegin()): Likewise.
	(unordered_multimap<>::cend()): Likewise.
	(unordered_multimap<>::begin(size_type)): Likewise.
	(unordered_multimap<>::end(size_type)): Likewise.
	(unordered_multimap<>::cbegin(size_type)): Likewise.
	(unordered_multimap<>::cend(size_type)): Likewise.
	(unordered_multimap<>::emplace<>(_Args&&...)): Likewise.
	(unordered_multimap<>::emplace_hint<>(const_iterator, _Args&&...)): Likewise.
	(unordered_multimap<>::insert(const value_type&)): Likewise.
	(unordered_multimap<>::insert(const_iterator, const value_type&)): Likewise.
	(unordered_multimap<>::insert(const_iterator, value_type&&)): Likewise.
	(unordered_multimap<>::insert<>(_Pair&&)): Likewise.
	(unordered_multimap<>::insert<>(const_iterator, _Pair&&)): Likewise.
	(unordered_multimap<>::insert(note_type&&)): Likewise.
	(unordered_multimap<>::insert(const_iterator, note_type&&)): Likewise.
	(unordered_multimap<>::find(const key_type&)): Likewise.
	(unordered_multimap<>::equal_range(const key_type&)): Likewise.
	(unordered_multimap<>::_M_extract): New.
	(unordered_multimap<>::extract(const_iterator)): Use latter.
	(unordered_multimap<>::extract(const key_type&)): Likewise.
	(unordered_multimap<>::_M_erase): New.
	(unordered_multimap<>::erase(const_iterator)): Likewise.
	(unordered_multimap<>::erase(iterator)): Likewise.
	(unordered_multimap<>::_M_invalidate): New.
	(unordered_multimap<>::erase(const key_type&)): Use latter.
	(unordered_multimap<>::erase(const_iterator, const_iterator)): Likewise.
	* include/debug/unordered_set
	(unordered_set<>::begin()): Use C++11 direct initialization.
	(unordered_set<>::end()): Likewise.
	(unordered_set<>::cbegin()): Likewise.
	(unordered_set<>::cend()): Likewise.
	(unordered_set<>::begin(size_type)): Likewise.
	(unordered_set<>::end(size_type)): Likewise.
	(unordered_set<>::cbegin(size_type)): Likewise.
	(unordered_set<>::cend(size_type)): Likewise.
	(unordered_set<>::emplace<>(_Args&&...)): Likewise.
	(unordered_set<>::emplace_hint<>(const_iterator, _Args&&...)): Likewise.
	(unordered_set<>::insert(const value_type&)): Likewise.
	(unordered_set<>::insert(value_type&&)): Likewise.
	(unordered_set<>::insert(const_iterator, const value_type&)): Likewise.
	(unordered_set<>::insert(const_iterator, value_type&&)): Likewise.
	(unordered_set<>::insert(note_type&&)): Likewise.
	(unordered_set<>::insert(const_iterator, note_type&&)): Likewise.
	(unordered_set<>::find(const key_type&)): Likewise.
	(unordered_set<>::equal_range(const key_type&)): Likewise.
	(unordered_set<>::_M_extract): New.
	(unordered_set<>::extract(const_iterator)): Use latter.
	(unordered_set<>::extract(const key_type&)): Likewise.
	(unordered_set<>::_M_erase): New.
	(unordered_set<>::erase(const key_type&)): Use latter.
	(unordered_set<>::erase(const_iterator)): Likewise.
	(unordered_set<>::erase(iterator)): Likewise.
	(unordered_set<>::_M_invalidate): New.
	(unordered_set<>::erase(const_iterator, const_iterator)): Use latter.
	(unordered_multiset<>::begin()): Use C++11 direct initialization.
	(unordered_multiset<>::end()): Likewise.
	(unordered_multiset<>::cbegin()): Likewise.
	(unordered_multiset<>::cend()): Likewise.
	(unordered_multiset<>::begin(size_type)): Likewise.
	(unordered_multiset<>::end(size_type)): Likewise.
	(unordered_multiset<>::cbegin(size_type)): Likewise.
	(unordered_multiset<>::cend(size_type)): Likewise.
	(unordered_multiset<>::emplace<>(_Args&&...)): Likewise.
	(unordered_multiset<>::emplace_hint<>(const_iterator, _Args&&...)): Likewise.
	(unordered_multiset<>::insert(const value_type&)): Likewise.
	(unordered_multiset<>::insert(const_iterator, const value_type&)): Likewise.
	(unordered_multiset<>::insert(value_type&&)): Likewise.
	(unordered_multiset<>::insert(const_iterator, value_type&&)): Likewise.
	(unordered_multiset<>::insert(node_type&&)): Likewise.
	(unordered_multiset<>::insert(const_iterator, node_type&&)): Likewise.
	(unordered_multiset<>::find(const key_type&)): Likewise.
	(unordered_multiset<>::equal_range(const key_type&)): Likewise.
	(unordered_multiset<>::_M_extract): New.
	(unordered_multiset<>::extract(const_iterator)): Use latter.
	(unordered_multiset<>::extract(const key_type&)): Likewise.
	(unordered_multiset<>::_M_erase): New.
	(unordered_multiset<>::erase(const_iterator)): Likewise.
	(unordered_multiset<>::erase(iterator)): Likewise.
	(unordered_multiset<>::_M_invalidate): New.
	(unordered_multiset<>::erase(const key_type&)): Use latter.
	(unordered_multiset<>::erase(const_iterator, const_iterator)): Likewise.

From-SVN: r265451
2018-10-24 05:40:25 +00:00
François Dumont a01fc83fea cstddef: Add versioned namespace.
2018-10-24  François Dumont  <fdumont@gcc.gnu.org>

	* include/c_global/cstddef: Add versioned namespace.

From-SVN: r265450
2018-10-24 05:20:35 +00:00
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