Commit Graph

12264 Commits

Author SHA1 Message Date
Jonathan Wakely
e19afa0645 libstdc++: Adjust link to PSTL upstream (again)
The LLVM project renamed their default branch to 'main'.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx2017.xml: Adjust link for PSTL.
	* doc/html/manual/status.html: Regenerate.
2021-03-29 14:14:00 +01:00
GCC Administrator
c411011287 Daily bump. 2021-03-29 00:16:20 +00:00
François Dumont
d04c246cae libstdc++: _GLIBCXX_DEBUG Fix allocator-extended move constructor
libstdc++-v3/ChangeLog:

	* include/debug/forward_list
	(forward_list(forward_list&&, const allocator_type&)): Add noexcept qualification.
	* include/debug/list (list(list&&, const allocator_type&)): Likewise and add
	call to safe container allocator aware move constructor.
	* include/debug/vector (vector(vector&&, const allocator_type&)):
	Fix noexcept qualification.
	* testsuite/23_containers/forward_list/cons/noexcept_move_construct.cc:
	Add allocator-extended move constructor noexceot qualification check.
	* testsuite/23_containers/list/cons/noexcept_move_construct.cc: Likewise.
2021-03-28 22:06:33 +02:00
GCC Administrator
651684b462 Daily bump. 2021-03-27 00:16:27 +00:00
Jonathan Wakely
5f070ba298 libstdc++: Add PRNG fallback to std::random_device
This makes std::random_device usable on VxWorks when running on older
x86 hardware. Since the r10-728 fix for PR libstdc++/85494 the library
will use the new code unconditionally on x86, but the cpuid checks for
RDSEED and RDRAND can fail at runtime, depending on the hardware where
the code is executing. If the OS does not provide /dev/urandom then this
means the std::random_device constructor always fails. In previous
releases if /dev/urandom is unavailable then std::mt19937 was used
unconditionally.

This patch adds a fallback for the case where the runtime cpuid checks
for x86 hardware instructions fail, and no /dev/urandom is available.
When this happens a std::linear_congruential_engine object will be used,
with a seed based on hashing the engine's address and the current time.
Distinct std::random_device objects will use different seeds, unless an
object is created and destroyed and a new object created at the same
memory location within the clock tick. This is not great, but is better
than always throwing from the constructor, and better than always using
std::mt19937 with the same seed (as GCC 9 and earlier do).

libstdc++-v3/ChangeLog:

	* src/c++11/random.cc (USE_LCG): Define when a pseudo-random
	fallback is needed.
	[USE_LCG] (bad_seed, construct_lcg_at, destroy_lcg_at, __lcg):
	New helper functions and callback.
	(random_device::_M_init): Add 'prng' and 'all' enumerators.
	Replace switch with fallthrough with a series of 'if' statements.
	[USE_LCG]: Construct an lcg_type engine and use __lcg when cpuid
	checks fail.
	(random_device::_M_init_pretr1) [USE_MT19937]: Accept "prng"
	token.
	(random_device::_M_getval): Check for callback unconditionally
	and always pass _M_file pointer.
	* testsuite/26_numerics/random/random_device/85494.cc: Remove
	effective-target check. Use new random_device_available helper.
	* testsuite/26_numerics/random/random_device/94087.cc: Likewise.
	* testsuite/26_numerics/random/random_device/cons/default-cow.cc:
	Remove effective-target check.
	* testsuite/26_numerics/random/random_device/cons/default.cc:
	Likewise.
	* testsuite/26_numerics/random/random_device/cons/token.cc: Use
	new random_device_available helper. Test "prng" token.
	* testsuite/util/testsuite_random.h (random_device_available):
	New helper function.
2021-03-26 19:12:12 +00:00
GCC Administrator
4493b1c1ad Daily bump. 2021-03-26 00:16:25 +00:00
François Dumont
50bb46e4d2 libstdc++: Fix and complete __gnu_debug::basic_string implementation
Fix and complete __gnu_debug::basic_string so that it can be used as a transparent
replacement of std::basic_string.

