Commit Graph

10619 Commits

Author SHA1 Message Date
Jonathan Wakely d80f04d61e Constexpr in std::pointer_traits (P1006R1)
* include/bits/ptr_traits.h [C++20] (pointer_traits<T*>::pointer_to):
	Add constexpr.
	* testsuite/20_util/pointer_traits/pointer_to_constexpr.cc: New test.

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

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

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

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

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

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

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

From-SVN: r269362
2019-03-04 12:21:06 +00:00
Jonathan Wakely 24cbcb003a PR libstdc++/89562 use binary mode for file I/O
PR libstdc++/89562
	* src/filesystem/ops-common.h (do_copy_file): Open files in binary
	mode for mingw.

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

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

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

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

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

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

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

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

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

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

From-SVN: r269234
2019-02-26 23:12:44 +00:00
Jonathan Wakely 3d7beb79e0 PR libstdc++/89416 fix alloc insertable trait for clang (again)
PR libstdc++/89416
	* include/bits/alloc_traits.h (__is_alloc_insertable_impl): Change
	to class template and partial specialization using void_t.
	(__is_copy_insertable, __is_move_insertable): Adjust base class.

From-SVN: r269229
2019-02-26 20:34:46 +00:00
Jonathan Wakely c7f01cb61d PR libstdc++/89416 fix accessibility of members
PR libstdc++/89416
	* include/bits/alloc_traits.h (__is_alloc_insertable_impl): Make
	copy and move members public.

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

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

From-SVN: r269148
2019-02-23 03:01:59 +00:00
Eric Botcazou 047b3e3408 baseline_symbols.txt: Adjust.
* config/abi/post/sparc64-linux-gnu/baseline_symbols.txt: Adjust.
	* config/abi/post/sparc64-linux-gnu/32/baseline_symbols.txt: Likewise.

From-SVN: r269136
2019-02-22 21:25:59 +00:00
Jakub Jelinek fcb141ac22 re PR libstdc++/89402 (warning: ‘void _ZNKSt4hashIeEclEe()’ specifies less restrictive attribute than its target)
PR libstdc++/89402
	* src/c++98/compatibility-ldbl.cc (_ZNKSt4hashIeEclEe): Change return
	type to std::size_t and argument to type to long double.

From-SVN: r269130
2019-02-22 20:10:47 +01:00
Eric Botcazou 406e490892 configure.host (abi_baseline_pair): Adjust for SPARC64/Linux.
* configure.host (abi_baseline_pair): Adjust for SPARC64/Linux.
	* config/abi/post/sparc64-linux-gnu: New directory.
	* config/abi/post/sparc64-linux-gnu/baseline_symbols.txt: New file.
	* config/abi/post/sparc64-linux-gnu/32: New directory.
	* config/abi/post/sparc64-linux-gnu/32/baseline_symbols.txt: New file.

From-SVN: r269096
2019-02-22 07:25:52 +00:00
Jonathan Wakely 148864cb8c Add tests for C++2a content of <atomic> header
* testsuite/29_atomics/headers/atomic/types_std_c++20.cc: New test.
	* testsuite/29_atomics/headers/atomic/types_std_c++20_neg.cc: New
	test.

From-SVN: r269091
2019-02-22 01:16:15 +00:00
Tom Honermann 5940bb028b P0482R5 char8_t: Updates to gdb pretty printing support
This patch adds recognition of the u8string and u8string_view type
aliases to the gdb pretty printer extension.

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

	* python/libstdcxx/v6/printers.py (register_type_printers): Add type
	printers for u8string and u8string_view.

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

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

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

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

From-SVN: r269089
2019-02-22 01:16:08 +00:00
Tom Honermann 65bbaf3125 Disambiguate __gnu_cxx::append_ partial specialization
This patch corrects ambiguous partial specializations of
typelist::detail::append_.  Previously, neither append_<chain<Hd, Tl>,
Typelist_Chain> nor append_<Typelist_Chain, null_type> was a better
match for append_<chain<Hd, Tl>, null_type>.

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

	* include/ext/typelist.h: Constrain a partial specialization of
	typelist::detail::append_ to only match chain<T1,T2>.

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

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

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

From-SVN: r269075
2019-02-21 20:47:43 +00:00
Jakub Jelinek ea1c2a95ba re PR libstdc++/89402 (warning: ‘void _ZNKSt4hashIeEclEe()’ specifies less restrictive attribute than its target)
PR libstdc++/89402
	* src/c++98/compatibility-ldbl.cc (_ZNKSt4hashIeEclEe): Add
	_GLIBCXX_PURE to the alias declaration.

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

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

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

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

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

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

