aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
AgeCommit message (Collapse)AuthorFilesLines
2022-01-11libstdc++: Install <source_location> header for freestanding [PR103726]Jonathan Wakely3-7/+9
This C++20 header is also supposed to be present for freestanding. libstdc++-v3/ChangeLog: PR libstdc++/103726 * include/Makefile.am: Install <source_location> for freestanding. * include/Makefile.in: Regenerate. * include/std/version (__cpp_lib_source_location): Define for freestanding.
2022-01-11libstdc++: Add missing noexcept to lazy_split_view iterator (LWG 3593)Jonathan Wakely1-1/+1
This was approved at the October 2021 plenary. We already have noexcept in the other places the issue adds it in the spec. libstdc++-v3/ChangeLog: * include/std/ranges (ranges::lazy_split_view::_InnerIter::end()): Add neoxcept (LWG 3593).
2022-01-11libstdc++: Make copyable-box completely constexpr (LWG 3572)Jonathan Wakely2-2/+31
This LWG issue was approved at the October 2021 plenary and can be implemented now that std::optional is fully constexpr. libstdc++-v3/ChangeLog: * include/std/ranges (ranges::__detail::__box): Add constexpr to assignment operators (LWG 3572). * testsuite/std/ranges/adaptors/filter.cc: Check assignment of a view that uses copyable-box.
2022-01-11libstdc++: Install <coroutine> header for freestanding [PR103726]Jonathan Wakely3-18/+45
The standard says that <coroutine> should be present for freestanding. That was intentionally left out of the initial implementation, but can be done without much trouble. The header should be moved to libsupc++ at some point in stage 1. The standard also says that <coroutine> defines a std::hash specialization, which was missing from our implementation. That's a problem for freestanding (see LWG 3653) so only do that for hosted. We can use concepts to constrain the __coroutine_traits_impl base class when compiled with concepts enabled. In a pure C++20 implementation we would not need that base class at all and could just use a constrained partial specialization of coroutine_traits. But the absence of the __coroutine_traits_impl<R, void> base would create an ABI difference between the non-standard C++14/C++17 support for coroutines and the same code compiled as C++20. If we drop support for <coroutine> pre-C++20 we should revisit this. libstdc++-v3/ChangeLog: PR libstdc++/103726 * include/Makefile.am: Install <coroutine> for freestanding. * include/Makefile.in: Regenerate. * include/std/coroutine: Adjust headers and preprocessor conditions. (__coroutine_traits_impl): Use concepts when available. [_GLIBCXX_HOSTED] (hash<coroutine_handle>): Define.
2022-01-11libstdc++: Optimize std::ostream inserters for single charactersJonathan Wakely1-2/+12
On the libsdc++ mailing list Lewis Hyatt pointed out the performance overhead of using sputn in stream inserters, rather than writing directly to the streambuf's put area: https://gcc.gnu.org/pipermail/libstdc++/2021-July/052877.html As Lewis noted, the standard explicitly requires a call to sputn for inserting a std::basic_string_view or std::basic_string. But for inserting single characters or null-terminated strings it is more vague, and so we can improve performance by not using the __ostream_insert function. This is a minimal change that avoids __ostream_insert for single characters. We can use the unformatted basic_ostream::put(charT) function when we don't need the additional effects of a formatted output function (i.e. padding and resetting the width). The put function will insert into the buffer if possible, and only make a virtual call (to overflow) if the buffer is full. We could also avoid sputn when inserting null-terminated character strings, but that would require using a new function for inserting null-terminated strings, so the existing code using sputn is still used for basic_string and basic_string_view. My preference is to leave that for now, and try to improve the standard. We could either remove the requirement to call sputn, or allow sputn to write directly to the buffer instead of calling xsputn. libstdc++-v3/ChangeLog: * include/std/ostream (operator<<(basic_ostream&, charT)): Use unformatted input if no padding is needed. (operator<<(basic_ostream<char>&, char)): Likewise.
2022-01-11libstdc++: Make std::variant work with Clang in C++20 mode [PR103891]Jonathan Wakely3-5/+12
Clang has some bugs with destructors that use constraints to be conditionally trivial, so disable the P2231R1 constexpr changes to std::variant unless the compiler is GCC 12 or later. If/when P2493R0 gets accepted and implemented by G++ we can remove the __GNUC__ check and use __cpp_concepts >= 202002 instead. libstdc++-v3/ChangeLog: PR libstdc++/103891 * include/bits/c++config (_GLIBCXX_HAVE_COND_TRIVIAL_SPECIAL_MEMBERS): Define. * include/std/variant (__cpp_lib_variant): Only define C++20 value when the compiler is known to support conditionally trivial destructors. * include/std/version (__cpp_lib_variant): Likewise.
2022-01-11libstdc++: Make std::common_iterator completely constexpr-able (LWG 3574)Jonathan Wakely3-23/+34
This library issue was approved in the October 2021 plenary. libstdc++-v3/ChangeLog: * include/bits/stl_iterator.h (common_iterator): Add constexpr to all member functions (LWG 3574). * testsuite/24_iterators/common_iterator/1.cc: Evaluate some tests as constant expressions. * testsuite/24_iterators/common_iterator/2.cc: Likewise.
2022-01-11Daily bump.GCC Administrator1-0/+85
2022-01-10libstdc++: Add %j, %U, %w, %W time_get support, fix %y, %Y, %C, %p [PR77760]Jakub Jelinek12-50/+1031
glibc strptime passes around some state, what fields in struct tm have been set and what needs to be finalized through possibly recursive calls, and at the end performs various finalizations, like applying %p so that it works for both %I %p and %p %I orders, or applying century so that both %C %y and %y %C works, or computation of missing fields from others (e.g. from %Y and %j one can compute tm_mon, tm_mday and tm_wday, from %Y %U %w, %Y %W %w, %Y %U %a, or %Y %W %w one can compute tm_mon, tm_mday, tm_yday or e.g. from %Y %m %d one can compute tm_wday and tm_yday. As the finalization is quite large and doesn't need to be a template (doesn't depend on any iterators or char types), I've put it into libstdc++, and left some padding in the state struct, so that perhaps in the future we can track some more state without changing ABI. Unfortunately, there is an ugly problem that the standard mandates that get method calls the do_get virtual method and I don't see how we can cary on any state in between those calls (even if we did an ABI change for the facets, the methods are const, so that I think multiple threads could use the same time_get objects and we couldn't store state in there). There is a hack for that for GCC (seems to work with ICC too, doesn't work with clang++) if the do_get method isn't overriden we can pass the state around. For both do_get_year and per IRC discussions also for %y, the behavior is if 1-2 digits are parsed, the year is treated according to POSIX 2008 %y rules (0-68 is 2000-2068, 69-99 is 1969-1999), if 3-4 digits are parsed, it is treated as %Y. 2022-01-10 Jakub Jelinek <jakub@redhat.com> PR libstdc++/77760 * include/bits/locale_facets_nonio.h (__time_get_state): New struct. (time_get::_M_extract_via_format): Declare new method with __time_get_state& as an extra argument. * include/bits/locale_facets_nonio.tcc (_M_extract_via_format): Add __state argument, set various fields in it while parsing. Handle %j, %U, %w and %W, fix up handling of %y, %Y and %C, don't adjust tm_hour for %p immediately. Add a wrapper around the method without the __state argument for backwards compatibility. (_M_extract_num): Remove all __len == 4 special cases. (time_get::do_get_time, time_get::do_get_date, time_get::do_get): Zero initialize __state, pass it to _M_extract_via_format and finalize it at the end. (do_get_year): For 1-2 digit parsed years, map 0-68 to 2000-2068, 69-99 to 1969-1999. For 3-4 digit parsed years use that as year. (get): If do_get isn't overloaded from the locale_facets_nonio.tcc version, don't call do_get but call _M_extract_via_format instead to pass around state. * config/abi/pre/gnu.ver (GLIBCXX_3.4.30): Export _M_extract_via_format with extra __time_get_state and __time_get_state::_M_finalize_state. * src/c++98/locale_facets.cc (is_leap, day_of_the_week, day_of_the_year): New functions in anon namespace. (mon_yday): New var in anon namespace. (__time_get_state::_M_finalize_state): Define. * testsuite/22_locale/time_get/get/char/4.cc: New test. * testsuite/22_locale/time_get/get/wchar_t/4.cc: New test. * testsuite/22_locale/time_get/get_year/char/1.cc (test01): Parse 197 as year 197AD instead of error. * testsuite/22_locale/time_get/get_year/char/5.cc (test01): Parse 1 as year 2001 instead of error. * testsuite/22_locale/time_get/get_year/char/6.cc: New test. * testsuite/22_locale/time_get/get_year/wchar_t/1.cc (test01): Parse 197 as year 197AD instead of error. * testsuite/22_locale/time_get/get_year/wchar_t/5.cc (test01): Parse 1 as year 2001 instead of error. * testsuite/22_locale/time_get/get_year/wchar_t/6.cc: New test.
2022-01-10libstdc++: Fix and simplify freestanding configuration [PR103866]Jonathan Wakely17-14/+56
This fixes the --disable-hosted-libstdcxx build so that it works with --without-headers. Currently you need to also use --with-newlib, which is confusing for users who aren't actually using newlib. The AM_PROG_LIBTOOL checks are currently skipped for --with-newlib and --with-avrlibc builds, with this change they are also skipped when using --without-headers. It would be nice if using --disable-hosted-libstdcxx automatically skipped those checks, but GLIBCXX_ENABLE_HOSTED comes too late to make the AM_PROG_LIBTOOL checks depend on $is_hosted. The checks for EOF, SEEK_CUR etc. cause the build to fail if there is no <stdio.h> available. Unlike most headers, which get a HAVE_FOO_H macro, <stdio.h> is in autoconf's default includes, so every check tries to include it unconditionally. This change skips those checks for freestanding builds. Similarly, the checks for <stdint.h> types done by GCC_HEADER_STDINT try to include <stdio.h> and fail for --without-headers builds. This change skips the use of GCC_HEADER_STDINT for freestanding. We can probably stop using GCC_HEADER_STDINT entirely, since only one file uses the gstdint.h header that is generated, and that could easily be changed to use <stdint.h> instead. That can wait for stage 1. We also need to skip the GLIBCXX_CROSSCONFIG stage if --without-headers was used, since we don't have any of the functions it deals with. The end result of the changes above is that it should not be necessary for a --disable-hosted-libstdcxx --without-headers build to also use --with-newlib. Finally, compile libsupc++ with -ffreestanding when --without-headers is used, so that <stdint.h> will use <gcc-stdint.h> instead of expecting it to come from libc. libstdc++-v3/ChangeLog: PR libstdc++/103866 * acinclude.m4 (GLIBCXX_COMPUTE_STDIO_INTEGER_CONSTANTS): Do nothing for freestanding builds. (GLIBCXX_ENABLE_HOSTED): Define FREESTANDING_FLAGS. * configure.ac: Do not use AC_LIBTOOL_DLOPEN when configured with --without-headers. Do not use GCC_HEADER_STDINT for freestanding builds. * libsupc++/Makefile.am (HOSTED_CXXFLAGS): Use -ffreestanding for freestanding builds. * configure: Regenerate. * Makefile.in: Regenerate. * doc/Makefile.in: Regenerate. * include/Makefile.in: Regenerate. * libsupc++/Makefile.in: Regenerate. * po/Makefile.in: Regenerate. * python/Makefile.in: Regenerate. * src/Makefile.in: Regenerate. * src/c++11/Makefile.in: Regenerate. * src/c++17/Makefile.in: Regenerate. * src/c++20/Makefile.in: Regenerate. * src/c++98/Makefile.in: Regenerate. * src/filesystem/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate.
2022-01-10libstdc++: Add dg-timeout-factor to some more regex testsJonathan Wakely4-0/+4
I'm seeing these fail with tool_timeout=30 on a busy machine. libstdc++-v3/ChangeLog: * testsuite/28_regex/algorithms/regex_replace/char/103664.cc: Add dg-timeout-factor directive. * testsuite/28_regex/basic_regex/84110.cc: Likewise. * testsuite/28_regex/basic_regex/ctors/char/other.cc: Likewise. * testsuite/28_regex/match_results/102667.cc: Likewise.
2022-01-10libstdc++: Update default -std option in manualJonathan Wakely3-4/+6
libstdc++-v3/ChangeLog: * doc/xml/manual/using.xml: Update documentation around default -std option. * doc/html/*: Regenerate.
2022-01-10libstdc++: Add -nostdinc++ for c++17 sources [PR100017]Jonathan Wakely2-2/+2
When building a build!=host compiler, the just-built gcc can't be used to build the target libstdc++ (because it is built for the host triplet, not the build triplet). The top-level configure.ac sets up the build flags for libstdc++ (and other "raw_cxx" libs) like this: GCC_TARGET_TOOL(c++ for libstdc++, RAW_CXX_FOR_TARGET, CXX, [gcc/xgcc -shared-libgcc -B$$r/$(HOST_SUBDIR)/gcc -nostdinc++ -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/libsupc++/.libs], c++) The -nostdinc++ flag is only used for the IN-TREE-TOOL, i.e. when using the just-built gcc/xgcc compiler. This means that the cross-compiler used to build libstdc++ will add its own libstdc++ headers to the include path. That results in the #include <cfenv> in src/c++17/floating_to_chars.cc and src/c++17/floating_from_chars.cc doing #include_next <fenv.h> and finding the libstdc++ fenv.h wrapper from the host compiler. Because that has the same include guard as the <fenv.h> in the libstdc++ we're trying to build, we never reach the underlying <fenv.h> from libc. That results in several errors of the form: error: 'fenv_t' has not been declared in '::' The most correct fix would be to add -nostdinc++ to the RAW_CXX_FOR_TARGET variable in configure.ac, or the RAW_CXX_TARGET_EXPORTS variable in Makefile.tpl. Another solution would be to make the libstdc++ <fenv.h> wrapper use _GLIBCXX_INCLUDE_NEXT_C_HEADERS like our <stdlib.h> and other C header wrappers. For now though, the simplest and safest solution is to just add -nostdinc++ to the CXXFLAGS used for src/c++17/*.cc, which is what this does. libstdc++-v3/ChangeLog: PR libstdc++/100017 * src/c++17/Makefile.am (AM_CXXFLAGS): Add -nostdinc++. * src/c++17/Makefile.in: Regenerate.
2022-01-10Daily bump.GCC Administrator1-0/+5
2022-01-08Testsuite: Make dependence on -fdelete-null-pointer-checks explicitSandra Loosemore1-0/+1
nios2-elf target defaults to -fno-delete-null-pointer-checks, breaking tests that implicitly depend on that optimization. Add the option explicitly on these tests. 2022-01-08 Sandra Loosemore <sandra@codesourcery.com> gcc/testsuite/ * g++.dg/cpp0x/constexpr-compare1.C: Add explicit -fdelete-null-pointer-checks option. * g++.dg/cpp0x/constexpr-compare2.C: Likewise. * g++.dg/cpp0x/constexpr-typeid2.C: Likewise. * g++.dg/cpp1y/constexpr-94716.C: Likewise. * g++.dg/cpp1z/constexpr-compare1.C: Likewise. * g++.dg/cpp1z/constexpr-if36.C: Likewise. * gcc.dg/init-compare-1.c: Likewise. libstdc++-v3/ * testsuite/18_support/type_info/constexpr.cc: Add explicit -fdelete-null-pointer-checks option.
2022-01-07Daily bump.GCC Administrator1-0/+26
2022-01-06libstdc++: Add self-merge check to std::forward_list::merge [PR103853]Pavel I. Kryukov2-0/+53
This implements the proposed resolution of LWG 3088, so that x.merge(x) is a no-op, consistent with std::list::merge. Signed-off-by: Pavel I. Kryukov <pavel.kryukov@phystech.edu> Co-authored-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/103853 * include/bits/forward_list.tcc (forward_list::merge): Check for self-merge. * testsuite/23_containers/forward_list/operations/merge.cc: New test.
2022-01-06libstdc++: Adjust friend declarations to work with ClangJonathan Wakely1-2/+2
I think this code is valid but it fails with Clang, possibly due to https://llvm.org/PR38882 Qualifying the names makes it work for all compilers. libstdc++-v3/ChangeLog: * include/bits/regex.h (basic_regex, match_results): Qualify name in friend declaration, to work around Clang bug.
2022-01-06libstdc++: Increase timeout for pthread7-rope.cc testJonathan Wakely1-1/+2
This test spawns thousands of threads and so times out if the tests are run with a low timeout value and the machine is busy. libstdc++-v3/ChangeLog: * testsuite/ext/rope/pthread7-rope.cc: Add dg-timeout-factor.
2022-01-06libstdc++: Do not use std::isdigit in <charconv> [PR103911]Jonathan Wakely1-6/+5
This avoids a potential race condition if std::setlocale is used concurrently with std::from_chars. libstdc++-v3/ChangeLog: PR libstdc++/103911 * include/std/charconv (__from_chars_alpha_to_num): Return char instead of unsigned char. Change invalid return value to 127 instead of using numeric trait. (__from_chars_alnum): Fix comment. Do not use std::isdigit. Change type of variable to char.
2022-01-06Daily bump.GCC Administrator1-0/+139
2022-01-05libstdc++: Optimize operations on small size hashtable [PR 68303]François Dumont5-35/+333
When hasher is identified as slow and the number of elements is limited in the container use a brute-force loop on those elements to look for a given key using the key_equal functor. For the moment the default threshold to consider the container as small is 20. libstdc++-v3/ChangeLog: PR libstdc++/68303 * include/bits/hashtable_policy.h (_Hashtable_hash_traits<_Hash>): New. (_Hash_code_base<>::_M_hash_code(const _Hash_node_value<>&)): New. (_Hashtable_base<>::_M_key_equals): New. (_Hashtable_base<>::_M_equals): Use latter. (_Hashtable_base<>::_M_key_equals_tr): New. (_Hashtable_base<>::_M_equals_tr): Use latter. * include/bits/hashtable.h (_Hashtable<>::__small_size_threshold()): New, use _Hashtable_hash_traits. (_Hashtable<>::find): Loop through elements to look for key if size is lower than __small_size_threshold(). (_Hashtable<>::_M_emplace(true_type, _Args&&...)): Likewise. (_Hashtable<>::_M_insert_unique(_Kt&&, _Args&&, const _NodeGenerator&)): Likewise. (_Hashtable<>::_M_compute_hash_code(const_iterator, const key_type&)): New. (_Hashtable<>::_M_emplace(const_iterator, false_type, _Args&&...)): Use latter. (_Hashtable<>::_M_find_before_node(const key_type&)): New. (_Hashtable<>::_M_erase(true_type, const key_type&)): Use latter. (_Hashtable<>::_M_erase(false_type, const key_type&)): Likewise. * src/c++11/hashtable_c++0x.cc: Include <bits/functional_hash.h>. * testsuite/util/testsuite_performance.h (report_performance): Use 9 width to display memory. * testsuite/performance/23_containers/insert_erase/unordered_small_size.cc: New performance test case.
2022-01-05libstdc++: Fix overconstrained std::string constructor [PR103919]Jonathan Wakely3-2/+47
The C++17 basic_string(const T&, size_t, size_t) constructor is overconstrained, so it can't be used for a NTBS and a temporary string gets constructed (potentially allocating memory). There is no corresponding constructor taking an NTBS, so no need to disambiguate from it. Accepting an NTBS avoids the temporary (and potential allocation) and is what the standard requires. libstdc++-v3/ChangeLog: PR libstdc++/103919 * include/bits/basic_string.h (basic_string(const T&, size_t, size_t)): Relax constraints on string_view parameter. * include/bits/cow_string.h (basic_string(const T&, size_t, size_t)): Likewise. * testsuite/21_strings/basic_string/cons/char/103919.cc: New test.
2022-01-05libstdc++: Implement P1328 "Making std::type_info::operator== constexpr"Jonathan Wakely6-34/+131
This feature is present in the C++23 draft. With Jakub's recent front-end changes we can implement constexpr equality by comparing the addresses of std::type_info objects. We do not need string comparisons, because for constant evaluation cases we know we aren't dealing with std::type_info objects defined in other translation units. The ARM EABI requires that the type_info::operator== function can be defined out-of-line (and suggests that should be the default), but to be a constexpr function it must be defined inline (at least for C++23 mode). To meet these conflicting requirements we make the inline version of operator== call a new __equal function when called at runtime. That is an alias for the non-inline definition of operator== defined in libsupc++. libstdc++-v3/ChangeLog: * config/abi/pre/gnu.ver (GLIBCXX_3.4.30): Export new symbol for ARM EABI. * include/bits/c++config (_GLIBCXX23_CONSTEXPR): Define. * include/std/version (__cpp_lib_constexpr_typeinfo): Define. * libsupc++/tinfo.cc: Add #error to ensure non-inline definition is emitted. (type_info::__equal): Define alias symbol. * libsupc++/typeinfo (type_info::before): Combine different implementations into one. (type_info::operator==): Likewise. Use address equality for constant evaluation. Call __equal for targets that require the definition to be non-inline. * testsuite/18_support/type_info/constexpr.cc: New test.
2022-01-05libstdc++: Improvements to standard error category objects (part deux)Jonathan Wakely2-20/+31
In r12-3860 the error categories in <system_error> were made final and immortal, but I missed the categories for <future> and <ios>. This makes the same changes to those. libstdc++-v3/ChangeLog: * src/c++11/cxx11-ios_failure.cc (io_error_category): Define class and virtual functions as 'final'. (io_category_instance): Use constinit union to make the object immortal. * src/c++11/future.cc (future_error_category): Define class and virtual functions as 'final'. (future_category_instance): Use constinit union.
2022-01-05libstdc++: Fix std::error_code pretty printer for versioned namespaceJonathan Wakely1-1/+1
libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (StdErrorCodePrinter): Strip versioned namespace from the type name that is printed.
2022-01-05libstdc++: Add pretty printer for std::regex internalsJonathan Wakely1-0/+32
This helps visualize the NFA states in a std::regex. It probably isn't very useful for users, but helps when working on the implementation. libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (StdRegexStatePrinter): New printer for std::regex NFA states.
2022-01-05libstdc++: Fix comments in std::forward_list testsJonathan Wakely7-13/+13
libstdc++-v3/ChangeLog: * testsuite/23_containers/forward_list/operations/1.cc: Fill in placeholders in comments. * testsuite/23_containers/forward_list/operations/2.cc: Likewise. * testsuite/23_containers/forward_list/operations/3.cc: Likewise. * testsuite/23_containers/forward_list/operations/4.cc: Likewise. * testsuite/23_containers/forward_list/operations/5.cc: Likewise. * testsuite/23_containers/forward_list/operations/6.cc: Likewise. * testsuite/23_containers/forward_list/operations/7.cc: Likewise.
2022-01-05libstdc++: Avoid -Wzero-as-null-pointer-constant warning [PR103848]Jonathan Wakely1-3/+4
libstdc++-v3/ChangeLog: PR libstdc++/103848 * include/bits/stl_deque.h (operator-): Do not use 0 as null pointer constant.
2022-01-05libstdc++: Simplify std::allocator_traits<allocator<void>>::constructJonathan Wakely1-7/+1
We don't need a preprocessor condition to decide whether to use placement new or std::construct_at, because std::_Construct already does that. libstdc++-v3/ChangeLog: * include/bits/alloc_traits.h (allocator_traits<allocator<void>>): Use std::_Construct for construct.
2022-01-05libstdc++: Fix example preprocessor command in FAQ [PR103877]Jonathan Wakely2-2/+2
libstdc++-v3/ChangeLog: PR libstdc++/103877 * doc/xml/faq.xml: Add '-x c++' to preprocessor command. * doc/html/faq.html: Regenerate.
2022-01-05libstdc++: Reduce template instantiations in <regex>Jonathan Wakely5-39/+37
This moves the last two template parameters of __regex_algo_impl to be runtime function parameters instead, so that we don't need four different instantiations for the possible ways to call it. Most of the function (and what it instantiates) is the same in all cases, so making them compile-time choices doesn't really have much benefit. Use 'if constexpr' for conditions that check template parameters, so that when we do depend on a compile-time condition we only instantiate what we need to. libstdc++-v3/ChangeLog: * include/bits/regex.h (__regex_algo_impl): Change __policy and __match_mode template parameters to be function parameters. (regex_match, regex_search): Pass policy and match mode as function arguments. * include/bits/regex.tcc (__regex_algo_impl): Change template parameters to function parameters. * include/bits/regex_compiler.h (_RegexTranslatorBase): Use 'if constexpr' for conditions using template parameters. (_RegexTranslator): Likewise. * include/bits/regex_executor.tcc (_Executor::_M_handle_accept): Likewise. * testsuite/util/testsuite_regex.h (regex_match_debug) (regex_search_debug): Move template arguments to function arguments.
2022-01-05libstdc++: Compare match_results for failed regex_matchJonathan Wakely1-2/+1
The regex_match_debug testsuite helper doesn't compare the std::match_results objects after a failed match, but it should do. The standard says that the effects of a failed match on the match-results are unspecified, except that [conditions testable by operator==]. So we can check that the two sets of results compare equal even if the match failed. libstdc++-v3/ChangeLog: * testsuite/util/testsuite_regex.h (regex_match_debug): Compare results even if the match failed.
2022-01-05libstdc++: Improve std::regex_error::what() stringsJonathan Wakely4-76/+111
This replaces the vague "regex_error" for std::regex_error::what() with a string that corresponds to the error_type enum passed to the constructor. This allows us to remove many of the strings passed to __throw_regex_error, because the default string is at least as good. When a string argument to __throw_regex_error is kept it should add some context-specific detail absent from the default string. Also remove full stops (periods) from the end of those strings, to make it easier to include them in logs and other output. I've left them starting with an upper-case letter, which is consistent with strerror output for (at least) Glibc, Solaris and BSD. I'm ambivalent whether that's the right choice. This also adds the missing noreturn attribute to __throw_regex_error. libstdc++-v3/ChangeLog: * include/bits/regex_compiler.tcc: Adjust all calls to __throw_regex_error. * include/bits/regex_error.h (__throw_regex_error): Add noreturn attribute. * include/bits/regex_scanner.tcc: Likewise. * src/c++11/regex.cc (desc): New helper function. (regex_error::regex_error(error_type)): Use desc to get a string corresponding to the error code.
2022-01-03Update copyright years.Jakub Jelinek10113-10114/+10114
2022-01-03Rotate ChangeLog files - step 2 - remove 2021 entries from ChangeLog files.Jakub Jelinek1-9009/+1
Can't be committed together with the previous one due to the ChangeLog vs. other files restrictions.
2022-01-03Rotate ChangeLog files - part 1 - add ChangeLog-2021.Jakub Jelinek1-0/+9013
2022-01-03 Jakub Jelinek <jakub@redhat.com> gcc/ * ChangeLog-2021: Rotate ChangeLog. New file. gcc/ada/ * ChangeLog-2021: Rotate ChangeLog. New file. gcc/cp/ * ChangeLog-2021: Rotate ChangeLog. New file. gcc/d/ * ChangeLog-2021: Rotate ChangeLog. New file. gcc/fortran/ * ChangeLog-2021: Rotate ChangeLog. New file. gcc/testsuite/ * ChangeLog-2021: Rotate ChangeLog. New file. libgfortran/ * ChangeLog-2021: Rotate ChangeLog. New file. libstdc++-v3/ * ChangeLog-2021: Rotate ChangeLog. New file.
2021-12-16Daily bump.GCC Administrator1-0/+22
2021-12-15libstdc++: Overload std::__to_address for __gnu_cxx::__normal_iterator.François Dumont3-26/+40
Prefer to overload __to_address to partially specialize std::pointer_traits because std::pointer_traits would be mostly useless. Moreover partial specialization of pointer_traits<__normal_iterator<P, C>> fails to rebind C, so you get incorrect types like __normal_iterator<long*, vector<int>>. In the case of __gnu_debug::_Safe_iterator the to_pointer method is impossible to implement correctly because we are missing the parent container to associate the iterator to. libstdc++-v3/ChangeLog: * include/bits/stl_iterator.h (std::pointer_traits<__gnu_cxx::__normal_iterator<>>): Remove. (std::__to_address(const __gnu_cxx::__normal_iterator<>&)): New for C++11 to C++17. * include/debug/safe_iterator.h (std::__to_address(const __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<>, _Sequence>&)): New for C++11 to C++17. * testsuite/24_iterators/normal_iterator/to_address.cc: Add check on std::vector::iterator to validate both __gnu_cxx::__normal_iterator<> __to_address overload in normal mode and __gnu_debug::_Safe_iterator in _GLIBCXX_DEBUG mode.
2021-12-15libstdc++: Poor man's case insensitive comparisons in time_get [PR71557]Jakub Jelinek3-27/+239
This patch uses the same not completely correct case insensitive comparisons as used elsewhere in the same header. Proper comparisons that would handle even multi-byte characters would be harder, but I don't see them implemented in __ctype's methods. 2021-12-15 Jakub Jelinek <jakub@redhat.com> PR libstdc++/71557 * include/bits/locale_facets_nonio.tcc (_M_extract_via_format): Compare characters other than format specifiers and whitespace case insensitively. (_M_extract_name): Compare characters case insensitively. * testsuite/22_locale/time_get/get/char/71557.cc: New test. * testsuite/22_locale/time_get/get/wchar_t/71557.cc: New test.
2021-12-15Daily bump.GCC Administrator1-0/+51
2021-12-14libstdc++: Support old and new T_FMT for en_HK locale [PR103687]Jonathan Wakely3-10/+65
This checks whether the locale data for en_HK includes %p and adjusts the string being tested accordingly. To account for Jakub's fix to make %I parse "12" as 0 instead of 12, we need to change the expected value for the case where the locale format doesn't include %p. Also change the time from 12:00:00 to 12:02:01 so we can tell if the minutes and seconds get mixed up. libstdc++-v3/ChangeLog: PR libstdc++/103687 * testsuite/22_locale/time_get/get_date/wchar_t/4.cc: Restore original locale before returning. * testsuite/22_locale/time_get/get_time/char/2.cc: Check for %p in locale's T_FMT and adjust accordingly. * testsuite/22_locale/time_get/get_time/wchar_t/2.cc: Likewise.
2021-12-14libstdc++: Fix handling of invalid ranges in std::regex [PR102447]Jonathan Wakely3-68/+152
std::regex currently allows invalid bracket ranges such as [\w-a] which are only allowed by ECMAScript when in web browser compatibility mode. It should be an error, because the start of the range is a character class, not a single character. The current implementation of _Compiler::_M_expression_term does not provide a way to reject this, because we only remember a previous character, not whether we just processed a character class (or collating symbol etc.) This patch replaces the pair<bool, CharT> used to emulate optional<CharT> with a custom class closer to pair<tribool,CharT>. That allows us to track three states, so that we can tell when we've just seen a character class. With this additional state the code in _M_expression_term for processing the _S_token_bracket_dash can be improved to correctly reject the [\w-a] case, without regressing for valid cases such as [\w-] and [----]. libstdc++-v3/ChangeLog: PR libstdc++/102447 * include/bits/regex_compiler.h (_Compiler::_BracketState): New class. (_Compiler::_BrackeyMatcher): New alias template. (_Compiler::_M_expression_term): Change pair<bool, CharT> parameter to _BracketState. Process first character for ECMAScript syntax as well as POSIX. * include/bits/regex_compiler.tcc (_Compiler::_M_insert_bracket_matcher): Pass _BracketState. (_Compiler::_M_expression_term): Use _BracketState to store state between calls. Improve handling of dashes in ranges. * testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc: Add more tests for ranges containing dashes. Check invalid ranges with character class at the beginning.
2021-12-14libstdc++: Simplify typedefs by using __UINTPTR_TYPE__Jonathan Wakely1-31/+19
libstdc++-v3/ChangeLog: * include/ext/pointer.h (_Relative_pointer_impl::_UIntPtrType): Rename to uintptr_t and define as __UINTPTR_TYPE__.
2021-12-14libstdc++: Simplify definition of std::regex_constants variablesJonathan Wakely6-91/+114
This removes the __syntax_option and __match_flag enumeration types, which are only used to define enumerators with successive values that are then used to initialize the std::regex_constants global variables. By defining enumerators in the syntax_option_type and match_flag_type enumeration types with the correct values for the globals we get rid of two useless enumeration types that just count from 0 to N, and we improve the debugging experience. Because the enumeration types now have enumerators defined, GDB will print values in terms of those enumerators e.g. $6 = (std::regex_constants::_S_ECMAScript | std::regex_constants::_S_multiline) Previously this would have been shown as simply 0x810 because there were no enumerators of that type. This changes the type and value of enumerators such as _S_grep, but users should never be referring to them directly anyway. libstdc++-v3/ChangeLog: * include/bits/regex_constants.h (__syntax_option, __match_flag): Remove. (syntax_option_type, match_flag_type): Define enumerators. Use to initialize globals. Add constexpr to compound assignment operators. * include/bits/regex_error.h (error_type): Add comment. * testsuite/28_regex/constants/constexpr.cc: Remove comment. * testsuite/28_regex/constants/error_type.cc: Improve comment. * testsuite/28_regex/constants/match_flag_type.cc: Check bitmask requirements. * testsuite/28_regex/constants/syntax_option_type.cc: Likewise.
2021-12-14libstdc++: Fix non-reserved name in <regex> headerJonathan Wakely2-2/+3
libstdc++-v3/ChangeLog: * include/bits/regex_compiler.tcc (_Compiler::_M_match_token): Use reserved name for parameter. * testsuite/17_intro/names.cc: Check "token".
2021-12-14Daily bump.GCC Administrator1-0/+22
2021-12-13libstdc++: Add support for '?' in linker script globsJonathan Wakely1-2/+4
The scripts/make_exports.pl script used for darwin only replaces '*' wildcards in globs, it doesn't handle '?'. This means the recent changes to std::__timepunct exports broke darwin. Rather than use mangled names in the linker script, this adds support for '?' to the perl script. This also removes some unnecessary escaping of the replacement strings in s// substitutions. libstdc++-v3/ChangeLog: * scripts/make_exports.pl: Replace '?' with '.' when turning a glob into a regex.
2021-12-13libstdc++: Make ranges::size and ranges::empty check for unbounded arraysJonathan Wakely3-0/+24
Passing IncompleteType(&)[] to ranges::begin produces an error outside the immediate context, which is fine for ranges::begin, but it means that we fail to enforce the SFINAE-able constraints for ranges::size and ranges::size. They should not be callable for any array of unknown bound, whether the type is complete or not. Because we don't enforce that in their constraints, we get a hard error when they try to use ranges::begin. This simply adds explicit checks for arrays of unknown bound to the constraints for ranges::size and ranges::empty. We only need to check it for the __sentinel_size and __eq_iter_empty concepts, because those are the ones that are relevant to arrays, and which try to use ranges::begin. libstdc++-v3/ChangeLog: * include/bits/ranges_base.h (ranges::size, ranges::empty): Add explicit check for unbounded arrays before using ranges::begin. * testsuite/std/ranges/access/empty.cc: Check handling of unbounded arrays. * testsuite/std/ranges/access/size.cc: Likewise.
2021-12-13libstdc++: Fix std::regex_replace for strings with embedded null [PR103664]Jonathan Wakely3-7/+33
The overload of std::regex_replace that takes a std::basic_string as the fmt argument (for the replacement string) is implemented in terms of the one taking a const C*, which uses std::char_traits to find the length. That means it stops at a null character, even though the basic_string might have additional characters beyond that. Rather than duplicate the implementation of the const C* one for the std::basic_string case, this moves that implementation to a new __regex_replace function which takes a const C* and a length. Then both the std::basic_string and const C* overloads can call that (with the latter using char_traits to find the length to pass to the new function). libstdc++-v3/ChangeLog: PR libstdc++/103664 * include/bits/regex.h (__regex_replace): Declare. (regex_replace): Use it. * include/bits/regex.tcc (__regex_replace): Replace regex_replace definition with __regex_replace. * testsuite/28_regex/algorithms/regex_replace/char/103664.cc: New test.