libstdc++-v3/ChangeLog:

	* include/debug/string
	(basic_string(const basic_string&, const _Alloc&)): Define even if !_GLIBCXX_USE_CXX11_ABI.
	(basic_string(basic_string&&, const _Alloc&)): Likewise and add noexcept qualification.
	(basic_string<>::erase): Adapt to take __const_iterator.
	(basic_string(const _CharT*, const _Allocator&)): Remove assign call.
	(basic_string<>::insert(const_iterator, _InputIte, _InputIte)): Try to
	remove iterator debug layer even if !_GLIBCXX_USE_CXX11_ABI.
	[_GLIBCXX_USE_CHAR8_T] (__gnu_debug::u8string): New.
	(__gnu_debug::u16string, __gnu_debug::u32string): New.
	(std::hash<__gnu_debug::basic_string<>>): New partial specialization.
	(std::__is_fast_hash<__gnu_debug::basic_string<>>): Likewise.
	* testsuite/util/exception/safety.h
	(erase_base<__gnu_debug::basic_string<>>): New partial specialization.
	(insert_base<__gnu_debug::basic_string<>>): Likewise.
	* testsuite/util/testsuite_container_traits.h (traits<__gnu_debug::basic_string<>>):
	New partial specialization.
	* testsuite/21_strings/basic_string/hash/debug.cc: New test.
	* testsuite/21_strings/basic_string/requirements/citerators.cc:
	Add test on __gnu_debug::string.
	* testsuite/21_strings/basic_string/requirements/dr438/constructor.cc: Likewise.
	* testsuite/21_strings/basic_string/requirements/exception/basic.cc: Likewise.
	* testsuite/21_strings/basic_string/requirements/exception/generation_prohibited.cc:
	Likewise.
	* testsuite/21_strings/basic_string/requirements/exception/propagation_consistent.cc:
	Likewise.
	* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char16_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char32_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char8_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string/requirements/explicit_instantiation/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string/requirements/typedefs.cc: Likewise.
2021-03-25 21:56:14 +01:00
Jakub Jelinek
2132a36370 c++: Fix source_location inconsistency between calls from templates and non-templates [PR99672]
The srcloc19.C testcase shows inconsistency in
std::source_location::current() locations between calls from
templates and non-templates.  The location used by __builtin_source_location
comes in both cases from input_location which is set on it by bot_manip
when handling the default argument, called during finish_call_expr.
The problem is that in templates that input_location comes from the
CALL_EXPR we built earlier and that has the combined locus with
range between first character of the function name and closing paren
with caret on the opening paren, so something printed as caret as:
foobar ();
~~~~~~^~
But outside of templates, finish_call_expr is called when input_location
is just the closing paren token, i.e.
foobar ();
        ^
and only after that returns we create the combined location and set
the CALL_EXPR location to that.  So, it means std::source_location::current()
reports in templates the column of opening (, while outside of templates
closing ).

The following patch makes it consistent by creating the combined location
already before calling finish_call_expr and temporarily overriding
input_location to that.

2021-03-25  Jakub Jelinek  <jakub@redhat.com>

	PR c++/99672
	* parser.c (cp_parser_postfix_expression): For calls, create
	combined_loc and temporarily set input_location to it before
	calling finish_call_expr.

	* g++.dg/concepts/diagnostic2.C: Adjust expected caret line.
	* g++.dg/cpp1y/builtin_location.C (f4, n6): Move #line directives
	to match locus changes.
	* g++.dg/cpp2a/srcloc1.C: Adjust expected column numbers.
	* g++.dg/cpp2a/srcloc2.C: Likewise.
	* g++.dg/cpp2a/srcloc15.C: Likewise.
	* g++.dg/cpp2a/srcloc16.C: Likewise.
	* g++.dg/cpp2a/srcloc19.C: New test.
	* g++.dg/modules/adhoc-1_b.C: Adjust expected column numbers
	and caret line.
	* g++.dg/modules/macloc-1_c.C: Adjust expected column numbers.
	* g++.dg/modules/macloc-1_d.C: Likewise.
	* g++.dg/plugin/diagnostic-test-expressions-1.C: Adjust expected
	caret line.

	* testsuite/18_support/source_location/consteval.cc (main): Adjust
	expected column numbers.
	* testsuite/18_support/source_location/1.cc (main): Likewise.
2021-03-25 21:35:11 +01:00
Jonathan Wakely
15d649f79d libstdc++: Declare malloc for freestanding
For a target with none of aligned_alloc, memalign etc. we defined our
own aligned_alloc using malloc, so we need a declaration of malloc. As
in libsupc++/new_op.cc we need to declare it ourselves for freestanding
environments.

libstdc++-v3/ChangeLog:

	* libsupc++/new_opa.cc [!_GLIBCXX_HOSTED]: Declare malloc.
2021-03-25 18:25:40 +00:00
Jonathan Wakely
c7fc73ee45 libstdc++: Allow seeding random engines in testsuite
The testsuite utilities that use random numbers use a
default-constructed mersenne_twister_engine, meaning the values are
reproducable. This adds support for seeding them, controlledby an
environment variable. Defining GLIBCXX_SEED_TEST_RNG=val in the
environment will cause the engines to be seeded with atoi(val) if that
is non-zero, or with a value read from std::random_device otherwise.