libstdc++:

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

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

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

Committed as obvious.

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

From-SVN: r268989
2019-02-18 14:09:17 +00:00
Jonathan Wakely 323694e9a2 Update libstdc++ documentation for C++2a implementation status
* doc/xml/manual/status_cxx2020.xml: Update P0887R1 status.
	* doc/html/*: Regenerate.

From-SVN: r268885
2019-02-14 17:46:26 +00:00
Jonathan Wakely bb2a18a3a8 Update libstdc++ documentation for implementation status
* doc/xml/manual/status_cxx2017.xml: Add P0063R3 to status table.
	* doc/html/*: Regenerate.

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

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

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

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

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

From-SVN: r268882
2019-02-14 15:08:33 +00:00
Jonathan Wakely a61ae535c3 Add std::timespec and std::timespec_get for C++17
* configure.ac: Check for C11 timespec_get function.
	* crossconfig.m4 (freebsd, linux, gnu, cygwin, solaris, netbsd)
	(openbsd): Likewise
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* include/c_global/ctime (timespec, timespec_get): Add to namespace
	std for C++17 and up.

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

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

From-SVN: r268878
2019-02-14 14:10:19 +00:00
Jonathan Wakely 1138a19dfe Enforce LWG DR 2566 requirement for container adaptors
Although there is no good use for stack<int, deque<double>> or similar
types with a mismatched value_type, it's possible somebody is doing that
and getting away with it currently. This patch only enforces the new
requirement for C++17 and later. During stage 1 we should consider
enforcing it for C++11 and C++14.

	* doc/xml/manual/intro.xml: Document LWG 2566 status.
	* include/bits/stl_queue.h (queue, priority_queue): Add static
	assertions to enforce LWG 2566 requirement on value_type.
	* include/bits/stl_stack.h (stack): Likewise.

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

From-SVN: r268869
2019-02-14 09:40:02 +00:00
Jonathan Wakely 8936f5310a Document LWG 2735 status and add test
This DR was already resolved for GCC 7.1 by the implementation of DR
2192, but we didn't have an explicit test for the behaviour that 2735
guarantees.

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

From-SVN: r268867
2019-02-14 09:07:09 +00:00
Jonathan Wakely 329c0f891a PR libstdc++/89345 Only define std::destroying_delete for C++2a
Clang defines the __cpp_impl_destroying_delete macro unconditionally, so
that the feature is supported whenever the library type is defined. This
is incompatible with the current definition in libstdc++ because we use
constexpr and inline variables, which will give an error for older -std
modes.

This patch defines the destroying_delete_t type and destroying_delete
variable independently of the __cpp_impl_destroying_delete macro, but
only for C++2a (because the names aren't reserved for previous
standards). The __cpp_lib_destroying_delete macro is only defined when
both the library type and compiler macro are defined (i.e. when the type
can actually be used as intended).

	PR libstdc++/89345
	* include/std/version [__cpp_impl_destroying_delete]
	(__cpp_lib_destroying_delete): Only define for C++2a and later.
	* libsupc++/new [__cpp_impl_destroying_delete]
	(__cpp_lib_destroying_delete): Likewise.
	(destroying_delete_t, destroying_delete): Likewise, but define even
	when __cpp_impl_destroying_delete is not defined.
	* testsuite/18_support/destroying_delete.cc: New test.

From-SVN: r268856
2019-02-13 22:13:45 +00:00
Jonathan Wakely 271ad97b6b PR libstdc++/89023 fix test that fails when <omp.h> not available
Instead of a single test that only checks whether <regex> can be
included in Parallel Mode, add tests for each of C++11/C++14/C++17 that
check whether <bits/extc++.h> is compatible with _GLIBCXX_PARALLEL.
This increases the coverage to (almost) all headers.

If <omp.h> is not available then the tests will trivially pass, because
we don't care about compatibility with _GLIBCXX_PARALLEL in that case.

	PR libstdc++/89023
	* testsuite/17_intro/headers/c++2011/parallel_mode.cc: New test.
	* testsuite/17_intro/headers/c++2014/parallel_mode.cc: New test.
	* testsuite/17_intro/headers/c++2017/parallel_mode.cc: New test.
	* testsuite/28_regex/headers/regex/parallel_mode.cc: Remove.

From-SVN: r268769
2019-02-11 12:56:59 +00:00
Jonathan Wakely 4fe5c8c730 Add noexcept to filesystem::path query functions
In the standard these member functions are specified in terms of the
potentially-throwing path decompositions functions, but we implement
them without constructing any new paths or doing anything else that can
throw.

	PR libstdc++/71044
	* include/bits/fs_path.h (path::has_root_name)
	(path::has_root_directory, path::has_root_path)
	(path::has_relative_path, path::has_parent_path)
	(path::has_filename, path::has_stem, path::has_extension)
	(path::is_absolute, path::is_relative, path::_M_find_extension): Add
	noexcept.
	* src/c++17/fs_path.cc (path::has_root_name)
	(path::has_root_directory, path::has_root_path)
	(path::has_relative_path, path::has_parent_path)
	(path::has_filename, path::_M_find_extension): Add noexcept.

From-SVN: r268713
2019-02-09 00:25:39 +00:00
Jonathan Wakely 373c726ec6 PR libstdc++/89102 fix common_type<> and common_type<T> specializations
This is a partial implementation of the revised std::common_type rules
from P0435R1.

	PR libstdc++/89102 (partial)
	* include/std/type_traits (common_type<>): Define.
	(common_type<T>): Derive from common_type<T, T>.
	* testsuite/20_util/common_type/requirements/explicit_instantiation.cc:
	Test zero-length template argument list.
	* testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc:
	Test additional single argument cases.
	* testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc:
	Adjust expected error.

From-SVN: r268586
2019-02-06 17:25:26 +00:00
Jonathan Wakely 5bb89e0a28 PR libstdc++/89128 add deduction guides for container adaptors
PR libstdc++/89128
	* include/bits/stl_queue.h (queue, priority_queue): Add deduction
	guides.
	* include/bits/stl_stack.h (stack): Likewise.
	* testsuite/23_containers/priority_queue/deduction.cc: New test.
	* testsuite/23_containers/queue/deduction.cc: New test.
	* testsuite/23_containers/stack/deduction.cc: New test.

From-SVN: r268566
2019-02-05 22:58:22 +00:00
Jonathan Wakely ed99e818e0 PR libstdc++/89194 untangle is_convertible and is_nothrow_convertible
The additional logic added to __is_convertible_helper in order to
support is_nothrow_convertible makes some uses of is_convertible
ill-formed. This appears to be due to PR c++/87603, but can be avoided
just by defining a separate helper for is_nothrow_convertible. The same
problems are likely to still exist for is_nothrow_convertible, but that
is new and so won't cause regressions for existing users of
is_convertible.

	PR libstdc++/89194
	* include/std/type_traits (__is_convertible_helper)
	(__is_convertible_helper<_From, _To, false>): Revert changes to
	support is_nothrow_convertible.
	(__is_nt_convertible_helper): New helper.
	(is_nothrow_convertible): Use __is_nt_convertible_helper.

From-SVN: r268543
2019-02-05 15:45:24 +00:00
Jonathan Wakely 39bc6f8752 Restore previous behaviour of test
Go back to using CopyConsOnlyType as before r265485, because it works
again now. Add test using DelAnyAssign for completeness and additional
coverage.

	* testsuite/23_containers/vector/modifiers/push_back/49836.cc: Restore
	use of CopyConsOnlyType, but also test DelAnyAssign for completeness.

From-SVN: r268539
2019-02-05 14:53:53 +00:00
Jonathan Wakely 258bd1d63a PR libstdc++/89130 restore support for non-MoveConstructible types
The changes to "relocate" std::vector elements can lead to new errors
outside the immediate context, because moving the elements to new
storage no longer makes use of the move-if-noexcept utilities. This
means that types with deleted moves no longer degenerate to copies, but
are just ill-formed. The errors happen while instantiating the
noexcept-specifier for __relocate_object_a, when deciding whether to try
to relocate.

This patch introduces indirections to avoid the ill-formed
instantiations of std::__relocate_object_a. In order to avoid using
if-constexpr prior to C++17 this is done by tag dispatching. After this
patch all uses of std::__relocate_a are guarded by checks that will
support sensible code (i.e. code not using custom allocators that fool
the new checks).

	PR libstdc++/89130
	* include/bits/alloc_traits.h (__is_copy_insertable_impl): Rename to
	__is_alloc_insertable_impl. Replace single type member with two
	members, one for each of copy and move insertable.
	(__is_move_insertable): New trait for internal use.
	* include/bits/stl_vector.h (vector::_S_nothrow_relocate(true_type))
	(vector::_S_nothrow_relocate(true_type)): New functions to
	conditionally check if __relocate_a can throw.
	(vector::_S_use_relocate()): Dispatch to _S_nothrow_relocate based
	on __is_move_insertable.
	(vector::_S_do_relocate): New overloaded functions to conditionally
	call __relocate_a.
	(vector::_S_relocate): New function that dispatches to _S_do_relocate
	based on _S_use_relocate.
	* include/bits/vector.tcc (vector::reserve, vector::_M_realloc_insert)
	(vector::_M_default_append): Call _S_relocate instead of __relocate_a.
	* testsuite/23_containers/vector/modifiers/push_back/89130.cc: New.

From-SVN: r268537
2019-02-05 14:45:00 +00:00
Jonathan Wakely 2781287255 PR libstdc++/89090 avoid C++17 features in C++11/C++14 code
Although GCC and Clang both allow these features pre-C++17 in system
headers, Clang does issue warnings with -Wsystem-headers. It can also
complicate bisection and/or testcase reduction if # line markers are
stripped, because the code won't be known to come from system headers.

	PR libstdc++/89090
	* include/bits/stl_uninitialized.h (__relocate_a_1): Make unused
	parameter unnamed. Add message to static assertion.
	* include/bits/vector.tcc (vector::reserve, vector::_M_realloc_insert)
	(vector::_M_default_append): Use _GLIBCXX17_CONSTEXPR for if constexpr
	in C++11 code.

From-SVN: r268536
2019-02-05 14:44:56 +00:00
Marc Glisse 9aa2470ab2 Rename __is_trivially_relocatable to __is_bitwise_relocatable.
2019-02-05  Marc Glisse  <marc.glisse@inria.fr>

	PR libstdc++/87106
	* include/bits/stl_uninitialized.h (__is_trivially_relocatable):
	Rename...
	(__is_bitwise_relocatable): ... to this.
	(__relocate_a_1): Adapt.
	* include/bits/stl_deque.h (__is_trivially_relocatable): Rename...
	(__is_bitwise_relocatable): ... to this.

From-SVN: r268532
2019-02-05 09:33:36 +00:00
Jonathan Wakely 9c5365902a PR libstdc++/89117 fix path::replace_extension("") case
Previously the operator+=(extension) call would have re-parsed the path
and recreated the components with the right extension. Since optimising
it to not re-parse the whole string, we need to actually remove the
extension from the final filename before appending anything to it, and
append the dot to that final component too.

	PR libstdc++/89117
	* src/c++17/fs_path.cc (path::replace_extension): Erase extension from
	final component as well as from _M_pathname. Append the dot using
	operator+= instead of only to _M_pathname.
	(path::_M_find_extension): Reformat slightly.
	* testsuite/27_io/filesystem/path/modifiers/replace_extension.cc:
	Add more test cases.

From-SVN: r268406
2019-01-30 23:18:22 +00:00
Ulrich Drepper 7341a03ab8 * doc/xml/manual/status_cxx2020.xml: Update P0600 entry.
From-SVN: r268398
2019-01-30 16:23:44 +00:00
Jonathan Wakely 375d59849a Fix tests for complex overloads of std::arg and std::proj
The test for the synopsis of <complex> incorrectly adds constexpr to
two functions in C++2a mode, but the C++2a draft and the <complex>
header do not declare them constexpr.

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

From-SVN: r268359
2019-01-29 01:49:36 +00:00
Jonathan Wakely 45e7df858b Add missing exports for symbols used by directory iterators
* config/abi/pre/gnu.ver (GLIBCXX_3.4.26): Add missing exports for
	__shared_ptr instantiations used by gcc4-compatible ABI.

From-SVN: r268357
2019-01-29 00:47:43 +00:00
Jonathan Wakely f7f07df5e2 Avoid ambiguity between C++2a std::erase_if and LFTS version
These calls should have been qualified to avoid ADL anyway, but in C++2a
it becomes essential to qualify the calls in experimental::erase because
std::erase_if is also declared and the calls become ambiguous.

	* include/experimental/forward_list (experimental::erase): Qualify
	call to erase_if.
	* include/experimental/list (experimental::erase): Likewise.
	* include/std/forward_list (std::erase): Likewise.
	* include/std/list (std::erase): Likewise.

From-SVN: r268356
2019-01-29 00:47:38 +00:00