aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/experimental
AgeCommit message (Collapse)AuthorFilesLines
2024-09-27libstdc++: Refactor experimental::filesystem::path string conversionsJonathan Wakely1-84/+53
I noticed a -Wc++17-extensions warning due to use of if-constexpr in std::experimental::filesystem::path, which was not protected by diagnostic pragmas to disable the warning. While adding the pragmas I noticed that other places in the same file use tag dispatching and multiple overloads instead of if-constexpr. Since we're already using it in that file, we might as well just use it everywhere. libstdc++-v3/ChangeLog: * include/experimental/bits/fs_path.h (path::_Cvt): Refactor to use if-constexpr. (path::string(const Allocator&)): Likewise.
2024-09-25libstdc++: #ifdef out #pragma GCC system_headerJason Merrill40-0/+80
In r15-3714-gd3a7302ec5985a I added -Wsystem-headers to the libstdc++ build flags to help catch problems in the library. This patch takes a different approach, of disabling the #pragma system_header unless _GLIBCXX_SYSHDR is defined. As a result, the testsuites will treat them as non-system-headers to get better warning coverage during regression testing of both gcc and libstdc++, not just when building the library. My rationale for the #ifdef instead of just removing the #pragma is the three G++ tests that want to test libstdc++ system header behavior, so we need a way to select it. This doesn't affect installed libraries, as they get their system-header status from the lookup path. But testsuite_flags --build-includes gives -I directives rather than -isystem. This patch doesn't change the headers in config/ because I'm not compiling with most of them, so won't see any warnings that need fixing. Adjusting them could happen later, or we can not bother. libstdc++-v3/ChangeLog: * acinclude.m4 (WARN_FLAGS): Remove -Wsystem-headers. * configure: Regenerate. * include/bits/algorithmfwd.h: #ifdef out #pragma GCC system_header. * include/bits/atomic_base.h * include/bits/atomic_futex.h * include/bits/atomic_timed_wait.h * include/bits/atomic_wait.h * include/bits/basic_ios.h * include/bits/basic_string.h * include/bits/boost_concept_check.h * include/bits/char_traits.h * include/bits/charconv.h * include/bits/chrono.h * include/bits/chrono_io.h * include/bits/codecvt.h * include/bits/concept_check.h * include/bits/cpp_type_traits.h * include/bits/elements_of.h * include/bits/enable_special_members.h * include/bits/erase_if.h * include/bits/forward_list.h * include/bits/functional_hash.h * include/bits/gslice.h * include/bits/gslice_array.h * include/bits/hashtable.h * include/bits/indirect_array.h * include/bits/invoke.h * include/bits/ios_base.h * include/bits/iterator_concepts.h * include/bits/locale_classes.h * include/bits/locale_facets.h * include/bits/locale_facets_nonio.h * include/bits/localefwd.h * include/bits/mask_array.h * include/bits/max_size_type.h * include/bits/memory_resource.h * include/bits/memoryfwd.h * include/bits/move_only_function.h * include/bits/node_handle.h * include/bits/ostream_insert.h * include/bits/out_ptr.h * include/bits/parse_numbers.h * include/bits/postypes.h * include/bits/quoted_string.h * include/bits/range_access.h * include/bits/ranges_base.h * include/bits/refwrap.h * include/bits/sat_arith.h * include/bits/semaphore_base.h * include/bits/slice_array.h * include/bits/std_abs.h * include/bits/std_function.h * include/bits/std_mutex.h * include/bits/std_thread.h * include/bits/stl_iterator_base_funcs.h * include/bits/stl_iterator_base_types.h * include/bits/stl_tree.h * include/bits/stream_iterator.h * include/bits/streambuf_iterator.h * include/bits/stringfwd.h * include/bits/this_thread_sleep.h * include/bits/unique_lock.h * include/bits/uses_allocator_args.h * include/bits/utility.h * include/bits/valarray_after.h * include/bits/valarray_array.h * include/bits/valarray_before.h * include/bits/version.h * include/c_compatibility/fenv.h * include/c_compatibility/inttypes.h * include/c_compatibility/stdint.h * include/decimal/decimal.h * include/experimental/bits/net.h * include/experimental/bits/shared_ptr.h * include/ext/aligned_buffer.h * include/ext/alloc_traits.h * include/ext/atomicity.h * include/ext/concurrence.h * include/ext/numeric_traits.h * include/ext/pod_char_traits.h * include/ext/pointer.h * include/ext/stdio_filebuf.h * include/ext/stdio_sync_filebuf.h * include/ext/string_conversions.h * include/ext/type_traits.h * include/ext/vstring.h * include/ext/vstring_fwd.h * include/ext/vstring_util.h * include/parallel/algorithmfwd.h * include/parallel/numericfwd.h * include/tr1/functional_hash.h * include/tr1/hashtable.h * include/tr1/random.h * libsupc++/exception.h * libsupc++/hash_bytes.h * include/bits/basic_ios.tcc * include/bits/basic_string.tcc * include/bits/fstream.tcc * include/bits/istream.tcc * include/bits/locale_classes.tcc * include/bits/locale_facets.tcc * include/bits/locale_facets_nonio.tcc * include/bits/ostream.tcc * include/bits/sstream.tcc * include/bits/streambuf.tcc * include/bits/string_view.tcc * include/bits/version.tpl * include/experimental/bits/string_view.tcc * include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp * include/ext/random.tcc * include/ext/vstring.tcc * include/tr2/bool_set.tcc * include/tr2/dynamic_bitset.tcc * include/bits/c++config * include/c/cassert * include/c/cctype * include/c/cerrno * include/c/cfloat * include/c/ciso646 * include/c/climits * include/c/clocale * include/c/cmath * include/c/csetjmp * include/c/csignal * include/c/cstdarg * include/c/cstddef * include/c/cstdio * include/c/cstdlib * include/c/cstring * include/c/ctime * include/c/cuchar * include/c/cwchar * include/c/cwctype * include/c_global/cassert * include/c_global/ccomplex * include/c_global/cctype * include/c_global/cerrno * include/c_global/cfenv * include/c_global/cfloat * include/c_global/cinttypes * include/c_global/ciso646 * include/c_global/climits * include/c_global/clocale * include/c_global/cmath * include/c_global/csetjmp * include/c_global/csignal * include/c_global/cstdalign * include/c_global/cstdarg * include/c_global/cstdbool * include/c_global/cstddef * include/c_global/cstdint * include/c_global/cstdio * include/c_global/cstdlib * include/c_global/cstring * include/c_global/ctgmath * include/c_global/ctime * include/c_global/cuchar * include/c_global/cwchar * include/c_global/cwctype * include/c_std/cassert * include/c_std/cctype * include/c_std/cerrno * include/c_std/cfloat * include/c_std/ciso646 * include/c_std/climits * include/c_std/clocale * include/c_std/cmath * include/c_std/csetjmp * include/c_std/csignal * include/c_std/cstdarg * include/c_std/cstddef * include/c_std/cstdio * include/c_std/cstdlib * include/c_std/cstring * include/c_std/ctime * include/c_std/cuchar * include/c_std/cwchar * include/c_std/cwctype * include/debug/array * include/debug/bitset * include/debug/deque * include/debug/forward_list * include/debug/list * include/debug/map * include/debug/set * include/debug/string * include/debug/unordered_map * include/debug/unordered_set * include/debug/vector * include/decimal/decimal * include/experimental/algorithm * include/experimental/any * include/experimental/array * include/experimental/buffer * include/experimental/chrono * include/experimental/contract * include/experimental/deque * include/experimental/executor * include/experimental/filesystem * include/experimental/forward_list * include/experimental/functional * include/experimental/internet * include/experimental/io_context * include/experimental/iterator * include/experimental/list * include/experimental/map * include/experimental/memory * include/experimental/memory_resource * include/experimental/net * include/experimental/netfwd * include/experimental/numeric * include/experimental/propagate_const * include/experimental/ratio * include/experimental/regex * include/experimental/scope * include/experimental/set * include/experimental/socket * include/experimental/string * include/experimental/string_view * include/experimental/synchronized_value * include/experimental/system_error * include/experimental/timer * include/experimental/tuple * include/experimental/type_traits * include/experimental/unordered_map * include/experimental/unordered_set * include/experimental/vector * include/ext/algorithm * include/ext/cmath * include/ext/functional * include/ext/iterator * include/ext/memory * include/ext/numeric * include/ext/random * include/ext/rb_tree * include/ext/rope * include/parallel/algorithm * include/std/algorithm * include/std/any * include/std/array * include/std/atomic * include/std/barrier * include/std/bit * include/std/bitset * include/std/charconv * include/std/chrono * include/std/codecvt * include/std/complex * include/std/concepts * include/std/condition_variable * include/std/coroutine * include/std/deque * include/std/execution * include/std/expected * include/std/filesystem * include/std/format * include/std/forward_list * include/std/fstream * include/std/functional * include/std/future * include/std/generator * include/std/iomanip * include/std/ios * include/std/iosfwd * include/std/iostream * include/std/istream * include/std/iterator * include/std/latch * include/std/limits * include/std/list * include/std/locale * include/std/map * include/std/memory * include/std/memory_resource * include/std/mutex * include/std/numbers * include/std/numeric * include/std/optional * include/std/ostream * include/std/print * include/std/queue * include/std/random * include/std/ranges * include/std/ratio * include/std/regex * include/std/scoped_allocator * include/std/semaphore * include/std/set * include/std/shared_mutex * include/std/span * include/std/spanstream * include/std/sstream * include/std/stack * include/std/stacktrace * include/std/stdexcept * include/std/streambuf * include/std/string * include/std/string_view * include/std/syncstream * include/std/system_error * include/std/text_encoding * include/std/thread * include/std/tuple * include/std/type_traits * include/std/typeindex * include/std/unordered_map * include/std/unordered_set * include/std/utility * include/std/valarray * include/std/variant * include/std/vector * include/std/version * include/tr1/array * include/tr1/cfenv * include/tr1/cinttypes * include/tr1/cmath * include/tr1/complex * include/tr1/cstdbool * include/tr1/cstdint * include/tr1/cstdio * include/tr1/cstdlib * include/tr1/cwchar * include/tr1/cwctype * include/tr1/functional * include/tr1/memory * include/tr1/random * include/tr1/regex * include/tr1/tuple * include/tr1/type_traits * include/tr1/unordered_map * include/tr1/unordered_set * include/tr1/utility * include/tr2/bool_set * include/tr2/dynamic_bitset * include/tr2/type_traits * libsupc++/atomic_lockfree_defines.h * libsupc++/compare * libsupc++/cxxabi.h * libsupc++/cxxabi_forced.h * libsupc++/cxxabi_init_exception.h * libsupc++/exception * libsupc++/initializer_list * libsupc++/new * libsupc++/typeinfo: Likewise. * testsuite/20_util/ratio/operations/ops_overflow_neg.cc * testsuite/23_containers/array/tuple_interface/get_neg.cc * testsuite/23_containers/vector/cons/destructible_debug_neg.cc * testsuite/24_iterators/operations/prev_neg.cc * testsuite/ext/type_traits/add_unsigned_floating_neg.cc * testsuite/ext/type_traits/add_unsigned_integer_neg.cc * testsuite/ext/type_traits/remove_unsigned_floating_neg.cc * testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Adjust line numbers. gcc/testsuite/ChangeLog * g++.dg/analyzer/fanalyzer-show-events-in-system-headers-default.C * g++.dg/analyzer/fanalyzer-show-events-in-system-headers-no.C * g++.dg/diagnostic/disable.C: #define _GLIBCXX_SYSHDR.
2024-09-03libstdc++: Simplify std::any to fix -Wdeprecated-declarations warningJonathan Wakely1-1/+1
We don't need to use std::aligned_storage in std::any. We just need a POD type of the right size. The void* union member already ensures the alignment will be correct. Avoiding std::aligned_storage means we don't need to suppress a -Wdeprecated-declarations warning. libstdc++-v3/ChangeLog: * include/experimental/any (experimental::any::_Storage): Use array of unsigned char instead of deprecated std::aligned_storage. * include/std/any (any::_Storage): Likewise. * testsuite/20_util/any/layout.cc: New test.
2024-08-28libstdc++: Fix -Wunused-parameter warnings in Networking TS headersJonathan Wakely2-2/+2
libstdc++-v3/ChangeLog: * include/experimental/io_context: Remove name of unused parameter. * include/experimental/socket: Add [[maybe_unused]] attribute.
2024-07-17c++: diagnose failed qualified lookup into current instPatrick Palka1-1/+1
When the scope of a qualified name is the current instantiation, and qualified lookup finds nothing at template definition time, then we know it'll find nothing at instantiation time (unless the current instantiation has dependent bases). So such qualified name lookup failure can be diagnosed ahead of time as per [temp.res.general]/6. This patch implements that, for qualified names of the form (where the current instantiation is A<T>): this->non_existent a.non_existent A::non_existent typename A::non_existent It turns out we already optimistically attempt qualified lookup of seemingly every qualified name, even when it's dependently scoped, and then suppress issuing a lookup failure diagnostic after the fact. So implementing this is mostly a matter of restricting the diagnostic suppression to "dependentish" scopes (i.e. dependent scopes or the current instantiation with dependent bases), rather than suppressing for any dependently-typed scope as we currently do. The cp_parser_conversion_function_id change is needed to avoid regressing lookup/using8.C: using A<T>::operator typename A<T>::Nested*; When looking up A<T>::Nested we consider it not dependently scoped since we entered A<T> from cp_parser_conversion_function_id earlier. But this A<T> is the implicit instantiation A<T> not the primary template type A<T>, and so the lookup fails which we now diagnose. This patch works around this by not entering the template scope of a qualified conversion function-id in this case, i.e. if we're in an expression vs declaration context, by seeing if the type already went through finish_template_type with entering_scope=true. gcc/cp/ChangeLog: * decl.cc (make_typename_type): Restrict name lookup failure punting to dependentish_scope_p instead of dependent_type_p. * error.cc (qualified_name_lookup_error): Improve diagnostic when the scope is the current instantiation. * parser.cc (cp_parser_diagnose_invalid_type_name): Likewise. (cp_parser_conversion_function_id): Don't call push_scope on a template scope unless we're in a declaration context. (cp_parser_lookup_name): Restrict name lookup failure punting to dependentish_scope_p instead of depedent_type_p. * semantics.cc (finish_id_expression_1): Likewise. * typeck.cc (finish_class_member_access_expr): Likewise. libstdc++-v3/ChangeLog: * include/experimental/socket (basic_socket_iostream::basic_socket_iostream): Fix typo. * include/tr2/dynamic_bitset (__dynamic_bitset_base::_M_is_proper_subset_of): Likewise. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/alignas18.C: Expect name lookup error for U::X. * g++.dg/cpp0x/forw_enum13.C: Expect name lookup error for D3::A and D4<T>::A. * g++.dg/parse/access13.C: Declare A::E::V to avoid name lookup failure and preserve intent of the test. * g++.dg/parse/enum11.C: Expect extra errors, matching the non-template case. * g++.dg/template/crash123.C: Avoid name lookup failure to preserve intent of the test. * g++.dg/template/crash124.C: Likewise. * g++.dg/template/crash7.C: Adjust expected diagnostics. * g++.dg/template/dtor6.C: Declare A::~A() to avoid name lookup failure and preserve intent of the test. * g++.dg/template/error22.C: Adjust expected diagnostics. * g++.dg/template/static30.C: Avoid name lookup failure to preserve intent of the test. * g++.old-deja/g++.other/decl5.C: Adjust expected diagnostics. * g++.dg/template/non-dependent34.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-06-20libstdc++: Fix find_last_set(simd_mask) to ignore padding bitsMatthias Kretz1-13/+13
With the change to the AVX512 find_last_set implementation, the change to AVX512 operator!= is unnecessary. However, the latter was not producing optimal code and unnecessarily set the padding bits. In theory, the compiler could determine that with the new != implementation, the bit operation for clearing the padding bits is a no-op and can be elided. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/115454 * include/experimental/bits/simd_x86.h (_S_not_equal_to): Use neq comparison instead of bitwise negation after eq. (_S_find_last_set): Clear unused high bits before computing bit_width. * testsuite/experimental/simd/pr115454_find_last_set.cc: New test.
2024-06-05[libstdc++] add _GLIBCXX_CLANG to workaround predefined __clang__Alexandre Oliva5-18/+18
A proprietary embedded operating system that uses clang as its primary compiler ships headers that require __clang__ to be defined. Defining that macro causes libstdc++ to adopt workarounds that work for clang but that break for GCC. So, introduce a _GLIBCXX_CLANG macro, and a convention to test for it rather than for __clang__, so that a GCC variant that adds -D__clang__ to satisfy system headers can also -D_GLIBCXX_CLANG=0 to avoid workarounds that are not meant for GCC. I've left fast_float and ryu files alone, their tests for __clang__ don't seem to be harmful for GCC, they don't include bits/c++config, and patching such third-party files would just make trouble for updating them without visible benefit. pstl_config.h, though also imported, required adjustment. for libstdc++-v3/ChangeLog * include/bits/c++config (_GLIBCXX_CLANG): Define or undefine. * include/bits/locale_facets_nonio.tcc: Test for it. * include/bits/stl_bvector.h: Likewise. * include/c_compatibility/stdatomic.h: Likewise. * include/experimental/bits/simd.h: Likewise. * include/experimental/bits/simd_builtin.h: Likewise. * include/experimental/bits/simd_detail.h: Likewise. * include/experimental/bits/simd_x86.h: Likewise. * include/experimental/simd: Likewise. * include/std/complex: Likewise. * include/std/ranges: Likewise. * include/std/variant: Likewise. * include/pstl/pstl_config.h: Likewise.
2024-06-04libstdc++: Fix simd<char> conversion for -fno-signed-char for ClangMatthias Kretz1-18/+27
The special case for Clang in the trait producing a signed integer type lead to the trait returning 'char' where it should have been 'signed char'. This workaround was introduced because on Clang the return type of vector compares was not convertible to '_SimdWrapper< __int_for_sizeof_t<...' unless '__int_for_sizeof_t<char>' was an alias for 'char'. In order to not rewrite the complete mask type code (there is code scattered around the implementation assuming signed integers), this needs to be 'signed char'; so the special case for Clang needs to be removed. The conversion issue is now solved in _SimdWrapper, which now additionally allows conversion from vector types with compatible integral type. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/115308 * include/experimental/bits/simd.h (__int_for_sizeof): Remove special cases for __clang__. (_SimdWrapper): Change constructor overload set to allow conversion from vector types with integral conversions via bit reinterpretation.
2024-05-29libstdc++: Avoid MMX return types from __builtin_shufflevectorMatthias Kretz1-11/+28
This resolves a regression on i686 that was introduced with r15-429-gfb1649f8b4ad50. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/115247 * include/experimental/bits/simd.h (__as_vector): Don't use vector_size(8) on __i386__. (__vec_shuffle): Never return MMX vectors, widen to 16 bytes instead. (concat): Fix padding calculation to pick up widening logic from __as_vector.
2024-05-13libstdc++: Use __builtin_shufflevector for simd split and concatMatthias Kretz3-192/+125
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/114958 * include/experimental/bits/simd.h (__as_vector): Return scalar simd as one-element vector. Return vector from single-vector fixed_size simd. (__vec_shuffle): New. (__extract_part): Adjust return type signature. (split): Use __extract_part for any split into non-fixed_size simds. (concat): If the return type stores a single vector, use __vec_shuffle (which calls __builtin_shufflevector) to produce the return value. * include/experimental/bits/simd_builtin.h (__shift_elements_right): Removed. (__extract_part): Return single elements directly. Use __vec_shuffle (which calls __builtin_shufflevector) to for all non-trivial cases. * include/experimental/bits/simd_fixed_size.h (__extract_part): Return single elements directly. * testsuite/experimental/simd/pr114958.cc: New test.
2024-04-22libstdc++: Fix conversion of simd to vector builtinMatthias Kretz1-1/+1
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/114803 * include/experimental/bits/simd_builtin.h (_SimdBase2::operator __vector_type_t): There is no __builtin() function in _SimdWrapper, instead use its conversion operator. * testsuite/experimental/simd/pr114803_vecbuiltin_cvt.cc: New test.
2024-04-22libstdc++: Silence irrelevant warnings in <experimental/simd>Matthias Kretz2-3/+8
Avoid -Wnarrowing in C code; -Wtautological-compare in unconditional static_assert (necessary for faking a dependency on a template parameter) Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/simd.h: Ignore -Wnarrowing for arm_neon.h. (__int_for_sizeof): Replace tautological compare with checking for invalid template parameter value. * include/experimental/bits/simd_builtin.h (__extract_part): Remove tautological compare by combining two static_assert.
2024-04-17libstdc++: Add include guard to simd-internal headerMatthias Kretz1-0/+4
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/numeric_traits.h: Add include guard.
2024-04-17libstdc++: Avoid ill-formed types on ARMMatthias Kretz1-2/+2
This resolves failing tests in check-simd. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/114750 * include/experimental/bits/simd_builtin.h (_SimdImplBuiltin::_S_load, _S_store): Fall back to copying scalars if the memory type cannot be vectorized for the target.
2024-03-27libstdc++: Add masked ++/-- implementation for sizeof < 16Matthias Kretz1-10/+14
This resolves further failures (-Wreturn-type warnings) and test failures for where-* tests targeting AVX-512. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/simd_x86.h (_S_masked_unary): Cast inputs < 16 bytes to 16 byte vectors before calling the right subtraction builtin. Before returning, truncate to the return vector type.
2024-03-27libstdc++: Fix call signature of builtins from masked ++/--Matthias Kretz1-3/+9
This resolves failures in the "expensive" where-* test of check-simd when targeting AVX-512. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/simd_x86.h (_S_masked_unary): Call the 4- and 8-byte variants of __builtin_ia32_subp[ds] without rounding direction argument.
2024-03-27libstdc++: add ARM SVE support to std::experimental::simdSrinivas Yadav Singanaboina7-104/+2150
libstdc++-v3/ChangeLog: * include/Makefile.am: Add simd_sve.h. * include/Makefile.in: Add simd_sve.h. * include/experimental/bits/simd.h: Add new SveAbi. * include/experimental/bits/simd_builtin.h: Use __no_sve_deduce_t to support existing Neon Abi. * include/experimental/bits/simd_converter.h: Convert sequentially when sve is available. * include/experimental/bits/simd_detail.h: Define sve specific macro. * include/experimental/bits/simd_math.h: Fallback frexp to execute sequntially when sve is available, to handle fixed_size_simd return type that always uses sve. * include/experimental/simd: Include bits/simd_sve.h. * testsuite/experimental/simd/tests/bits/main.h: Enable testing for sve128, sve256, sve512. * include/experimental/bits/simd_sve.h: New file. Signed-off-by: Srinivas Yadav Singanaboina <vasu.srinivasvasu.14@gmail.com>
2024-02-28libstdc++: Fix noexcept on dtors in <experimental/scope> [PR114152]Jonathan Wakely1-3/+3
The PR points out that the destructors all have incorrect noexcept-specifiers. libstdc++-v3/ChangeLog: PR libstdc++/114152 * include/experimental/scope (scope_exit scope_fail): Make destructor unconditionally noexcept. (scope_sucess): Fix noexcept-specifier. * testsuite/experimental/scopeguard/114152.cc: New test.
2024-02-28libstdc++: Consistently use noexcept, constexpr, nodiscard on bitmask opsJonathan Wakely1-0/+12
The bitwise operators for combining bitmask types such as std::launch are not consistently annotated with noexcept, constexpr, and nodiscard. This is the subject of LWG 3977, although the proposed resolution doesn't work. We can make the changes in libstdc++ anyway though. libstdc++-v3/ChangeLog: * include/bits/atomic_base.h (operator|, operator&): Add noexcept. * include/bits/fs_fwd.h (operator&, operator|, operator^) (operator~): Add nodiscard to overloads for copy_options, perms, perm_options, and directory_options. * include/bits/ios_base.h (operator&, operator|, operator^) (operator~): Add nodiscard and noexcept to overloads for _Ios_Fmtflags, _Ios_Openmode, and _Ios_Iostate. (operator|=, operator&=, operator^=): Add constexpr for C++14. * include/bits/regex_constants.h (operator&, operator|, operator^) (operator~): Add nodiscard and noexcept to overloads for syntax_option_type and match_flag_type. (operator|=, operator&=, operator^=): Add noexcept. * include/std/charconv (operator&, operator|, operator^) (operator~): Add nodiscard to overloads for chars_format. * include/std/future (operator&, operator|, operator^) (operator~): Add nodiscard for overloads for launch. (operator&=, operator|=, operator^=): Add constexpr for C++14. * include/experimental/bits/fs_fwd.h (operator&, operator|) (operator^, operator~): Add nodiscard to overloads for copy_options, perms, and directory_options. * testsuite/27_io/ios_base/types/fmtflags/bitmask_operators.cc: Add dg-warning for nodiscard warnings. * testsuite/27_io/ios_base/types/iostate/bitmask_operators.cc: Likewise. * testsuite/27_io/ios_base/types/openmode/bitmask_operators.cc: Likewise. * testsuite/27_io/filesystem/operations/bitmask_types.cc: New test.
2024-02-02libstdc++: Implement some missing functions for net::ip::network_v6Jonathan Wakely1-4/+22
libstdc++-v3/ChangeLog: * include/experimental/internet (network_v6::network): Define. (network_v6::hosts): Finish implementing. (network_v6::to_string): Do not concatenate std::string to arbitrary std::basic_string specialization. * testsuite/experimental/net/internet/network/v6/cons.cc: New test.
2024-02-01libstdc++: Fix -Wdeprecated warning about implicit capture of 'this'Jonathan Wakely1-14/+6
In C++20 it's deprecated for a [=] lambda capture to capture the 'this' pointer. Using resize_and_overwrite with a lambda seems like overkill to write three chars to the string anyway. Just resize the string and overwrite the end of it directly. libstdc++-v3/ChangeLog: * include/experimental/internet (network_v4::to_string()): Remove lambda and use of resize_and_overwrite.
2024-01-03Update copyright years.Jakub Jelinek60-60/+60
2023-09-14libstdc++: Remove some more unconditional uses of atomicsJonathan Wakely2-1/+15
These atomics cause linker errors on arm4t where __sync_synchronize is not defined. For single-threaded targets we don't need the atomics. libstdc++-v3/ChangeLog: * include/experimental/io_context (io_context) [!_GLIBCXX_HAS_GTHREADS]: Use a plain integer for _M_work_count for single-threaded targets. * include/experimental/memory_resource (__get_default_resource) [!_GLIBCXX_HAS_GTHREADS]: Use unsynchronized type for single-threaded targets. * src/c++17/default_resource.h: Adjust preprocessor conditions to match memory_resource.cc. * src/c++17/memory_resource.cc [!_GLIBCXX_HAS_GTHREADS] (atomic_mem_res): Use unsynchronized type for single-threaded targets.
2023-08-17libstdc++: Fix -Wunused-parameter in <experimental/internet>Jonathan Wakely1-1/+1
libstdc++-v3/ChangeLog: * include/experimental/internet (address_v4::to_string): Remove unused parameter name.
2023-08-09libstdc++: Fix constexpr functions to conform to older standardsJonathan Wakely1-1/+1
Some constexpr functions were inadvertently relying on relaxed constexpr rules from later standards. libstdc++-v3/ChangeLog: * include/bits/chrono.h (duration_cast): Do not use braces around statements for C++11 constexpr rules. * include/bits/stl_algobase.h (__lg): Rewrite as a single statement for C++11 constexpr rules. * include/experimental/bits/fs_path.h (path::string): Use _GLIBCXX17_CONSTEXPR not _GLIBCXX_CONSTEXPR for 'if constexpr'. * include/std/charconv (__to_chars_8): Initialize variable for C++17 constexpr rules.
2023-06-09libstdc++: Add preprocessor checks to <experimental/internet> [PR100285]Jonathan Wakely1-0/+2
We can't define endpoints and resolvers without the relevant OS support. If IPPROTO_TCP and IPPROTO_UDP are both udnefined then we won't need basic_endpoint and basic_resovler anyway, so make them depend on those macros. libstdc++-v3/ChangeLog: PR libstdc++/100285 * include/experimental/internet [IPPROTO_TCP || IPPROTO_UDP] (basic_endpoint, basic_resolver_entry, resolver_base) (basic_resolver_results, basic_resolver): Only define if the tcp or udp protocols will be defined.
2023-06-06libstdc++: Avoid vector casts while still avoiding PR90424Matthias Kretz1-25/+15
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/109822 * include/experimental/bits/simd_builtin.h (_S_store): Rewrite to avoid casts to other vector types. Implement store as succession of power-of-2 sized memcpy to avoid PR90424.
2023-06-06libstdc++: Replace use of incorrect non-temporal storeMatthias Kretz2-37/+7
The call to the base implementation sometimes didn't find a matching signature because the _Abi parameter of _SimdImpl* was "wrong" after conversion. It has to call into <new ABI tag>::_SimdImpl instead of the current ABI tag's _SimdImpl. This also reduces the number of possible template instantiations. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/110054 * include/experimental/bits/simd_builtin.h (_S_masked_store): Call into deduced ABI's SimdImpl after conversion. * include/experimental/bits/simd_x86.h (_S_masked_store_nocvt): Don't use _mm_maskmoveu_si128. Use the generic fall-back implementation. Also fix masked stores without SSE2, which were not doing anything before.
2023-06-06libstdc++: Protect against macrosMatthias Kretz1-4/+4
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/simd.h (__bit_cast): Use __gnu__::__vector_size__ instead of gnu::vector_size.
2023-06-01libstdc++: Fix condition for supported SIMD types on ARMv8Matthias Kretz1-2/+4
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/110050 * include/experimental/bits/simd.h (__vectorized_sizeof): With __have_neon_a32 only single-precision float works (in addition to integers).
2023-06-01libstdc++: Reduce <functional> inclusion to <stl_algobase.h>François Dumont1-4/+1
Move the std::search definition from stl_algo.h to stl_algobase.h and use the later in <functional>. For consistency also move std::__parallel::search and associated helpers from <parallel/stl_algo.h> to <parallel/stl_algobase.h> so that std::__parallel::search is accessible along with std::search. libstdc++-v3/ChangeLog: * include/bits/stl_algo.h (std::__search, std::search(_FwdIt1, _FwdIt1, _FwdIt2, _FwdIt2, _BinPred)): Move... * include/bits/stl_algobase.h: ...here. * include/std/functional: Replace <stl_algo.h> include by <stl_algobase.h>. * include/parallel/algo.h (std::__parallel::search<_FIt1, _FIt2, _BinaryPred>) (std::__parallel::__search_switch<_FIt1, _FIt2, _BinaryPred, _ItTag1, _ItTag2>): Move... * include/parallel/algobase.h: ...here. * include/experimental/functional: Remove <bits/stl_algo.h> and <parallel/algorithm> includes. Include <bits/stl_algobase.h>.
2023-05-30libstdc++: Correct NTTP and simd_mask ctor callMatthias Kretz1-3/+4
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/109822 * include/experimental/bits/simd.h (to_native): Use int NTTP as specified in PTS2. (to_compatible): Likewise. Add missing tag to call mask generator ctor. * testsuite/experimental/simd/pr109822_cast_functions.cc: New test.
2023-05-26libstdc++: Resolve -Wsign-compare issueMatthias Kretz1-1/+1
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/simd_ppc.h (_S_bit_shift_left): Negative __y is UB, so prefer signed compare.
2023-05-24libstdc++: Fix type of first argument to vec_cntm callMatthias Kretz2-6/+36
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/109949 * include/experimental/bits/simd.h (__intrinsic_type): If __ALTIVEC__ is defined, map gnu::vector_size types to their corresponding __vector T types without losing unsignedness of integer types. Also prefer long long over long. * include/experimental/bits/simd_ppc.h (_S_popcount): Cast mask object to the expected unsigned vector type.
2023-05-24libstdc++: Fix SFINAE for __is_intrinsic_type on ARMMatthias Kretz1-3/+9
On ARM NEON doesn't support double, so __is_intrinsic_type_v<double, whatever> should say false (instead of being ill-formed). Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/109261 * include/experimental/bits/simd.h (__intrinsic_type): Specialize __intrinsic_type<double, 8> and __intrinsic_type<double, 16> in any case, but provide the member type only with __aarch64__.
2023-05-24libstdc++: Add missing constexpr to simd_neonMatthias Kretz1-40/+36
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/109261 * include/experimental/bits/simd_neon.h (_S_reduce): Add constexpr and make NEON implementation conditional on not __builtin_is_constant_evaluated.
2023-05-23libstdc++: Add missing constexpr to simdMatthias Kretz5-250/+326
The constexpr API is only available with -std=gnu++XX (and proposed for C++26). The proposal is to have the complete simd API usable in constant expressions. This patch resolves several issues with using simd in constant expressions. Issues why constant_evaluated branches are necessary: * subscripting vector builtins is not allowed in constant expressions * if the implementation needs/uses memcpy * if the implementation would otherwise call SIMD intrinsics/builtins Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/109261 * include/experimental/bits/simd.h (_SimdWrapper::_M_set): Avoid vector builtin subscripting in constant expressions. (resizing_simd_cast): Avoid memcpy if constant_evaluated. (const_where_expression, where_expression, where) (__extract_part, simd_mask, _SimdIntOperators, simd): Add either _GLIBCXX_SIMD_CONSTEXPR (on public APIs), or constexpr (on internal APIs). * include/experimental/bits/simd_builtin.h (__vector_permute) (__vector_shuffle, __extract_part, _GnuTraits::_SimdCastType1) (_GnuTraits::_SimdCastType2, _SimdImplBuiltin) (_MaskImplBuiltin::_S_store): Add constexpr. (_CommonImplBuiltin::_S_store_bool_array) (_SimdImplBuiltin::_S_load, _SimdImplBuiltin::_S_store) (_SimdImplBuiltin::_S_reduce, _MaskImplBuiltin::_S_load): Add constant_evaluated case. * include/experimental/bits/simd_fixed_size.h (_S_masked_load): Reword comment. (__tuple_element_meta, __make_meta, _SimdTuple::_M_apply_r) (_SimdTuple::_M_subscript_read, _SimdTuple::_M_subscript_write) (__make_simd_tuple, __optimize_simd_tuple, __extract_part) (__autocvt_to_simd, _Fixed::__traits::_SimdBase) (_Fixed::__traits::_SimdCastType, _SimdImplFixedSize): Add constexpr. (_SimdTuple::operator[], _M_set): Add constexpr and add constant_evaluated case. (_MaskImplFixedSize::_S_load): Add constant_evaluated case. * include/experimental/bits/simd_scalar.h: Add constexpr. * include/experimental/bits/simd_x86.h (_CommonImplX86): Add constexpr and add constant_evaluated case. (_SimdImplX86::_S_equal_to, _S_not_equal_to, _S_less) (_S_less_equal): Value-initialize to satisfy constexpr evaluation. (_MaskImplX86::_S_load): Add constant_evaluated case. (_MaskImplX86::_S_store): Add constexpr and constant_evaluated case. Value-initialize local variables. (_MaskImplX86::_S_logical_and, _S_logical_or, _S_bit_not) (_S_bit_and, _S_bit_or, _S_bit_xor): Add constant_evaluated case. * testsuite/experimental/simd/pr109261_constexpr_simd.cc: New test.
2023-05-22libstdc++: Resolve -Wunused-variable warnings in stdx::simd and testsMatthias Kretz1-2/+2
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/simd_builtin.h (_S_fpclassify): Move __infn into #ifdef'ed block. * testsuite/experimental/simd/tests/fpclassify.cc: Declare constants only when used. * testsuite/experimental/simd/tests/frexp.cc: Likewise. * testsuite/experimental/simd/tests/logarithm.cc: Likewise. * testsuite/experimental/simd/tests/trunc_ceil_floor.cc: Likewise. * testsuite/experimental/simd/tests/ldexp_scalbn_scalbln_modf.cc: Move totest and expect1 into #ifdef'ed block.
2023-05-12libstdc++: Remove redundant dependencies on _GLIBCXX_USE_C99_STDINT_TR1Jonathan Wakely1-6/+0
We never need to use std::make_unsigned in std::char_traits<char16_t> and std::char_traits<char32_t> because <cstdint> guarantees to provide the types we need, since r9-2028-g8ba7f29e3dd064. Similarly, experimental::source_location can just assume uint_least32_t is defined by <cstdint>. libstdc++-v3/ChangeLog: * include/bits/char_traits.h (char_traits<char16_t>): Do not depend on _GLIBCXX_USE_C99_STDINT_TR1. (char_traits<char32_t>): Likewise. * include/experimental/source_location: Likewise.
2023-04-28libstdc++: Minor fixes to doxygen commentsJonathan Wakely1-2/+0
libstdc++-v3/ChangeLog: * include/bits/uses_allocator.h: Add missing @file comment. * include/bits/regex.tcc: Remove stray doxygen comments. * include/experimental/memory_resource: Likewise. * include/std/bit: Tweak doxygen @cond comments. * include/std/expected: Likewise. * include/std/numbers: Likewise.
2023-04-12libstdc++: Initialize all members of basic_endpoint union [PR109482]Jonathan Wakely1-4/+18
On Solaris the in_addr struct contains a union and value-initializing it does not make the s_addr member active. This means we can't access that member later during constant evaluation. Make the constructors explicitly set every member that we might want to read later in constexpr member functions. This means even the default constructor can only be constexpr for C++20, because we can't change the active member of a union in older standards. libstdc++-v3/ChangeLog: PR libstdc++/109482 * include/experimental/internet (basic_endpoint::basic_endpoint()): Ensure that the required union members are active. Only define as constexpr for C++20 and later. (basic_endpoint::basic_endpoint(const protocol_type&, port_type)): Likewise. * testsuite/experimental/net/internet/endpoint/cons.cc: Only check constexpr default constructor for C++20 and later. * testsuite/experimental/net/internet/endpoint/extensible.cc: Likewise.
2023-03-31libstdc++: Revert addition of boolean flag to net::ip::basic_endpointJonathan Wakely1-18/+14
As pointed out in P2641R1, we can use GCC's __builtin_constant_p to emulate the proposed std::is_active_member. This allows us to detect which of the union members is active during constant evaluation, so we don't need the extra bool data member. We still can't support constexpr until C++20 though, as we need to change the active member during constant evaluation. libstdc++-v3/ChangeLog: * include/experimental/internet (ip::basic_endpoint::_M_if_v6): Revert change from member function to data member. Fix for constant evaluation by detecting which union member is active. (ip::basic_endpoint::resize): Revert changes to update _M_is_v6 flag.
2023-03-30libstdc++: Fix constexpr functions in <experimental/internet>Jonathan Wakely1-28/+75
Change ip::basic_endpoint to work in constant expressions, but only for C++20 and later (due to the use of a union, which cannot change active member in constexpr evaluation until C++20). During constant evaluation we cannot inspect the common initial sequence of basic_endpoint's union members to check whether sin_family == AF_INET or AF_INET6. This means we need to store an additional boolean member that remembers whether we have a v4 or v6 address. The address type can change behind our backs if a user copies an address to the data() pointer and then calls resize(n), so we need to inspect the sa_family_t member in the union after a resize and update the boolean. POSIX only guarantees that the sa_family_t member of each protocol-specific address structure is at the same offset and of the same type, not that there is a common initial sequence. The check in resize is done using memcmp, so that we avoid accessing an inactive member of the union if the sockaddr_in and sockaddr_in6 structures do not have a common initial sequence that includes the sa_family_t member. libstdc++-v3/ChangeLog: * include/experimental/internet (ip::make_address): Implement missing overload. (ip::address_v4::broadcast()): Avoid undefined shift. (ip::basic_endpoint): Fix member functions for constexpr. (ip::basic_endpoint::_M_is_v6): Replace member function with data member, adjust member functions using it. (ip::basic_endpoint::resize): Update _M_is_v6 based on sockaddr content. * testsuite/experimental/net/internet/address/v4/cons.cc: Fix constexpr checks to work in C++14. * testsuite/experimental/net/internet/address/v4/creation.cc: Likewise. * testsuite/experimental/net/internet/endpoint/cons.cc: Likewise. * testsuite/experimental/net/internet/network/v4/cons.cc: Likewise. * testsuite/experimental/net/internet/network/v4/members.cc: Likewise. * testsuite/experimental/net/internet/endpoint/extensible.cc: New test.
2023-03-28libstdc++: Add missing trait is_simd_flag_typeMatthias Kretz1-13/+39
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/simd.h (is_simd_flag_type): New. (_IsSimdFlagType): New. (copy_from, copy_to, load ctors): Constrain _Flags using _IsSimdFlagType.
2023-03-28libstdc++: Fix operator% implementation for ClangMatthias Kretz1-0/+2
This resolves a regression of my previous fix where Clang would ICE on _S_divides. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/simd_x86.h (_SimdImplX86): Use _Base::_S_divides if the optimized _S_divides function is hidden via the preprocessor.
2023-03-21libstdc++: Use more precise __RECIPROCAL_MATH__ macroMatthias Kretz1-1/+1
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/simd_x86.h (_SimdImplX86::_S_divides): Replace test for __GCC_IEC_559 == 0 with __RECIPROCAL_MATH__.
2023-03-21libstdc++: Skip integer division optimization for ClangMatthias Kretz2-2/+4
Clang ICEs on _SimdImplX86::_S_divides. The function is only working around a missed optimization and not necessary for correctness. Therefore, don't use it for Clang. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/simd_detail.h: Don't define _GLIBCXX_SIMD_WORKAROUND_PR90993 for Clang. * include/experimental/bits/simd_x86.h (_S_divides): Remove check for __clang__.
2023-03-21libstdc++: Fix simd compilation with ClangMatthias Kretz2-5/+55
Clang fails to compile some constant expressions involving simd. Therefore, just disable this non-conforming extension for clang. Fix AVX512 blend implementation for Clang. It was converting the bitmask to bool before, which is obviously wrong. Instead use a Clang builtin to convert the bitmask to vector-mask before using a vector blend ?:. A similar change is required for the masked unary implementation, because the GCC builtins do not exist on Clang. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/simd_detail.h: Don't declare the simd API as constexpr with Clang. * include/experimental/bits/simd_x86.h (__movm): New. (_S_blend_avx512): Resolve FIXME. Implement blend using __movm and ?:. (_SimdImplX86::_S_masked_unary): Clang does not implement the same builtins. Implement the function using __movm, ?:, and - operators on vector_size types instead.
2023-02-24libstdc++: Fix formattingMatthias Kretz7-930/+942
Whitespace changes only. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/simd.h: Line breaks and indenting fixed to follow the libstdc++ standard. * include/experimental/bits/simd_builtin.h: Likewise. * include/experimental/bits/simd_fixed_size.h: Likewise. * include/experimental/bits/simd_neon.h: Likewise. * include/experimental/bits/simd_ppc.h: Likewise. * include/experimental/bits/simd_scalar.h: Likewise. * include/experimental/bits/simd_x86.h: Likewise.
2023-02-24libstdc++: Always-inline most of non-cmath fixed_size implementationMatthias Kretz1-30/+30
For simd, the inlining behavior should be similar to builtin types. (No operator on buitin types is ever translated into a function call.) Therefore, always_inline is the right choice (i.e. inline on -O0 as well). Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/108030 * include/experimental/bits/simd_fixed_size.h (_SimdImplFixedSize::_S_broadcast): Replace inline with _GLIBCXX_SIMD_INTRINSIC. (_SimdImplFixedSize::_S_generate): Likewise. (_SimdImplFixedSize::_S_load): Likewise. (_SimdImplFixedSize::_S_masked_load): Likewise. (_SimdImplFixedSize::_S_store): Likewise. (_SimdImplFixedSize::_S_masked_store): Likewise. (_SimdImplFixedSize::_S_min): Likewise. (_SimdImplFixedSize::_S_max): Likewise. (_SimdImplFixedSize::_S_complement): Likewise. (_SimdImplFixedSize::_S_unary_minus): Likewise. (_SimdImplFixedSize::_S_plus): Likewise. (_SimdImplFixedSize::_S_minus): Likewise. (_SimdImplFixedSize::_S_multiplies): Likewise. (_SimdImplFixedSize::_S_divides): Likewise. (_SimdImplFixedSize::_S_modulus): Likewise. (_SimdImplFixedSize::_S_bit_and): Likewise. (_SimdImplFixedSize::_S_bit_or): Likewise. (_SimdImplFixedSize::_S_bit_xor): Likewise. (_SimdImplFixedSize::_S_bit_shift_left): Likewise. (_SimdImplFixedSize::_S_bit_shift_right): Likewise. (_SimdImplFixedSize::_S_remquo): Add inline keyword (to be explicit about not always-inline, yet). (_SimdImplFixedSize::_S_isinf): Likewise. (_SimdImplFixedSize::_S_isfinite): Likewise. (_SimdImplFixedSize::_S_isnan): Likewise. (_SimdImplFixedSize::_S_isnormal): Likewise. (_SimdImplFixedSize::_S_signbit): Likewise.