Running with different seeds revealed some bugs in the tests, where a
randomly selected iterator was past-the-end (which can't be erased), or
where the randomly populated container was empty, and then we tried to
remove elements from it unconditionally.

libstdc++-v3/ChangeLog:

	* testsuite/util/exception/safety.h (setup_base::generate):
	Support seeding random engine.
	(erase_point, erase_range): Adjust range of random numbers to
	ensure dereferenceable iterators are used where required.
	(generation_prohibited::run): Do not try to erase from empty
	containers.
	* testsuite/util/testsuite_containergen.h (test_containers):
	Support seeding random engine.
2021-03-25 18:21:19 +00:00
GCC Administrator
bf1f3168f4 Daily bump. 2021-03-24 00:16:25 +00:00
Jonathan Wakely
d1aa5f57db libstdc++: Improve test for views::reverse
libstdc++-v3/ChangeLog:

	* testsuite/std/ranges/adaptors/reverse.cc: Replace duplicated
	line with a check that uses the const being/end overloads.
2021-03-23 18:24:39 +00:00
Moritz Sichert
09f08fef71 libstdc++: Avoid accidental ADL when calling make_reverse_iterator
std::ranges::reverse_view uses make_reverse_iterator in its
implementation as described in [range.reverse.view]. This accidentally
allows ADL as an unqualified name is used in the call. According to
[contents], however, this should be treated as a qualified lookup into
the std namespace.

This leads to errors due to ambiguous name lookups when another
make_reverse_iterator function is found via ADL.

libstdc++-v3/Changelog:

	* include/std/ranges (reverse_view::begin, reverse_view::end):
	Qualify make_reverse_iterator calls to avoid ADL.
	* testsuite/std/ranges/adaptors/reverse.cc: Test that
	views::reverse works when make_reverse_iterator is defined
	in an associated namespace.
2021-03-23 16:34:42 +00:00
Jonathan Wakely
baef0cffb5 libstdc++: Disable "ALT128" long double support for Clang
Clang does not currently support the __ibm128 type [1] and only supports
the __ieee128 type in the unreleased 12.0.0 version [2]. That means it
is not possible to provide support for -mabi=ieeelongdouble with Clang
in an ABI compatible way (as we do for GCC by defining new facets and
other types in the __gnu_cxx_ldbl128 namespace).

By preventing the definition of _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT when
compiling with Clang, all uses of __ibm128 and __ieee128 types will be
disabled. This can be revisited in future when Clang supports the types
(and provides a way to detect that support using the preprocessor).

[1] https://reviews.llvm.org/D93377
[2] https://reviews.llvm.org/D97846

libstdc++-v3/ChangeLog:

	* include/bits/c++config (_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT):
	Do not define when compiling with Clang.
2021-03-23 15:00:43 +00:00
GCC Administrator
8b744f46a2 Daily bump. 2021-03-23 00:16:25 +00:00
Jonathan Wakely
7c1006135d libstdc++: Implement string_view range constructor for C++20
This implements the new string_view constructor proposed by P1989R2.
This hasn't been voted into the C++23 draft yet, but it's been reviewed
by LWG and is expected to be approved at the next WG21 meeting.

libstdc++-v3/ChangeLog:

	* include/std/string_view (basic_string_view(Range&&)): Define new
	constructor and deduction guide.
	* testsuite/21_strings/basic_string_view/cons/char/range_c++20.cc: New test.
	* testsuite/21_strings/basic_string_view/cons/wchar_t/range_c++20.cc: New test.
2021-03-22 22:56:04 +00:00
Jonathan Wakely
00b46c00c8 libstdc++: Add noexcept to std::begin etc as per LWG 2280 and 3537
This implements the proposed changes for LWG 3537 (which we're allowed
to do as an extension whatever the outcome of the issue). I noticed we
didn't implement LWG 2280 completely, as the std::begin and std::end
overloads for arrays were not noexcept.

libstdc++-v3/ChangeLog:

	* include/bits/range_access.h (begin(T (&)[N]), end(T (&)[N])):
	Add missing 'noexcept' as per LWG 2280.
	(rbegin(T (&)[N]), rend(T (&)[N]), rbegin(initializer_list<T>))
	(rend(initializer_list<T>)): Add 'noexcept' as per LWG 3537.
	* testsuite/24_iterators/range_access/range_access.cc: Check for
	expected noexcept specifiers. Check result types of generic
	std::begin and std::end overloads.
	* testsuite/24_iterators/range_access/range_access_cpp14.cc:
	Check for expected noexcept specifiers.
	* testsuite/24_iterators/range_access/range_access_cpp17.cc:
	Likewise.
2021-03-22 15:56:49 +00:00
GCC Administrator
5f256a70a0 Daily bump. 2021-03-20 00:16:24 +00:00
Jonathan Wakely
b8ecdc7727 libstdc++: Add std::is_scoped_enum for C++23
Implement this C++23 feature, as proposed by P1048R1.

This implementation assumes that a C++23 compiler supports concepts
already. I don't see any point in using preprocessor hacks to detect
compilers which define __cplusplus to a post-C++20 value but don't
support concepts yet.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_scoped_enum): Define.
	* include/std/version (__cpp_lib_is_scoped_enum): Define.
	* testsuite/20_util/is_scoped_enum/value.cc: New test.
	* testsuite/20_util/is_scoped_enum/version.cc: New test.
2021-03-19 20:10:56 +00:00
GCC Administrator
bc2127767a Daily bump. 2021-03-17 00:16:25 +00:00
Jonathan Wakely
995a740cb0 libstdc++: Remove symbols for new std::call_once implementation [PR 99341]
This removes the new symbols added for the new futex-based
std::call_once implementation. These symbols were new on trunk, so not
in any released version. However, they are already present in some
beta distro releases (Fedora Linux 34) and in Fedora Linux rawhide. This
change can be locally reverted by distros that need to keep the symbols
present until affected packages have been rebuilt.

libstdc++-v3/ChangeLog:

	PR libstdc++/99341
	* config/abi/post/aarch64-linux-gnu/baseline_symbols.txt: Remove
	std::once_flag symbols.
	* config/abi/post/ia64-linux-gnu/baseline_symbols.txt: Likewise.
	* config/abi/post/m68k-linux-gnu/baseline_symbols.txt: Likewise.
	* config/abi/post/riscv64-linux-gnu/baseline_symbols.txt:
	Likewise.
	* config/abi/pre/gnu.ver: Likewise.
	* src/c++11/mutex.cc [_GLIBCXX_HAVE_LINUX_FUTEX]
	(struct __once_flag_compat): Remove.
	(_ZNSt9once_flag11_M_activateEv): Remove.
	(_ZNSt9once_flag9_M_finishEb): Remove.
2021-03-16 12:25:28 +00:00
Jonathan Wakely
6ee24638ed libstdc++: Revert to old std::call_once implementation [PR 99341]
The new std::call_once implementation is not backwards compatible,
contrary to my intention. Because std::once_flag::_M_active() doesn't
write glibc's "fork generation" into the pthread_once_t object, it's
possible for glibc and libstdc++ to run two active executions
concurrently. This violates the primary invariant of the feature!

This patch reverts std::once_flag and std::call_once to the old
implementation that uses pthread_once. This means PR 66146 is a problem
again, but glibc has been changed to solve that. A new API similar to
pthread_once but supporting failure and resetting the pthread_once_t
will be proposed for inclusion in glibc and other C libraries.

This change doesn't simply revert r11-4691 because I want to retain the
new implementation for non-ghtreads targets (which didn't previously
support std::call_once at all, so there's no backwards compatibility
concern). This also leaves the new std::call_once::_M_activate() and
std::call_once::_M_finish(bool) symbols present in libstdc++.so.6 so
that code already compiled against GCC 11 can still use them. Those
symbols will be removed in a subsequent commit (which distros can choose
to temporarily revert if needed).

libstdc++-v3/ChangeLog:

	PR libstdc++/99341
	* include/std/mutex [_GLIBCXX_HAVE_LINUX_FUTEX] (once_flag):
	Revert to pthread_once_t implementation.
	[_GLIBCXX_HAVE_LINUX_FUTEX] (call_once): Likewise.
	* src/c++11/mutex.cc [_GLIBCXX_HAVE_LINUX_FUTEX]
	(struct __once_flag_compat): New type matching the reverted
	implementation of once_flag using futexes.
	(once_flag::_M_activate): Remove, replace with ...
	(_ZNSt9once_flag11_M_activateEv): ... alias symbol.
	(once_flag::_M_finish): Remove, replace with ...
	(_ZNSt9once_flag9_M_finishEb): ... alias symbol.
	* testsuite/30_threads/call_once/66146.cc: Removed.
2021-03-16 12:25:28 +00:00
GCC Administrator
3c5b6d24e6 Daily bump. 2021-03-16 10:55:35 +00:00
Caroline Tice
c2be82058f libstdc++-v3: Update VTV vars for libtool link commands [PR99172]
This fixes PR 99172

Currently when GCC is configured with --enable-vtable-verify, the
libstdc++-v3 Makefiles add "-fvtable-verify=std
-Wl,-u_vtable_map_vars_start,-u_vtable_map_vars_end" to libtool link
commands. The "-fvtable-verify=std" piece causes alternate versions of
libtool (such as slibtool) to fail, unable to find "-lvtv" (GNU
libtool just removes that piece).

This patch updates the libstdc++-v3 Makefiles to not pass
"-fvtable-verify=std" to the libtool link commands.
2021-03-15 09:22:45 -07:00
Iain Sandoe
6f4b0ff2b1 libstdc++, testsuite, Darwin : Adjust for names used in system headers.
For all current Darwin SDKs inttypes.h has:
extern intmax_t imaxabs(intmax_t j);

So we need to exclude j from the defined test symbols.

libstdc++-v3/ChangeLog:

	* testsuite/17_intro/names.cc: Exclude j from the list
	of test symbols for Darwin.
2021-03-15 15:42:39 +00:00
Iain Sandoe
f8aa819b4a libstdc++, Darwin, ppc : Add new long double symbols.
We need to add the symbols for to_chars and from_chars for the
long double cases.

libstdc++-v3/ChangeLog:

	* config/os/bsd/darwin/ppc-extra.ver: Add matching for
	to_chars and from_chars for long double.
2021-03-15 15:34:11 +00:00
Patrick Palka
dce586ff83 libstdc++: Implement missing operator overloads in max_size_type.h
This implements operator++, operator-- and operator<=> for the
integer-class types defined in max_size_type.h, which I overlooked
when originally implementing the class.

libstdc++-v3/ChangeLog:

	* include/bits/max_size_type.h (__max_size_type::operator _Tp):
	Fix formatting.
	(__max_size_type::operator++): Define.
	(__max_size_type::operator--): Likewise.
	(__max_size_type::operator<=>): Conditionally define (in place
	of the other comparison operators).
	(__max_diff_type::operator _Tp): Fix formatting.
	(__max_diff_type::operator++): Define.
	(__max_diff_type::operator--): Likewise.
	(__max_diff_type::operator<=>): Conditionally define (in place
	of the other comparison operators).
	* testsuite/std/ranges/iota/max_size_type.cc (test01): Test
	these operator overloads.
2021-03-15 10:31:45 -04:00
GCC Administrator
48ff383f0d Daily bump. 2021-03-12 00:16:29 +00:00
Patrick Palka
c4f8e568aa libstdc++: Add a fallback 128-bit integer class type and use it
This implements a minimal integer class type that emulates 128-bit
unsigned arithmetic using a pair of 64-bit integers, which the
floating-point std::to_chars implementation then uses as a drop-in
replacement for unsigned __int128 on targets that lack the latter.
After this patch, we now fully support formatting of large long double
types on such targets.

Since Ryu performs 128-bit division/modulus only by 2, 5 and 10, this
integer class type supports only these divisors rather than general
division/modulus.

libstdc++-v3/ChangeLog:

	* src/c++17/floating_to_chars.cc: Simplify the file as if
	__SIZEOF_INT128__ is always defined.
	[!defined __SIZEOF_INT128__]: Include "uint128_t.h".  Define
	a base-10 to_chars overload for the uint128_t class type.
	* src/c++17/uint128_t.h: New file.
	* testsuite/20_util/to_chars/long_double.cc: No longer expect an
	execution FAIL on targets that have a large long double type
	but lack __int128.
2021-03-11 17:02:27 -05:00
Patrick Palka
349adff208 libstdc++: Remove Ryu's uint128_t aliases
This makes Ryu consistently use the uint128_t alias that's defined in
floating_to_chars.cc.

libstdc++-v3/ChangeLog:

	* src/c++17/ryu/LOCAL_PATCHES: Update.
	* src/c++17/ryu/d2s_intrinsics.h: Don't define uint128_t.
	* src/c++17/ryu/generic_128.h: Likewise.
	* src/c++17/ryu/ryu_generic_128.h (struct floating_decimal_128):
	Use uint128_t instead of __uint128_t.
	(generic_binary_to_decimal): Likewise.
2021-03-11 16:59:15 -05:00
Patrick Palka
60097beb32 libstdc++: Add a LOCAL_PATCHES file to Ryu source directory
This file keeps track of the local modifications we've made to our
copy of Ryu.

libstdc++-v3/ChangeLog:

	* src/c++17/ryu/LOCAL_PATCHES: New file.
2021-03-11 16:58:28 -05:00
Patrick Palka
a38fa1b31f libstdc++: Factor out uses of __int128 into a type alias
Since Ryu has the alias uint128_t for this same purpose, it seems best
for us to use this name as well, so as to minimize the amount of local
modifications we'd need to make to our copy of Ryu.  (In a subsequent
patch, we're going to remove Ryu's aliases so that it uses this one
defined in floating_to_chars.cc.)

libstdc++-v3/ChangeLog:

	* src/c++17/floating_to_chars.cc (uint128_t): New conditionally
	defined alias of unsigned __int128.
	(floating_type_traits_binary128::mantissa_t): Use uint128_t
	instead of unsigned __int128.
	(floating_type_traits<long double>::mantissa_t)
	[LONG_DOUBLE_KIND == LDK_IBM128]: Likewise.
	(get_ieee_repr): Likewise.  Make casts from uint_t to mantissa_t
	and uint32_t explicit.  Simplify the extraction of mantissa,
	exponent and sign bit.
2021-03-11 16:57:49 -05:00
Jonathan Wakely
5643f6f396 libstdc++: Make barrier::arrival_token a move-only class type
The standard only specifies that barrier::arrival_token is a move
constructible and move assignable type. We originally used a scoped enum
type, but that means we do not diagnose non-portable code that makes
copies of arrival tokens (or compares them for equality, or uses them as
keys in map!) This wraps the enum in a move-only class type, so that
users are forced to pass it correctly.

The move constructor and move assignment operator of the new class do
not zero out the moved-from token, as that would add additional
instructions. That means that passing a moved-from token will work with
our implementation, despite being a bug in the user code. We could
consider doing that zeroing out in debug mode.

libstdc++-v3/ChangeLog:

	* include/std/barrier (barrier::arrival_token): New move-only
	class that encapsulates the underlying token value.
2021-03-11 17:52:57 +00:00
Jonathan Wakely
9dacc828bf libstdc++: Fix find_type helper to work consistently
The find_type helper function sometimes results in "class X::name" and
lookup for that fails. For more details see "Problem 1" in
https://gcc.gnu.org/pipermail/libstdc++/2021-March/052132.html and the
example at https://sourceware.org/bugzilla/show_bug.cgi?id=27510#c2

This patch replaces typ.unqualified() with typ.tag, which is never
qualified, and will never include the 'class' or 'struct' keywords.
Using the .tag attribute should be safe here because we know we are
looking at a class type and we've already used strip_typedefs().

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (find_type): Use tag attribute
	instead of unqualified() method.
2021-03-11 17:52:56 +00:00
Jonathan Wakely
15825b17cf libstdc++: Use acq_rel memory ordering [PR 99537]
As Lewis Baker wrote in the PR:

> The 'fetch_sub()' operation in _M_release_ownership() should be using
> memory_order::acq_rel instead of memory_order::release. The use of
> 'release' only is insufficient as it does not synchronise with any
> corresponding 'acquire' operation.

> With the current implementation, it's possible that a prior write to
> one of the _M_value or _M_head data-members by a thread releasing the
> second-to-last reference might not be visible to another thread that
> releases the last reference and frees the memory, resulting in
> potential write to freed memory.

This simply changes the memory order to acq_rel as suggested.

libstdc++-v3/ChangeLog:

	PR libstdc++/99537
	* include/std/stop_token (_Stop_state_t::_M_release_ownership):
	Use acq_rel memory ordering.
2021-03-11 17:52:56 +00:00
Jonathan Wakely
8cfb387388 libstdc++: Handle EPERM for filesystem access errors on MacOS [PR 99537]
Contrary to what POSIX says, some directory operations on MacOS can fail
with EPERM instead of EACCES, so we need to handle both.

libstdc++-v3/ChangeLog:

	PR libstdc++/99537
	* src/c++17/fs_dir.cc (recursive_directory_iterator): Use new
	helper function to check for permission denied errors.
	* src/filesystem/dir.cc (recursive_directory_iterator):
	Likewise.
	* src/filesystem/dir-common.h (is_permission_denied_error): New
	helper function.
2021-03-11 17:52:56 +00:00
Jonathan Wakely
67e3976606 libstdc++: Initialize std::normal_distribution::_M_saved [PR 99536]
This avoids a false positive -Wmaybe-uninitialized warning, by
initializing _M_saved on construction.

libstdc++-v3/ChangeLog:

	PR libstdc++/99536
	* include/bits/random.h (normal_distribution): Use
	default-initializer for _M_saved and _M_saved_available.
2021-03-11 17:52:55 +00:00
GCC Administrator
e980085206 Daily bump. 2021-03-11 00:16:37 +00:00
John David Anglin
71dc5ae574 Add options to link with libatomic in various tests.
libstdc++-v3/ChangeLog:

	* testsuite/29_atomics/atomic/wait_notify/bool.cc: Add options to
	link with libatomic.
	* testsuite/29_atomics/atomic/wait_notify/generic.cc: Likewise.
	* testsuite/29_atomics/atomic/wait_notify/pointers.cc: Likewise.
	* testsuite/29_atomics/atomic_flag/wait_notify/1.cc: Likewise.
	* testsuite/30_threads/barrier/arrive.cc: Likewise.
	* testsuite/30_threads/barrier/arrive_and_drop.cc: Likewise.
	* testsuite/30_threads/barrier/arrive_and_wait.cc: Likewise.
	* testsuite/30_threads/barrier/completion.cc: Likewise.
	* testsuite/30_threads/latch/3.cc: Likewise.
	* testsuite/30_threads/semaphore/try_acquire.cc: Likewise.
	* testsuite/30_threads/semaphore/try_acquire_for.cc: Likewise.
	* testsuite/30_threads/semaphore/try_acquire_until.cc: Likewise.
2021-03-10 16:01:12 +00:00
Jonathan Wakely
47cca0288d libstdc++: Fix headers that can't be used as header units [PR 99413]
This adds missing includes to internal library headers which get
included from more than one other header, so that they can be compiled
as a stand-alone header unit.

For existing use cases these includes are no-ops because they're already
done by the header that includes these files. For compiling them as a
header unit, this ensures that they include what they use.

libstdc++-v3/ChangeLog:

	PR libstdc++/99413
	* include/bits/align.h: Include debug/assertions.h.
	* include/bits/codecvt.h: Include bits/c++config.h.
	* include/bits/enable_special_members.h: Likewise.
	* include/bits/erase_if.h: Likewise.
	* include/bits/functional_hash.h: Include <type_traits>.
	* include/bits/invoke.h: Include bits/move.h.
	* include/bits/ostream_insert.h: Include bits/exception_defines.h.
	* include/bits/parse_numbers.h: Include <type_traits>.
	* include/bits/predefined_ops.h: Include bits/c++config.h.
	* include/bits/range_access.h: Include bits/stl_iterator.h.
	* include/bits/stl_bvector.h: Do not include bits/stl_vector.h.
	* include/bits/stl_iterator.h: Include bits/stl_iterator_base_types.h.
	* include/bits/stl_uninitialized.h: Include bits/stl_algobase.h.
	* include/bits/uniform_int_dist.h: Include bits/concept_check.h.
	* include/bits/unique_lock.h: Include bits/std_mutex.h.
	* include/debug/assertions.h: Include bits/c++config.h.
2021-03-10 15:27:41 +00:00
Jonathan Wakely
dddd011113 libstdc++: Implement LWG 3530 for concept-constrained comparisons
The proposed resolution for this library issue simplifies the
constraints for compare_three_way, ranges::equal_to, ranges::less etc.
so that they do not work with types which are convertible to pointers
but which fail to meet the usual syntactic requirements for the
comparisons.

This affects the example in PR libstdc++/93628 but doesn't fix the
problem described in that report.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_cmp.h (__eq_builtin_ptr_cmp): Remove.
	(ranges::equal_to, ranges::not_equal_to): Do not constrain
	with __eq_builtin_ptr_cmp.
	(ranges::less, ranges::greater, ranges::less_equal)
	(ranges::greater_equal): Do not constrain with
	__less_builtin_ptr_cmp.
	* libsupc++/compare (compare_three_way): Do not constrain with
	__3way_builtin_ptr_cmp.
	* testsuite/18_support/comparisons/object/builtin-ptr-three-way.cc: Moved to...
	* testsuite/18_support/comparisons/object/lwg3530.cc: ...here.
	* testsuite/20_util/function_objects/range.cmp/lwg3530.cc: New test.
2021-03-10 15:27:06 +00:00
Jonathan Wakely
e7afb82c35 libstdc++: Uncomment more parts of <chrono> synopsis test
libstdc++-v3/ChangeLog:

	* testsuite/std/time/syn_c++20.cc: Enable synopsis checks for
	C++20 calendar types.
2021-03-10 11:14:27 +00:00
GCC Administrator
0ad6a2e2f0 Daily bump. 2021-03-07 00:16:24 +00:00
Jakub Jelinek
84185598dc libstdc++: Improve std::rot[lr] [PR99396]
As can be seen on:

unsigned char f1 (unsigned char x, int y) { return std::rotl (x, y); }
unsigned char f2 (unsigned char x, int y) { return std::rotr (x, y); }
unsigned short f3 (unsigned short x, int y) { return std::rotl (x, y); }
unsigned short f4 (unsigned short x, int y) { return std::rotr (x, y); }
unsigned int f5 (unsigned int x, int y) { return std::rotl (x, y); }
unsigned int f6 (unsigned int x, int y) { return std::rotr (x, y); }
unsigned long int f7 (unsigned long int x, int y) { return std::rotl (x, y); }
unsigned long int f8 (unsigned long int x, int y) { return std::rotr (x, y); }
unsigned long long int f9 (unsigned long long int x, int y) { return std::rotl (x, y); }
unsigned long long int f10 (unsigned long long int x, int y) { return std::rotr (x, y); }
//unsigned __int128 f11 (unsigned __int128 x, int y) { return std::rotl (x, y); }
//unsigned __int128 f12 (unsigned __int128 x, int y) { return std::rotr (x, y); }

constexpr auto a = std::rotl (1234U, 0);
constexpr auto b = std::rotl (1234U, 5);
constexpr auto c = std::rotl (1234U, -5);
constexpr auto d = std::rotl (1234U, -__INT_MAX__ - 1);
the current <bit> definitions of std::__rot[lr] aren't pattern recognized
as rotates, they are too long/complex for that, starting with signed modulo,
special case for 0 and different cases for positive and negative.

For types with power of two bits the following patch adds definitions that
the compiler can pattern recognize and turn e.g. on x86_64 into ro[lr][bwlq]
instructions.  For weirdo types like unsigned __int20 etc. it keeps the
current definitions.

2021-03-06  Jakub Jelinek  <jakub@redhat.com>

	PR libstdc++/99396
	* include/std/bit (__rotl, __rotr): Add optimized variants for power of
	two _Nd which the compiler can pattern match the rotates.
2021-03-06 11:11:30 +01:00
GCC Administrator
67f10d28f0 Daily bump. 2021-03-05 00:16:21 +00:00
Jonathan Wakely
905ce0ca30 libstdc++: Fix buffer overflows in tests [PR 99382]
This seems to be a typo/thinko in the definition of the arrays used as
storage.

libstdc++-v3/ChangeLog:

	PR libstdc++/99382
	* testsuite/20_util/specialized_algorithms/uninitialized_default_n/sizes.cc:
	Make storage larger than required. Verify no write to the last
	element.
	* testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/sizes.cc:
	Likewise.
2021-03-04 10:31:27 +00:00
GCC Administrator
f3641ac70e Daily bump. 2021-03-04 00:16:48 +00:00
Rainer Orth
5bc3a2bc8a libstdc++: Update Solaris baselines for GCC 11.1
The following patch updates the Solaris baselines for GCC 11.1.  There's
only one caveat: comparing the Solaris 11.3 and 11.4 baselines, I find

+FUNC:_ZSt10from_charsPKcS0_RdSt12chars_format@@GLIBCXX_3.4.29
+FUNC:_ZSt10from_charsPKcS0_ReSt12chars_format@@GLIBCXX_3.4.29
+FUNC:_ZSt10from_charsPKcS0_RfSt12chars_format@@GLIBCXX_3.4.29

i.e.

std::from_chars(char const*, char const*, double&, std::chars_format)

and similarly for long double, float.  Those are from from
src/c++17/floating_from_chars.cc and only defined if
_GLIBCXX_HAVE_USELOCALE, i.e. depend on the XPG7 addition.  Given that
only Solaris 11.4 supports XPG7, I've taken the 11.3 baselines to avoid
having separate ones for 11.3 and 11.4.

Tested on i386-pc-solaris2.11 and sparc-sun-solaris2.11 (sparc and x86,
32 and 64-bit, 11.3 and 11.4).


2021-02-10  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	libstdc++-v3:
	* config/abi/post/i386-solaris/baseline_symbols.txt: Regenerate.
	* config/abi/post/i386-solaris/amd64/baseline_symbols.txt:
	Likewise.
	* config/abi/post/sparc-solaris/baseline_symbols.txt: Likewise.
	* config/abi/post/sparc-solaris/sparcv9/baseline_symbols.txt:
	Likewise.
2021-03-03 14:25:51 +01:00
Rainer Orth
a726723737 libstdc++: Don't use reserved identifiers in simd headers
Two simd tests FAIL on Solaris, both SPARC and x86:

FAIL: experimental/simd/standard_abi_usable.cc -msse2 -O2 -Wno-psabi (test for excess errors)
FAIL: experimental/simd/standard_abi_usable_2.cc -msse2 -O2 -Wno-psabi (test for excess errors)

This happens because the simd headers use identifiers documented in the
libstdc++ manual as reserved by system headers.

Fixed as follows, tested on i386-pc-solaris2.11, sparc-sun-solaris2.11,
and x86_64-pc-linux-gnu.


2021-02-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	libstdc++-v3:
	* include/experimental/bits/simd.h: Replace reserved _X, _B by
	_Xp, _Bp.
	* include/experimental/bits/simd_builtin.h: Likewise.
	* include/experimental/bits/simd_x86.h: Likewise.
2021-03-03 13:16:35 +01:00
GCC Administrator
ec9dc4fa08 Daily bump. 2021-02-28 00:16:18 +00:00