aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/22_locale
AgeCommit message (Collapse)AuthorFilesLines
2024-01-17libstdc++: Implement C++26 std::text_encoding (P1885R12) [PR113318]Jonathan Wakely1-0/+36
This is another C++26 change, approved in Varna 2023. We require a new static array of data that is extracted from the IANA Character Sets database. A new Python script to generate a header from the IANA CSV file is added. The text_encoding class is basically just a pointer to an {ID,name} pair in the static array. The aliases view is also just the same pointer (or empty), and the view's iterator moves forwards and backwards in the array while the array elements have the same ID (or to one element further, for a past-the-end iterator). Because those iterators refer to a global array that never goes out of scope, there's no reason they should every produce undefined behaviour or indeterminate values. They should either have well-defined behaviour, or abort. The overhead of ensuring those properties is pretty low, so seems worth it. This means that an aliases_view iterator should never be able to access out-of-bounds. A non-value-initialized iterator always points to an element of the static array even when not dereferenceable (the array has unreachable entries at the start and end, which means that even a past-the-end iterator for the last encoding in the array still points to valid memory). Dereferencing an iterator can always return a valid array element, or "" for a non-dereferenceable iterator (but doing so will abort when assertions are enabled). In the language being proposed for C++26, dereferencing an invalid iterator erroneously returns "". Attempting to increment/decrement past the last/first element in the view is erroneously a no-op, so aborts when assertions are enabled, and doesn't change value otherwise. Similarly, constructing a std::text_encoding with an invalid id (one that doesn't have the value of an enumerator) erroneously behaves the same as constructing with id::unknown, or aborts with assertions enabled. libstdc++-v3/ChangeLog: PR libstdc++/113318 * acinclude.m4 (GLIBCXX_CONFIGURE): Add c++26 directory. (GLIBCXX_CHECK_TEXT_ENCODING): Define. * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Use GLIBCXX_CHECK_TEXT_ENCODING. * include/Makefile.am: Add new headers. * include/Makefile.in: Regenerate. * include/bits/locale_classes.h (locale::encoding): Declare new member function. * include/bits/unicode.h (__charset_alias_match): New function. * include/bits/text_encoding-data.h: New file. * include/bits/version.def (text_encoding): Define. * include/bits/version.h: Regenerate. * include/std/text_encoding: New file. * src/Makefile.am: Add new subdirectory. * src/Makefile.in: Regenerate. * src/c++26/Makefile.am: New file. * src/c++26/Makefile.in: New file. * src/c++26/text_encoding.cc: New file. * src/experimental/Makefile.am: Include c++26 convenience library. * src/experimental/Makefile.in: Regenerate. * python/libstdcxx/v6/printers.py (StdTextEncodingPrinter): New printer. * scripts/gen_text_encoding_data.py: New file. * testsuite/22_locale/locale/encoding.cc: New test. * testsuite/ext/unicode/charset_alias_match.cc: New test. * testsuite/std/text_encoding/cons.cc: New test. * testsuite/std/text_encoding/members.cc: New test. * testsuite/std/text_encoding/requirements.cc: New test. Reviewed-by: Ulrich Drepper <drepper.fsp@gmail.com> Reviewed-by: Patrick Palka <ppalka@redhat.com>
2024-01-03Update copyright years.Jakub Jelinek620-620/+620
2023-10-21libstdc++: testsuite: Enhance codecvt_unicode with tests for length()Dimitrij Mijoski1-13/+110
We can test codecvt::length() with the same data that we test codecvt::in(). For each call of in() we add another call to length(). Some additional small cosmentic changes are applied. libstdc++-v3/ChangeLog: * testsuite/22_locale/codecvt/codecvt_unicode.h: Test length()
2023-09-29libstdc++: Fix handling of surrogate CP in codecvt [PR108976]Dimitrij Mijoski5-440/+1484
This patch fixes the handling of surrogate code points in all standard facets for transcoding Unicode that are based on std::codecvt. Surrogate code points should always be treated as error. On the other hand surrogate code units can only appear in UTF-16 and only when they come in a proper pair. Additionally, it fixes a bug in std::codecvt_utf16::in() when odd number of bytes were given in the range [from, from_end), error was returned always. The last byte in such range does not form a full UTF-16 code unit and we can not make any decisions for error, instead partial should be returned. The testsuite for testing these facets was updated in the following order: 1. All functions that test codecvts that work with UTF-8 were refactored and made more generic so they accept codecvt that works with the char type char8_t. 2. The same functions were updated with new test cases for transcoding errors and now additionally test for surrogates, overlong UTF-8 sequences, code points out of the Unicode range, and more tests for missing leading and trailing code units. 3. New tests were added to test codecvt_utf16 in both of its variants, UTF-16 <-> UTF-32/UCS-4 and UTF-16 <-> UCS-2. libstdc++-v3/ChangeLog: PR libstdc++/108976 * src/c++11/codecvt.cc (read_utf8_code_point): Fix handing of surrogates in UTF-8. (ucs4_out): Fix handling of surrogates in UCS-4 -> UTF-8. (ucs4_in): Fix handling of range with odd number of bytes. (ucs4_out): Fix handling of surrogates in UCS-4 -> UTF-16. (ucs2_out): Fix handling of surrogates in UCS-2 -> UTF-16. (ucs2_in): Fix handling of range with odd number of bytes. (__codecvt_utf16_base<char16_t>::do_in): Likewise. (__codecvt_utf16_base<char32_t>::do_in): Likewise. (__codecvt_utf16_base<wchar_t>::do_in): Likewise. * testsuite/22_locale/codecvt/codecvt_unicode.cc: Renames, add tests for codecvt_utf16<char16_t> and codecvt_utf16<char32_t>. * testsuite/22_locale/codecvt/codecvt_unicode.h: Refactor UTF-8 testing functions for char8_t, add more test cases for errors, add testing functions for codecvt_utf16. * testsuite/22_locale/codecvt/codecvt_unicode_wchar_t.cc: Renames, add tests for codecvt_utf16<whchar_t>. * testsuite/22_locale/codecvt/codecvt_utf16/79980.cc (test06): Fix test. * testsuite/22_locale/codecvt/codecvt_unicode_char8_t.cc: New test.
2023-05-12libstdc++: Remove test dependency on _GLIBCXX_USE_C99_STDINT_TR1Jonathan Wakely1-4/+0
This should have been removed in r9-2029-g612c9c702e2c9e when the char16_t and char32_t specializations of std::codecvt were changed to be defined unconditionally. libstdc++-v3/ChangeLog: * testsuite/22_locale/locale/cons/unicode.cc: Remove dependency on _GLIBCXX_USE_C99_STDINT_TR1.
2023-04-05Fix 22_locale/locale/cons/12658_thread-2.cc on hppa.John David Anglin1-0/+1
2023-04-05 John David Anglin <danglin@gcc.gnu.org> libstdc++-v3/ChangeLog: * testsuite/22_locale/locale/cons/12658_thread-2.cc: Double timeout factor on hppa*-*-*.
2023-01-18libstdc++: testsuite: Simplify codecvt_unicodeDimitrij Mijoski3-22/+17
Stop using unique_ptr, create some objects directly. libstdc++-v3/ChangeLog: * testsuite/22_locale/codecvt/codecvt_unicode.cc: Simplify. * testsuite/22_locale/codecvt/codecvt_unicode.h: Simplify. * testsuite/22_locale/codecvt/codecvt_unicode_wchar_t.cc: Simplify.
2023-01-16Update copyright years.Jakub Jelinek616-616/+616
2023-01-13libstdc++: Fix Unicode codecvt and add tests [PR86419]Dimitrij Mijoski3-0/+1396
Fixes the conversion from UTF-8 to UTF-16 to properly return partial instead ok. Fixes the conversion from UTF-16 to UTF-8 to properly return partial instead ok. Fixes the conversion from UTF-8 to UCS-2 to properly return partial instead error. Fixes the conversion from UTF-8 to UCS-2 to treat 4-byte UTF-8 sequences as error just by seeing the leading byte. Fixes UTF-8 decoding for all codecvts so they detect error at the end of the input range when the last code point is also incomplete. libstdc++-v3/ChangeLog: PR libstdc++/86419 * src/c++11/codecvt.cc (read_utf8_code_point): Correctly detect errors in incomplete multibyte sequences. (utf16_in): Remove surrogates parameter. Fix conditions for returning partial. (utf16_out): Fix condition for returning partial. (ucs2_in): Do not pass surrogates argument to utf16_in. * testsuite/22_locale/codecvt/codecvt_unicode.cc: New test. * testsuite/22_locale/codecvt/codecvt_unicode.h: New header for tests. * testsuite/22_locale/codecvt/codecvt_unicode_wchar_t.cc: New test.
2022-11-11libstdc++: Avoid redundant checks in std::use_facet [PR103755]Jonathan Wakely1-2/+3
We do not need to do bounds checks or a runtime dynamic_cast when using std::has_facet and std::use_facet to access the default facets that are guaranteed to be present in every std::locale object. We can just index straight into the array and use a static_cast for the conversion. This patch adds a new std::__try_use_facet function that is like std::use_facet but returns a pointer, so can be used to implement both std::has_facet and std::use_facet. We can then do the necessary metaprogramming to skip the redundant checks in std::__try_use_facet. To avoid having to export (or hide) instantiations of the new function from libstdc++.so the instantiations are given hidden visibility. This allows them to be used in the library, but user code will instantiate it again using the definition in the header. That would happen anyway, because there are no explicit instantiation declarations for any of std::has_facet, std::use_facet, or the new std::__try_use_facet. libstdc++-v3/ChangeLog: PR libstdc++/103755 * config/abi/pre/gnu.ver: Tighten patterns for facets in the base version. Add exports for __try_use_facet. * include/bits/basic_ios.tcc (basic_ios::_M_cache_locale): Use __try_use_facet instead of has_facet and use_facet. * include/bits/fstream.tcc (basic_filebuf::basic_filebuf()): Likewise. (basic_filebuf::imbue): Likewise. * include/bits/locale_classes.h (locale, locale::id) (locale::_Impl): Declare __try_use_facet as a friend. * include/bits/locale_classes.tcc (__try_use_facet): Define new function template with special cases for default facets. (has_facet, use_facet): Call __try_use_facet. * include/bits/locale_facets.tcc (__try_use_facet): Declare explicit instantiations. * include/bits/locale_facets_nonio.tcc (__try_use_facet): Likewise. * src/c++11/locale-inst-monetary.h (INSTANTIATE_FACET_ACCESSORS): Use new macro for facet accessor instantiations. * src/c++11/locale-inst-numeric.h (INSTANTIATE_FACET_ACCESSORS): Likewise. * src/c++11/locale-inst.cc (INSTANTIATE_USE_FACET): Define new macro for instantiating __try_use_facet and use_facet. (INSTANTIATE_FACET_ACCESSORS): Define new macro for also defining has_facet. * src/c++98/compatibility-ldbl.cc (__try_use_facet): Instantiate. * testsuite/22_locale/ctype/is/string/89728_neg.cc: Adjust expected errors.
2022-05-05libstdc++: Fixes for tests that fail with -fno-rttiJonathan Wakely4-13/+10
This disables a use of dynamic_cast that is not valid for -fno-rtti and adjusts some tests so they don't FAIL with -fno-rtti. Some tests are skipped completely, and others just make use of typeid conditional on the __cpp_rtti macro. A couple of tests were using typeid to verify typedefs denote the right type, which can be done at compile-time using templates instead. libstdc++-v3/ChangeLog: * include/experimental/memory_resource [!__cpp_rtti] (__resource_adaptor_imp::do_is_equal): Do not use dynamic_cast when RTTI is disabled. * testsuite/17_intro/freestanding.cc: Require RTTI. * testsuite/18_support/exception/38732.cc: Likewise. * testsuite/18_support/exception_ptr/rethrow_exception.cc: Likewise. * testsuite/18_support/nested_exception/68139.cc: Likewise. * testsuite/18_support/nested_exception/rethrow_if_nested.cc: Likewise. * testsuite/18_support/type_info/103240.cc: Likewise. * testsuite/18_support/type_info/fundamental.cc: Likewise. * testsuite/18_support/type_info/hash_code.cc: Likewise. * testsuite/20_util/any/assign/emplace.cc: Likewise. * testsuite/20_util/any/cons/in_place.cc: Likewise. * testsuite/20_util/any/misc/any_cast.cc: Likewise. * testsuite/20_util/any/observers/type.cc: Likewise. * testsuite/20_util/function/1.cc: Likewise. * testsuite/20_util/function/2.cc: Likewise. * testsuite/20_util/function/3.cc: Likewise. * testsuite/20_util/function/4.cc: Likewise. * testsuite/20_util/function/5.cc: Likewise. * testsuite/20_util/function/6.cc: Likewise. * testsuite/20_util/function/7.cc: Likewise. * testsuite/20_util/function/8.cc: Likewise. * testsuite/20_util/polymorphic_allocator/resource.cc: Likewise. * testsuite/20_util/shared_ptr/casts/1.cc: Likewise. * testsuite/20_util/shared_ptr/casts/rval.cc: Likewise. * testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_2.cc: Likewise. * testsuite/20_util/shared_ptr/misc/get_deleter.cc: Likewise. * testsuite/20_util/typeindex/comparison_operators.cc: Likewise. * testsuite/20_util/typeindex/comparison_operators_c++20.cc: Likewise. * testsuite/20_util/typeindex/hash.cc: Likewise. * testsuite/20_util/typeindex/hash_code.cc: Likewise. * testsuite/20_util/typeindex/name.cc: Likewise. * testsuite/22_locale/ctype/is/string/89728_neg.cc: Likewise. * testsuite/22_locale/global_templates/standard_facet_hierarchies.cc: Likewise. * testsuite/22_locale/global_templates/user_facet_hierarchies.cc: Likewise. * testsuite/22_locale/locale/13630.cc: Check type without using RTTI. * testsuite/23_containers/array/requirements/non_default_constructible.cc: Require RTTI. * testsuite/27_io/basic_ostream/emit/1.cc: Likewise. * testsuite/27_io/fpos/14320-1.cc: Check type without using RTTI. * testsuite/27_io/fpos/mbstate_t/12065.cc: Require RTTI. * testsuite/27_io/ios_base/failure/dual_abi.cc: Likewise. * testsuite/experimental/any/misc/any_cast.cc: Likewise. * testsuite/experimental/any/observers/type.cc: Likewise. * testsuite/experimental/memory_resource/resource_adaptor.cc: Likewise. * testsuite/lib/libstdc++.exp (check_effective_target_rtti): Define new proc. * testsuite/tr1/3_function_objects/function/1.cc: Likewise. * testsuite/tr1/3_function_objects/function/2.cc: Likewise. * testsuite/tr1/3_function_objects/function/3.cc: Likewise. * testsuite/tr1/3_function_objects/function/4.cc: Likewise. * testsuite/tr1/3_function_objects/function/5.cc: Likewise. * testsuite/tr1/3_function_objects/function/6.cc: Likewise. * testsuite/tr1/3_function_objects/function/7.cc: Likewise. * testsuite/tr1/3_function_objects/function/8.cc: Likewise. * testsuite/tr2/bases/value.cc: Likewise. * testsuite/tr2/direct_bases/value.cc: Likewise. * testsuite/util/exception/safety.h [!__cpp_rtti]: Don't print types without RTTI.
2022-03-28libstdc++: Fix typos in comments in testsJonathan Wakely6-20/+20
libstdc++-v3/ChangeLog: * testsuite/20_util/optional/monadic/and_then.cc: Fix typo. * testsuite/20_util/optional/monadic/transform.cc: Likewise. * testsuite/22_locale/codecvt/always_noconv/char/1.cc: Likewise. * testsuite/22_locale/codecvt/encoding/char/1.cc: Likewise. * testsuite/22_locale/codecvt/in/char/1.cc: Likewise. * testsuite/22_locale/codecvt/max_length/char/1.cc: Likewise. * testsuite/22_locale/codecvt/out/char/1.cc: Likewise. * testsuite/22_locale/codecvt/unshift/char/1.cc: Likewise.
2022-01-14libstdc++: Fix 22_locale/numpunct/members/char/3.cc execution testUros Bizjak1-3/+3
The test fails on Fedora 33+ because nl_NL locale got thousands separator defined. Use one of ar_SA, bg_BG, bs_BA, pt_PT or plain C locale instead. 2022-01-14 Uroš Bizjak <ubizjak@gmail.com> libstdc++-v3/ChangeLog: * testsuite/22_locale/numpunct/members/char/3.cc: Require pt_PT locale instead of nl_NL. (test02): Use pt_PT locale instead of nl_NL.
2022-01-10libstdc++: Add %j, %U, %w, %W time_get support, fix %y, %Y, %C, %p [PR77760]Jakub Jelinek8-10/+656
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-03Update copyright years.Jakub Jelinek612-612/+612
2021-12-15libstdc++: Poor man's case insensitive comparisons in time_get [PR71557]Jakub Jelinek2-0/+192
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-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-10libstdc++: Add std::time_get %r support [PR71367]Jakub Jelinek2-0/+134
This incremental patch adds std::time_get %r support (%p was added already in the previous patch). The _M_am_fm_format method previously in the header unfortunately had wrong arguments and so was useless, so the largest complication in this patch is exporting a new symbol in the right symbol version. 2021-12-10 Jakub Jelinek <jakub@redhat.com> PR libstdc++/71367 * config/locale/dragonfly/time_members.cc (_M_initialize_timepunct): Initialize "C" _M_am_pm_format to %I:%M:%S %p rather than empty string. * config/locale/gnu/time_members.cc (_M_initialize_timepunct): Likewise. * config/locale/generic/time_members.cc (_M_initialize_timepunct): Likewise. * include/bits/locale_facets_nonio.h (_M_am_pm_format): New method. * include/bits/locale_facets_nonio.tcc (_M_extract_via_format): Handle %r. * config/abi/pre/gnu.ver (GLIBCXX_3.4.30): Export _M_am_pm_format with const _CharT** argument, ensure it isn't exported in GLIBCXX_3.4. * testsuite/22_locale/time_get/get/char/71367.cc: New test. * testsuite/22_locale/time_get/get/wchar_t/71367.cc: New test.
2021-12-10libstdc++: Some time_get fixes [PR78714]Jakub Jelinek8-8/+720
The following patch is an attempt to fix various time_get related issues. Sorry, it is long... One of them is PR78714. It seems _M_extract_via_format has been written with how strftime behaves in mind rather than how strptime behaves. There is a significant difference between the two, for strftime %a and %A behave differently etc., one emits an abbreviated name, the other full name. For strptime both should behave the same and accept both the full or abbreviated names. This needed large changes in _M_extract_name, which was assuming the names are unique and names aren't prefixes of other names. The _M_extract_name changes allow to deal with those cases. As can be seen in the new testcase, e.g. for %b and english locales we need to accept both Apr and April. If we see Apr in the input, the code looks at whether there is end right after those 3 chars or if the next character doesn't match characters in the longer names; in that case it accepts the abbreviated name. Otherwise, if the input has Apri, it commits to a longer name and fails if it isn't April. This behavior is different from strptime, which for %bix and Aprix accepts it, but for an input iterator I'm afraid we can't do better, we can't go back (peek more than the current character). Another case is that %d and %e in strptime should work the same, while previously the code was hardcoding that %d would be 01 to 31 and %e 1 to 31 (with leading 0 replaced by space). strptime POSIX 2009 documentation seems to suggest for numbers it should accept up to the specified number of digits rather than exactly that number of digits: The pattern "[x,y]" indicates that the value shall fall within the range given (both bounds being inclusive), and the maximum number of characters scanned shall be the maximum required to represent any value in the range without leading zeros. so by my reading "1:" is valid for "%H:". The glibc strptime implementation actually skips any amount of whitespace in all the cases where a number is read, my current patch skips a single space at the start of %d/%e but not the others, but doesn't subtract the space length from the len characters. One option would be to do the leading whitespace skipping in _M_extract_num but take it into account how many digits can be read. This matters for " 12:" and "%H:", but not for " 12:" and " %H:" as in the latter case the space in the format string results in all the whitespace at the start to be consumed. Note, the allowing of a single digit rather than 2 changes a behavior in other ways, e.g. when seeing 40 in a number for range [1, 31] we reject it as before, but previously we'd keep *ret == '4' because it was assuming it has to be 2 digits and 40 isn't valid, so we know error already on the 4, but now we accept the 4 as value and fail iff the next format string doesn't match the 0. Also, previously it wasn't really checking the number was in the right range, it would accept 00 for [1, 31] numbers, or would accept 39. Another thing is that %I was parsing 12 as tm_hour 12 rather than as tm_hour 0 like e.g. glibc does. Another thing is that %t was matching a single tab and %n a single newline, while strptime docs say it skips over whitespace (again, zero or more). Another thing is that %p wasn't handled at all, I think this was the main cause of FAIL: 22_locale/time_get/get_time/char/2.cc execution test FAIL: 22_locale/time_get/get_time/char/wrapped_env.cc execution test FAIL: 22_locale/time_get/get_time/char/wrapped_locale.cc execution test FAIL: 22_locale/time_get/get_time/wchar_t/2.cc execution test FAIL: 22_locale/time_get/get_time/wchar_t/wrapped_env.cc execution test FAIL: 22_locale/time_get/get_time/wchar_t/wrapped_locale.cc execution test before this patch, because en_HK* locales do use %I and %p in it. The patch handles %p only if it follows %I (i.e. when the hour is parsed first), which is the more usual case (in glibc): grep '%I' localedata/locales/* | grep '%I.*%p' | wc -l 282 grep '%I' localedata/locales/* | grep -v '%I.*%p' | wc -l 44 grep '%I' localedata/locales/* | grep -v '%p' | wc -l 17 The last case use %P instead of %p in t_fmt_ampm, not sure if that one is never used by strptime because %P isn't handled by strptime. Anyway, the right thing to handle even %p%I would be to pass some state around through all the _M_extract_via_format calls like glibc passes struct __strptime_state { unsigned int have_I : 1; unsigned int have_wday : 1; unsigned int have_yday : 1; unsigned int have_mon : 1; unsigned int have_mday : 1; unsigned int have_uweek : 1; unsigned int have_wweek : 1; unsigned int is_pm : 1; unsigned int want_century : 1; unsigned int want_era : 1; unsigned int want_xday : 1; enum ptime_locale_status decided : 2; signed char week_no; signed char century; int era_cnt; } s; around. That is for the %p case used like: if (s.have_I && s.is_pm) tm->tm_hour += 12; during finalization, but handles tons of other cases which it is unclear if libstdc++ needs or doesn't need to handle, e.g. strptime if one specifies year and yday computes wday/mon/day from it, etc. basically for the redundant fields computes them from other fields if those have been parsed and are sufficient to determine it. To do this we'd need to change ABI for the _M_extract_via_format, though sure, we could add a wrapper around the new one with the old arguments that would just use a dummy state. And we'd need a new _M_whatever finalizer that would do those post parsing tweaks. Also, %% wasn't handled. For a whitespace in the strings there was inconsistent behavior, _M_extract_via_format would require exactly that whitespace char (say matching space, or matching tab), while the caller follows what https://eel.is/c++draft/locale.time.get#members-8.5 says, that when encountering whitespace it skips whitespace in the format and then whitespace in the input if any. I've changed _M_extract_via_format to skip whitespace in the input (looping over format isn't IMHO necessary, because next iteration of the loop will handle that too). Tested on x86_64-linux by make check-target-libstdc++-v3, ok for trunk if it passes full bootstrap/regtest? For the new 3.cc testcases, I have included hopefully correctly corresponding C testcase using strptime in an attachment, and to the extent where it can be compared (e.g. strptime on failure just returns NULL, doesn't tell where it exactly stopped) I think the only difference is that str = "Novembur"; format = "%bembur"; ret = strptime (str, format, &time); case where strptime accepts it but there is no way to do it with input operator. I admit I don't have libc++ or other STL libraries around to be able to check how much the new 3.cc matches or disagrees with other implementations. Now, the things not handled by this patch but which should be fixed (I probably need to go back to compiler work) or at least looked at: 1) seems %j, %r, %U, %w and %W aren't handled (not sure if all of them are already in POSIX 2009 or some are later) 2) I haven't touched the %y/%Y/%C and year handling stuff, that is definitely not matching what POSIX 2009 says: C All but the last two digits of the year {2}; leading zeros shall be permitted but shall not be required. A leading '+' or '−' character shall be permitted before any leading zeros but shall not be required. y The last two digits of the year. When format contains neither a C conversion specifier nor a Y conversion specifier, values in the range [69,99] shall refer to years 1969 to 1999 inclusive and values in the range [00,68] shall refer to years 2000 to 2068 inclusive; leading zeros shall be permitted but shall not be re‐ quired. A leading '+' or '−' character shall be permitted before any leading zeros but shall not be required. Note: It is expected that in a future version of this standard the default century inferred from a 2-digit year will change. (This would apply to all commands accepting a 2-digit year as input.) Y The full year {4}; leading zeros shall be permitted but shall not be required. A leading '+' or '−' character shall be permitted before any leading zeros but shall not be required. I've tried to avoid making changes to _M_extract_num for these as well to keep current status quo (the __len == 4 cases). One thing is what to do for things with %C %y and/or %Y in the formats, another thing is what to do in the methods that directly perform _M_extract_num for year 3) the above question what to do for leading whitespace of any numbers being parsed 4) the %p%I issue mentioned above and generally what to do if we pass state and have finalizers at the end of parsing 5) _M_extract_via_format is also inconsistent with its callers on handling the non-whitespace characters in between format specifiers, the caller follows https://eel.is/c++draft/locale.time.get#members-8.6 and does case insensitive comparison: // TODO real case-insensitive comparison else if (__ctype.tolower(*__s) == __ctype.tolower(*__fmt) || __ctype.toupper(*__s) == __ctype.toupper(*__fmt)) while _M_extract_via_format only compares exact characters: // Verify format and input match, extract and discard. if (__format[__i] == *__beg) ++__beg; (another question is if there is a better way how to do real case-insensitive comparison of 2 characters and whether we e.g. need to handle the Turkish i/İ and ı/I which have different number of bytes in UTF-8) 6) _M_extract_name does something weird for case-sensitivity, // NB: Some of the locale data is in the form of all lowercase // names, and some is in the form of initially-capitalized // names. Look for both. if (__beg != __end) and if (__c == __names[__i1][0] || __c == __ctype.toupper(__names[__i1][0])) for the first letter while just __name[__pos] == *__beg on all the following letters. strptime says: In case a text string (such as the name of a day of the week or a month name) is to be matched, the comparison is case insensitive. so supposedly all the _M_extract_name comparisons should be case insensitive. 2021-12-10 Jakub Jelinek <jakub@redhat.com> PR libstdc++/78714 * include/bits/locale_facets_nonio.tcc (_M_extract_via_format): Mention in function comment it interprets strptime format string rather than strftime. Handle %a and %A the same by accepting both full and abbreviated names. Similarly handle %h, %b and %B the same. Handle %d and %e the same by accepting possibly optional single space and 1 or 2 digits. For %I store tm_hour 0 instead of tm_hour 12. For %t and %n skip any whitespace. Handle %p and %%. For whitespace in the string skip any whitespace. (_M_extract_num): For __len == 2 accept 1 or 2 digits rather than always 2. Don't punt early if __value * __mult is larget than __max or smaller than __min - __mult, instead punt if __value > __max. At the end verify __value is in between __min and __max and punt otherwise. (_M_extract_name): Allow non-unique names or names which are prefixes of other names. Don't recompute lengths of names for every character. * testsuite/22_locale/time_get/get/char/3.cc: New test. * testsuite/22_locale/time_get/get/wchar_t/3.cc: New test. * testsuite/22_locale/time_get/get_date/char/12791.cc (test01): Use 62 instead 60 and expect 6 to be accepted and thus *ret01 == '2'. * testsuite/22_locale/time_get/get_date/wchar_t/12791.cc (test01): Similarly. * testsuite/22_locale/time_get/get_time/char/2.cc (test02): Add " PM" to the string. * testsuite/22_locale/time_get/get_time/char/5.cc (test01): Expect tm_hour 1 rather than 0. * testsuite/22_locale/time_get/get_time/wchar_t/2.cc (test02): Add " PM" to the string. * testsuite/22_locale/time_get/get_time/wchar_t/5.cc (test01): Expect tm_hour 1 rather than 0.
2021-10-09libstdc++: Remove unnecessary uses of _GLIBCXX_USE_WCHAR_T in testsuite ↵Jonathan Wakely1-2/+0
[PR98725] Now that std::wstring and other specializations for wchar_t are defined unconditionally, many checks for _GLIBCXX_USE_WCHAR_T in the testsuite are unnecessary and can be removed. Tests for iostreams, locales, regex and filesystem::path still need to be guarded by _GLIBCXX_USE_WCHAR_T because those components depend on libc support in <wchar.h> and other headers. libstdc++-v3/ChangeLog: PR libstdc++/98725 * testsuite/18_support/numeric_limits/lowest.cc: Remove use of _GLIBCXX_USE_WCHAR_T. * testsuite/18_support/numeric_limits/min_max.cc: Replace use of _GLIBCXX_USE_WCHAR_T with checks for WCHAR_MIN and WCHAR_MAX. * testsuite/20_util/from_chars/1_neg.cc: Remove use of _GLIBCXX_USE_WCHAR_T. * testsuite/20_util/function_objects/searchers.cc: Likewise. Use char_traits<wchar_t>::length instead of wcslen. * testsuite/20_util/hash/requirements/explicit_instantiation.cc: Likewise. * testsuite/20_util/is_arithmetic/value.cc: Likewise. * testsuite/20_util/is_compound/value.cc: Likewise. * testsuite/20_util/is_floating_point/value.cc: Likewise. * testsuite/20_util/is_fundamental/value.cc: Likewise. * testsuite/20_util/is_integral/value.cc: Likewise. * testsuite/20_util/is_signed/value.cc: Likewise. * testsuite/20_util/is_unsigned/value.cc: Likewise. * testsuite/20_util/is_void/value.cc: Likewise. * testsuite/20_util/make_signed/requirements/typedefs-1.cc: Likewise. * testsuite/20_util/make_signed/requirements/typedefs-2.cc: Likewise. * testsuite/20_util/make_signed/requirements/typedefs-3.cc: Likewise. * testsuite/20_util/make_signed/requirements/typedefs-4.cc: Likewise. * testsuite/20_util/make_unsigned/requirements/typedefs-1.cc: Likewise. * testsuite/20_util/make_unsigned/requirements/typedefs-2.cc: Likewise. * testsuite/20_util/make_unsigned/requirements/typedefs-3.cc: Likewise. * testsuite/20_util/to_chars/3.cc: Likewise. * testsuite/20_util/type_identity/requirements/typedefs.cc: Likewise. * testsuite/21_strings/basic_string/hash/debug.cc: Likewise. * testsuite/21_strings/basic_string/hash/hash.cc: Likewise. * testsuite/21_strings/basic_string/literals/types-char8_t.cc: Likewise. * testsuite/21_strings/basic_string/literals/types.cc: Likewise. * testsuite/21_strings/basic_string/literals/values-char8_t.cc: Likewise. * testsuite/21_strings/basic_string/literals/values.cc: Likewise. * testsuite/21_strings/basic_string/modifiers/64422.cc: Likewise. * testsuite/21_strings/basic_string/range_access/wchar_t/1.cc: Likewise. * testsuite/21_strings/basic_string/requirements/citerators.cc: Likewise. * testsuite/21_strings/basic_string/requirements/typedefs.cc: Likewise. * testsuite/21_strings/basic_string/types/pmr_typedefs.cc: Likewise. * testsuite/21_strings/basic_string_view/literals/types-char8_t.cc: Likewise. * testsuite/21_strings/basic_string_view/literals/types.cc: Likewise. * testsuite/21_strings/basic_string_view/literals/values-char8_t.cc: Likewise. * testsuite/21_strings/basic_string_view/literals/values.cc: Likewise. * testsuite/21_strings/basic_string_view/requirements/typedefs.cc: Likewise. * testsuite/21_strings/basic_string_view/typedefs.cc: Likewise. * testsuite/21_strings/char_traits/requirements/constexpr_functions.cc: Likewise. * testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc: Likewise. * testsuite/21_strings/char_traits/requirements/constexpr_functions_c++20.cc: Likewise. * testsuite/22_locale/ctype/is/string/89728_neg.cc: Likewise. * testsuite/25_algorithms/fill/4.cc: Likewise. * testsuite/25_algorithms/fill_n/1.cc: Likewise. * testsuite/experimental/functional/searchers.cc: Likewise. Use char_traits<wchar_t>::length instead of wcslen. * testsuite/experimental/polymorphic_allocator/pmr_typedefs_string.cc: Likewise. * testsuite/experimental/string_view/literals/types-char8_t.cc: Likewise. * testsuite/experimental/string_view/literals/types.cc: Likewise. * testsuite/experimental/string_view/literals/values-char8_t.cc: Likewise. * testsuite/experimental/string_view/literals/values.cc: Likewise. * testsuite/experimental/string_view/range_access/wchar_t/1.cc: Likewise. * testsuite/experimental/string_view/requirements/typedefs.cc: Likewise. * testsuite/experimental/string_view/typedefs.cc: Likewise. * testsuite/ext/vstring/range_access.cc: Likewise. * testsuite/std/concepts/concepts.lang/concept.arithmetic/integral.cc: Likewise. * testsuite/std/concepts/concepts.lang/concept.arithmetic/signed_integral.cc: Likewise. * testsuite/std/concepts/concepts.lang/concept.arithmetic/unsigned_integral.cc: Likewise. * testsuite/tr1/4_metaprogramming/is_arithmetic/value.cc: Likewise. * testsuite/tr1/4_metaprogramming/is_compound/value.cc: Likewise. * testsuite/tr1/4_metaprogramming/is_floating_point/value.cc: Likewise. * testsuite/tr1/4_metaprogramming/is_fundamental/value.cc: Likewise. * testsuite/tr1/4_metaprogramming/is_integral/value.cc: Likewise. * testsuite/tr1/4_metaprogramming/is_signed/value.cc: Likewise. * testsuite/tr1/4_metaprogramming/is_unsigned/value.cc: Likewise. * testsuite/tr1/4_metaprogramming/is_void/value.cc: Likewise. * testsuite/tr1/6_containers/hash/24799.cc: Likewise.
2021-10-09libstdc++: Add missing _GLIBCXX_USE_WCHAR_T checks in testsuiteJonathan Wakely3-5/+25
These tests fail for a --disable-wchar_t build. libstdc++-v3/ChangeLog: * testsuite/22_locale/conversions/buffer/1.cc: Check _GLIBCXX_USE_WCHAR_T. * testsuite/22_locale/conversions/buffer/3.cc: Likewise. Add test using char16_t. * testsuite/22_locale/conversions/string/1.cc: Check _GLIBCXX_USE_WCHAR_T. * testsuite/27_io/filesystem/path/generic/generic_string.cc: Likewise. * testsuite/27_io/filesystem/path/modifiers/make_preferred.cc: Likewise. * testsuite/27_io/filesystem/path/native/alloc.cc: Likewise. * testsuite/27_io/filesystem/path/native/string-char8_t.cc: Likewise. * testsuite/27_io/filesystem/path/native/string.cc: Likewise. * testsuite/28_regex/algorithms/regex_match/extended/wstring_locale.cc: Likewise. * testsuite/experimental/filesystem/path/generic/generic_string.cc: Likewise. * testsuite/experimental/filesystem/path/native/alloc.cc: Likewise. * testsuite/experimental/filesystem/path/native/string-char8_t.cc: Likewise. * testsuite/experimental/filesystem/path/native/string.cc: Likewise.
2021-06-01libstdc++: Fix new test for C++98 mode [PR 89728]Jonathan Wakely1-2/+6
The isblank class is not supported until C++11. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * testsuite/22_locale/ctype/is/string/89728_neg.cc: Only test isblank for C++11 and later.
2021-05-17libstdc++: diagnose some misuses of [locale.convenience] functions [PR 89728]Antony Polukhin1-0/+73
This patch provides better diagnostics for common misuse of [locale.convenience] functions with std::string as a character type. libstdc++-v3/ChangeLog: PR libstdc++/89728 * include/bits/locale_facets.h (ctype<basic_string<C,T,A>>): Declare (but do not define) partial specialization. * testsuite/22_locale/ctype/is/string/89728_neg.cc: New test.
2021-01-04Update copyright years.Jakub Jelinek605-605/+605
2020-12-15libstdc++: Fix required locales of a testcaseMarius Hillenbrand1-1/+3
The testsuite for libstdc++ aims to skips test cases for which not all required locales are installed. This patch adds missing directives about required locales to one test case to avoid false positive test failures on systems that have a partial set of locales installed. Verified by test suite runs that this patch changes the test case from FAIL to UNSUPPORTED when not all required locales are available and that the test case will run and PASS when the necessary locales have been added. libstdc++-v3/ChangeLog: * testsuite/22_locale/locale/cons/5.cc: Add missing directives for required locales.
2020-10-29libstdc++: Avoid warnings in testsJonathan Wakely1-0/+12
This fixes some warnings emitted when testing with warning flags added. Some of these are only necessary when testing with -Wsystem-headers, but either way it cleans up the tests to be less noisy under non-default flags. libstdc++-v3/ChangeLog: * testsuite/18_support/96817.cc: Avoid -Wunused warnings. * testsuite/20_util/any/assign/2.cc: Likewise. * testsuite/20_util/any/cons/2.cc: Likewise. * testsuite/20_util/align/1.cc: Avoid -Wsign-compare warning. * testsuite/20_util/function/65760.cc: Avoid -Wunused warning. * testsuite/20_util/function/1.cc: Avoid -Wcatch-value warning. * testsuite/20_util/function/cons/move_target.cc: Avoid -Wunused warning. * testsuite/20_util/headers/memory/synopsis.cc: Add exception specification. * testsuite/20_util/monotonic_buffer_resource/allocate.cc: Avoid -Wsign-compare warning. * testsuite/20_util/tuple/cons/deduction.cc: Avoid -Wunused warning. * testsuite/20_util/specialized_algorithms/uninitialized_copy/808590-cxx11.cc: Avoid -Wdeprecated-copy warning. * testsuite/21_strings/basic_string/56166.cc: Avoid -Wcatch-value warning. * testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc: Avoid -Wcatch-value warnings. * testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc: Likewise. * testsuite/21_strings/basic_string_view/operations/compare/char/nonnull.cc: Prune additional diagnostics. * testsuite/21_strings/basic_string_view/operations/find/char/nonnull.cc: Likewise. * testsuite/21_strings/basic_string_view/operations/rfind/char/nonnull.cc: Likewise. * testsuite/21_strings/headers/string/synopsis.cc: Add exception specifications. * testsuite/22_locale/locale/cons/12352.cc: Define sized delete operators to avoid warnings. * testsuite/23_containers/deque/modifiers/swap/1.cc: Add exception specification. * testsuite/23_containers/forward_list/cons/11.cc: Avoid -Wdeprecated-copy warning. * testsuite/23_containers/headers/bitset/synopsis.cc: Add exception specification. * testsuite/23_containers/headers/deque/synopsis.cc: Likewise. * testsuite/23_containers/headers/forward_list/synopsis.cc: Likewise. * testsuite/23_containers/headers/list/synopsis.cc: Likewise. * testsuite/23_containers/headers/map/synopsis.cc: Likewise. * testsuite/23_containers/headers/queue/synopsis.cc: Likewise. * testsuite/23_containers/headers/set/synopsis.cc: Likewise. * testsuite/23_containers/headers/vector/synopsis.cc: Likewise. * testsuite/23_containers/list/modifiers/swap/1.cc: Likewise. * testsuite/23_containers/map/modifiers/swap/1.cc: Likewise. * testsuite/23_containers/multimap/modifiers/swap/1.cc: Likewise. * testsuite/23_containers/multiset/modifiers/swap/1.cc: Likewise. * testsuite/23_containers/set/modifiers/swap/1.cc: Likewise. * testsuite/23_containers/unordered_set/56267-2.cc: Avoid -Wdeprecated-copy warning. * testsuite/23_containers/vector/bool/23632.cc: Avoid -Wempty-body warning. * testsuite/23_containers/vector/modifiers/swap/1.cc: Add exception specification. * testsuite/25_algorithms/heap/moveable2.cc: Fix misplaced parentheses around arguments. * testsuite/25_algorithms/sample/1.cc: Use return value. * testsuite/25_algorithms/search/searcher.cc: Avoid -Wunused warnings. * testsuite/27_io/basic_ostream/exceptions/char/9561.cc: Likewise. * testsuite/27_io/basic_ostream/exceptions/wchar_t/9561.cc: Likewise. * testsuite/27_io/filesystem/operations/remove_all.cc: Avoid -Wsign-compare warning. * testsuite/experimental/any/assign/2.cc: Avoid -Wunused warnings. * testsuite/experimental/any/cons/2.cc: Likewise. * testsuite/experimental/filesystem/operations/remove_all.cc: Avoid -Wign-compare warning. * testsuite/experimental/memory/observer_ptr/cons/cons.cc: Likewise. * testsuite/experimental/memory_resource/null_memory_resource.cc: Likewise. * testsuite/experimental/source_location/1.cc: Avoid -Waddress warning. * testsuite/ext/pod_char_traits.cc: Avoid -Wunused warning. * testsuite/ext/vstring/modifiers/clear/56166.cc: Avoid -Wcatch-value. * testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc: Avoid -Wunused warning. * testsuite/std/concepts/concepts.lang/concept.swappable/swappable.cc: Likewise. * testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Prune additional warnings. * testsuite/tr1/3_function_objects/function/1.cc: Avoid -Wcatch-value warning. * testsuite/util/replacement_memory_operators.h: Define sized delete to avoid warnings. * testsuite/util/testsuite_api.h (_NonDefaultConstructible): Add user-declared assignment operator to stop -Wdeprecated-copy warnings. * testsuite/util/testsuite_containers.h: Avoid -Wunused warning. * testsuite/util/testsuite_iterators.h: Avoid -Wsign-compare warnings. * testsuite/util/testsuite_new_operators.h: Define sized deleted.
2020-01-01Update copyright years.Jakub Jelinek605-605/+605
From-SVN: r279813
2019-02-22P0482R5 char8_t: Updates to existing standard library testsTom Honermann1-0/+8
This patch augments existing tests to validate behavior for char8_t. In all cases, added test cases are cloned from existing tests for wchar_t or char16_t. A few tests required updates to line numbers for diagnostic messages. 2019-02-22 Tom Honermann <tom@honermann.net> * testsuite/18_support/byte/ops.cc: Validate std::to_integer<char8_t>, std::to_integer<char16_t>, and std::to_integer<char32_t>. * testsuite/18_support/numeric_limits/dr559.cc: Validate std::numeric_limits<char8_t>. * testsuite/18_support/numeric_limits/lowest.cc: Validate std::numeric_limits<char8_t>::lowest(). * testsuite/18_support/numeric_limits/max_digits10.cc: Validate std::numeric_limits<char8_t>::max_digits10. * testsuite/18_support/type_info/fundamental.cc: Validate typeinfo for char8_t. * testsuite/20_util/from_chars/1_c++20_neg.cc: New test, validating std::from_chars with char8_t. * testsuite/20_util/hash/requirements/explicit_instantiation.cc: Validate explicit instantiation of std::hash<char8_t>. * testsuite/20_util/is_integral/value.cc: Validate std::is_integral<char8_t>. * testsuite/20_util/make_signed/requirements/typedefs-4.cc: Validate std::make_signed<char8_t>. * testsuite/21_strings/basic_string/cons/char/deduction.cc: Validate u8string construction from char8_t sources. * testsuite/21_strings/basic_string/types/pmr_typedefs.cc: Validate std::pmr::u8string. * testsuite/21_strings/basic_string_view/operations/compare/ char/70483.cc: Validate substr operations on u8string_view. * testsuite/21_strings/basic_string_view/typedefs.cc: Validate that the u8string_view typedef is defined. * testsuite/21_strings/char_traits/requirements/ constexpr_functions.cc: Validate char_traits<char8_t> constexpr member functions. * testsuite/21_strings/char_traits/requirements/ constexpr_functions_c++17.cc: Validate char_traits<char8_t> C++17 constexpr member functions. * testsuite/21_strings/headers/string/types_std_c++0x.cc: Validate that the u8string typedef is defined. * testsuite/22_locale/locale/cons/unicode.cc: Validate the presence of the std::codecvt<char16_t, char8_t, std::mbstate_t> and std::codecvt<char32_t, char8_t, std::mbstate_t> facets. * testsuite/29_atomics/atomic/cons/assign_neg.cc: Update line numbers. * testsuite/29_atomics/atomic/cons/copy_neg.cc: Likewise. * testsuite/29_atomics/atomic_integral/cons/assign_neg.cc: Likewise. * testsuite/29_atomics/atomic_integral/cons/copy_neg.cc: Likewise. * testsuite/29_atomics/atomic_integral/is_always_lock_free.cc: Validate std::atomic<char8_t>::is_always_lock_free * testsuite/29_atomics/atomic_integral/operators/bitwise_neg.cc: Update line numbers. * testsuite/29_atomics/atomic_integral/operators/decrement_neg.cc: Likewise. * testsuite/29_atomics/atomic_integral/operators/increment_neg.cc: Likewise. * testsuite/experimental/polymorphic_allocator/pmr_typedefs_string.cc: Validate std::experimental::pmr::u8string. * testsuite/experimental/string_view/typedefs.cc: Validate that the u8string_view typedef is defined. * testsuite/util/testsuite_common_types.h: Add char8_t, char16_t and char32_t to the typelists. From-SVN: r269089
2019-02-19Adjust C++11/C++14 tests to work with -fchar8_tJonathan Wakely7-22/+30
* testsuite/21_strings/basic_string/literals/types.cc [_GLIBCXX_USE_CHAR8_T]: Adjust expected string type for u8 literal. * testsuite/21_strings/basic_string/literals/values.cc [_GLIBCXX_USE_CHAR8_T]: Likewise. * testsuite/22_locale/codecvt/char16_t.cc: Adjust for u8 literals potentially having different type. * testsuite/22_locale/codecvt/char32_t.cc: Likewise. * testsuite/22_locale/codecvt/codecvt_utf8/79980.cc: Cast u8 literal to char. * testsuite/22_locale/codecvt/codecvt_utf8/wchar_t/1.cc: Likewise. * testsuite/22_locale/codecvt/utf8.cc: Likewise. * testsuite/22_locale/conversions/string/2.cc: Remove u8 prefix from string literals only using basic character set. * testsuite/22_locale/conversions/string/3.cc: Likewise. Cast other u8 literals to char. * testsuite/29_atomics/headers/atomic/macros.cc [_GLIBCXX_USE_CHAR8_T]: Test ATOMIC_CHAR8_T_LOCK_FREE. Add missing #error to ATOMIC_CHAR16_T_LOCK_FREE test. * testsuite/29_atomics/headers/atomic/types_std_c++0x.cc [_GLIBCXX_USE_CHAR8_T]: Check for std::atomic_char8_t. * testsuite/experimental/string_view/literals/types.cc [_GLIBCXX_USE_CHAR8_T]: Adjust expected string_view type for u8 literal. * testsuite/experimental/string_view/literals/values.cc [_GLIBCXX_USE_CHAR8_T]: Likewise. From-SVN: r269006
2019-02-19P0482R5 char8_t: New standard library testsTom Honermann3-0/+275
2019-02-19 Tom Honermann <tom@honermann.net> * testsuite/18_support/numeric_limits/char8_t.cc: New test cloned from char16_32_t.cc; validates numeric_limits<char8_t>. * testsuite/21_strings/basic_string/literals/types-char8_t.cc: New test cloned from types.cc; validates operator""s for char8_t returns u8string. * testsuite/21_strings/basic_string/literals/values-char8_t.cc: New test cloned from values.cc; validates construction and comparison of u8string values. * testsuite/21_strings/basic_string/requirements/ /explicit_instantiation/char8_t/1.cc: New test cloned from char16_t/1.cc; validates explicit instantiation of basic_string<char8_t>. * testsuite/21_strings/basic_string_view/literals/types-char8_t.cc: New test cloned from types.cc; validates operator""sv for char8_t returns u8string_view. * testsuite/21_strings/basic_string_view/literals/ values-char8_t.cc: New test cloned from values.cc; validates construction and comparison of u8string_view values. * testsuite/21_strings/basic_string_view/requirements/ explicit_instantiation/char8_t/1.cc: New test cloned from char16_t/1.cc; validates explicit instantiation of basic_string_view<char8_t>. * testsuite/21_strings/char_traits/requirements/char8_t/65049.cc: New test cloned from char16_t/65049.cc; validates that char_traits<char8_t> is not vulnerable to the concerns in PR65049. * testsuite/21_strings/char_traits/requirements/char8_t/ typedefs.cc: New test cloned from char16_t/typedefs.cc; validates that char_traits<char8_t> member typedefs are present and correct. * testsuite/21_strings/char_traits/requirements/ explicit_instantiation/char8_t/1.cc: New test cloned from char16_t/1.cc; validates explicit instantiation of char_traits<char8_t>. * testsuite/22_locale/codecvt/char16_t-char8_t.cc: New test cloned from char16_t.cc: validates codecvt<char16_t, char8_t, mbstate_t>. * testsuite/22_locale/codecvt/char32_t-char8_t.cc: New test cloned from char32_t.cc: validates codecvt<char32_t, char8_t, mbstate_t>. * testsuite/22_locale/codecvt/utf8-char8_t.cc: New test cloned from utf8.cc; validates codecvt<char16_t, char8_t, std::mbstate_t> and codecvt<char32_t, char8_t, std::mbstate_t>. * testsuite/27_io/filesystem/path/native/string-char8_t.cc: New test cloned from string.cc; validates filesystem::path construction from char8_t input. * testsuite/experimental/feat-char8_t.cc: New test; validates that the __cpp_lib_char8_t feature test macro is defined with the correct value. * testsuite/experimental/filesystem/path/native/string-char8_t.cc: New test cloned from string.cc; validates filesystem::path construction from char8_t input. * testsuite/experimental/string_view/literals/types-char8_t.cc: New test cloned from types.cc; validates operator""sv for char8_t returns u8string_view. * testsuite/experimental/string_view/literals/values-char8_t.cc: New test cloned from values.cc; validates construction and comparison of u8string_view values. * testsuite/experimental/string_view/requirements/ explicit_instantiation/char8_t/1.cc: New test cloned from char16_t/1.cc; validates explicit instantiation of basic_string_view<char8_t>. * testsuite/ext/char8_t/atomic-1.cc: New test; validates that ATOMIC_CHAR8_T_LOCK_FREE is not defined if char8_t support is not enabled. From-SVN: r269005
2019-01-03PR libstdc++/88681 export missing symbolsJonathan Wakely3-0/+150
These new facet functions were added to GCC 5.1 but the versions for the old std::string ABI were never exported from the shared library. PR libstdc++/88681 * config/abi/pre/gnu.ver: Add missing exports. * testsuite/22_locale/collate_byname/88681.cc: New test. * testsuite/22_locale/time_get/get/char/88681.cc: New test. * testsuite/22_locale/time_get/get/wchar_t/88681.cc: New test. From-SVN: r267563
2019-01-01Update copyright years.Jakub Jelinek599-599/+599
From-SVN: r267494
2018-10-15Adjust test to pass with latest glibcJonathan Wakely1-2/+4
Glibc changed the it_IT locales to use thousands separators, invalidating this test. Use nl_NL instead, as Dutch only uses grouping for money not numbers. * testsuite/22_locale/numpunct/members/char/3.cc: Adjust test to account for change to glibc it_IT localedata (glibc bz#10797). From-SVN: r265165
2018-08-29PR libstdc++/31413 fix test failure on Debian systemsJonathan Wakely1-1/+23
Debian uses a different D_FMT string for the zh_TW.UTF-8 locale, which caused this test to fail. Try to detect the Debian format and adjust the input being tested. PR libstdc++/31413 * testsuite/22_locale/time_get/get_date/wchar_t/4.cc: Check D_FMT string for alternative format. From-SVN: r263948
2018-07-26Remove dg-require-cstdint directive from testsJonathan Wakely6-6/+0
Tests for components which are no longer dependent on _GLIBCXX_USE_C99_STDINT_TR1 do not need to require <cstdint>. * testsuite/18_support/numeric_limits/char16_32_t.cc: Qualify names from namespace std. * testsuite/20_util/align/2.cc: Remove dg-require-cstdint directive. * testsuite/20_util/duration/arithmetic/1.cc: Likewise. * testsuite/20_util/duration/arithmetic/2.cc: Likewise. * testsuite/20_util/duration/arithmetic/dr2020.cc: Likewise. * testsuite/20_util/duration/arithmetic/dr934-1.cc: Likewise. * testsuite/20_util/duration/arithmetic/dr934-2.cc: Likewise. * testsuite/20_util/duration/comparison_operators/1.cc: Likewise. * testsuite/20_util/duration/cons/1.cc: Likewise. * testsuite/20_util/duration/cons/1_neg.cc: Likewise. * testsuite/20_util/duration/cons/2.cc: Likewise. * testsuite/20_util/duration/cons/54025.cc: Likewise. * testsuite/20_util/duration/cons/dr974_neg.cc: Likewise. * testsuite/20_util/duration/requirements/explicit_instantiation/ explicit_instantiation.cc: Likewise. * testsuite/20_util/duration/requirements/typedefs_neg1.cc: Likewise. * testsuite/20_util/duration/requirements/typedefs_neg2.cc: Likewise. * testsuite/20_util/duration/requirements/typedefs_neg3.cc: Likewise. * testsuite/20_util/make_signed/requirements/typedefs-4.cc: Likewise. * testsuite/20_util/ratio/comparisons/comp1.cc: Likewise. * testsuite/20_util/ratio/comparisons/comp2.cc: Likewise. * testsuite/20_util/ratio/comparisons/comp3.cc: Likewise. * testsuite/20_util/ratio/cons/cons1.cc: Likewise. * testsuite/20_util/ratio/operations/45866.cc: Likewise. * testsuite/20_util/ratio/operations/47913.cc: Likewise. * testsuite/20_util/ratio/operations/53840.cc: Likewise. * testsuite/20_util/ratio/operations/ops1.cc: Likewise. * testsuite/20_util/shared_ptr/atomic/3.cc: Likewise. * testsuite/20_util/system_clock/1.cc: Likewise. * testsuite/20_util/time_point/1.cc: Likewise. * testsuite/20_util/time_point/2.cc: Likewise. * testsuite/20_util/time_point/3.cc: Likewise. * testsuite/20_util/time_point/requirements/explicit_instantiation/ explicit_instantiation.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_view/requirements/ explicit_instantiation/char16_t/1.cc: Likewise. * testsuite/21_strings/basic_string_view/requirements/ explicit_instantiation/char32_t/1.cc: Likewise. * testsuite/21_strings/char_traits/requirements/ explicit_instantiation/char16_t/1.cc: Likewise. * testsuite/21_strings/char_traits/requirements/ explicit_instantiation/char32_t/1.cc: Likewise. * testsuite/21_strings/headers/string/types_std_c++0x.cc: Likewise. * testsuite/22_locale/codecvt/char16_t.cc: Likewise. * testsuite/22_locale/codecvt/char32_t.cc: Likewise. * testsuite/22_locale/codecvt/codecvt_utf16/requirements/1.cc: Likewise. * testsuite/22_locale/codecvt/codecvt_utf8/requirements/1.cc: Likewise. * testsuite/22_locale/codecvt/codecvt_utf8_utf16/requirements/1.cc: Likewise. * testsuite/22_locale/codecvt/utf8.cc: Likewise. * testsuite/23_containers/vector/bool/72847.cc: Likewise. * testsuite/23_containers/vector/debug/multithreaded_swap.cc: Likewise. * testsuite/experimental/string_view/requirements/ explicit_instantiation/char16_t/1.cc: Likewise. * testsuite/experimental/string_view/requirements/ explicit_instantiation/char32_t/1.cc: Likewise. * testsuite/ext/vstring/requirements/explicit_instantiation/char16_t/ 1.cc: Likewise. * testsuite/ext/vstring/requirements/explicit_instantiation/char32_t/ 1.cc: Likewise. From-SVN: r263005
2018-06-14P0935R0 Eradicating unnecessarily explicit default constructorsJonathan Wakely2-0/+11
More pieces of P0935R0, making default constructors non-explicit. * include/backward/strstream (strstreambuf): Add non-explicit default constructor. * include/bits/locale_conv.h (wbuffer_convert, wstring_convert): Likewise. * include/bits/regex.h (match_results): Likewise. * testsuite/22_locale/conversions/buffer/1.cc: Test for non-explicit default constructor. * testsuite/22_locale/conversions/string/1.cc: Likewise. * testsuite/28_regex/match_results/ctors/char/default.cc: Likewise. * testsuite/28_regex/match_results/ctors/wchar_t/default.cc: Likewise. From-SVN: r261597
2018-05-19Fix std::codecvt_utf8<wchar_t> for MingwJonathan Wakely2-3/+54
* src/c++11/codecvt.cc (__codecvt_utf8_base<wchar_t>::do_in) [__SIZEOF_WCHAR_T__==2 && __BYTE_ORDER__!=__ORDER_BIG_ENDIAN__]: Set little_endian element in bitmask. * testsuite/22_locale/codecvt/codecvt_utf8/69703.cc: Run all tests. * testsuite/22_locale/codecvt/codecvt_utf8/wchar_t/1.cc: New. From-SVN: r260389
2018-01-03Update copyright years.Jakub Jelinek598-598/+598
From-SVN: r256169
2017-11-20streambuf_iterator.h (istreambuf_iterator<>): Declare std::advance for ↵François Dumont2-12/+10
istreambuf_iterator of char types to be friend. 2017-11-20 François Dumont <fdumont@gcc.gnu.org> * include/bits/streambuf_iterator.h (istreambuf_iterator<>): Declare std::advance for istreambuf_iterator of char types to be friend. (std::advance(istreambuf_iterator&, _Distance)): New overload. * include/std/streambuf (basic_streambuf<>): Declare std::advance for istreambuf_iterator of char types to be friend. * testsuite/22_locale/money_get/get/char/9.cc: Have istreambuf_iterator created on the fly when calling money_get<>::get. * testsuite/22_locale/money_get/get/wchar_t/9.cc: Likewise. * testsuite/24_iterators/istreambuf_iterator/debug/1_neg.cc: New. * testsuite/24_iterators/istreambuf_iterator/debug/2_neg.cc: New. * testsuite/25_algorithms/advance/istreambuf_iterators/char/1.cc: New. * testsuite/25_algorithms/advance/istreambuf_iterators/char/1_neg.cc: New. * testsuite/25_algorithms/advance/istreambuf_iterators/char/2.cc: New. * testsuite/25_algorithms/advance/istreambuf_iterators/char/2_neg.cc: New. * testsuite/25_algorithms/advance/istreambuf_iterators/char/3_neg.cc: New. * testsuite/25_algorithms/advance/istreambuf_iterators/wchar_t/1.cc: New. * testsuite/25_algorithms/advance/istreambuf_iterators/wchar_t/1_neg.cc: New. * testsuite/25_algorithms/advance/istreambuf_iterators/wchar_t/2.cc: New. * testsuite/25_algorithms/advance/istreambuf_iterators/wchar_t/2_neg.cc: New. * testsuite/25_algorithms/advance/istreambuf_iterators/wchar_t/3_neg.cc: New. * testsuite/25_algorithms/find/istreambuf_iterators/char/2.cc: Leverage on std::advance overload. * testsuite/25_algorithms/find/istreambuf_iterators/wchar_t/2.cc: Likewise. From-SVN: r254972
2017-11-14Fix typo in std::wbuffer_convertJonathan Wakely1-0/+58
* include/bits/locale_conv.h (wbuffer_convert::_M_conv_get): Fix typo. * testsuite/22_locale/conversions/buffer/3.cc: New test. From-SVN: r254735
2017-10-24libstdc++.exp (check_v3_target_normal_mode): Add c++config.h include.François Dumont1-0/+1
2017-10-24 François Dumont <fdumont@gcc.gnu.org> * testsuite/lib/libstdc++.exp (check_v3_target_normal_mode): Add c++config.h include. (check_v3_target_normal_namespace): New. * testsuite/lib/dg-options.exp (dg-require-normal-namespace): New. * testsuite/18_support/headers/limits/synopsis.cc: Add latter. * testsuite/20_util/from_chars/requirements.cc: Likewise. * testsuite/20_util/headers/functional/synopsis.cc: Likewise. * testsuite/20_util/headers/memory/synopsis.cc: Likewise. * testsuite/20_util/headers/utility/synopsis.cc: Likewise. * testsuite/20_util/to_chars/requirements.cc: Likewise. * testsuite/21_strings/headers/string/synopsis.cc: Likewise. * testsuite/22_locale/headers/locale/synopsis.cc: Likewise. * testsuite/23_containers/headers/bitset/synopsis.cc: Likewise. * testsuite/23_containers/headers/deque/synopsis.cc: Likewise. * testsuite/23_containers/headers/forward_list/synopsis.cc: Likewise. * testsuite/23_containers/headers/list/synopsis.cc: Likewise. * testsuite/23_containers/headers/map/synopsis.cc: Likewise. * testsuite/23_containers/headers/queue/synopsis.cc: Likewise. * testsuite/23_containers/headers/set/synopsis.cc: Likewise. * testsuite/23_containers/headers/stack/synopsis.cc: Likewise. * testsuite/23_containers/headers/vector/synopsis.cc: Likewise. * testsuite/23_containers/map/modifiers/erase/abi_tag.cc: Likewise. * testsuite/23_containers/multimap/modifiers/erase/abi_tag.cc: Likewise. * testsuite/23_containers/multiset/modifiers/erase/abi_tag.cc: Likewise. * testsuite/23_containers/set/modifiers/erase/abi_tag.cc: Likewise. * testsuite/24_iterators/headers/iterator/synopsis.cc: Likewise. * testsuite/24_iterators/headers/iterator/synopsis_c++11.cc: Likewise. * testsuite/24_iterators/headers/iterator/synopsis_c++14.cc: Likewise. * testsuite/24_iterators/headers/iterator/synopsis_c++17.cc: Likewise. * testsuite/26_numerics/complex/abi_tag.cc: Likewise. * testsuite/26_numerics/headers/complex/synopsis.cc: Likewise. * testsuite/26_numerics/headers/valarray/synopsis.cc: Likewise. * testsuite/27_io/headers/fstream/synopsis.cc: Likewise. * testsuite/27_io/headers/ios/synopsis.cc: Likewise. * testsuite/27_io/headers/istream/synopsis.cc: Likewise. * testsuite/27_io/headers/ostream/synopsis.cc: Likewise. * testsuite/27_io/headers/sstream/synopsis.cc: Likewise. * testsuite/27_io/headers/streambuf/synopsis.cc: Likewise. From-SVN: r254060
2017-09-2722131.cc: Make test less istreambuf_iterator implementation dependent.François Dumont2-2/+2
2017-09-27 François Dumont <fdumont@gcc.gnu.org> * testsuite/22_locale/money_get/get/char/22131.cc: Make test less istreambuf_iterator implementation dependent. * testsuite/22_locale/money_get/get/wchar_t/22131.cc: Likewise. From-SVN: r253237
2017-07-06Fix memory leaks in libstdc++ testsJonathan Wakely1-50/+5
* testsuite/20_util/specialized_algorithms/memory_management_tools/ 1.cc: Free memory. * testsuite/22_locale/locale/cons/5.cc: Remove redundant restoration of original environment and free memory. From-SVN: r250021
2017-06-17Get rid of dg-skip-if etc. default argsRainer Orth9-9/+9
libstdc++-v3: * testsuite: Remove dg-skip-if, dg-xfail-if, dg-xfail-run-if default args. libgomp: * testsuite/libgomp.fortran/strassen.f90: Remove dg-skip-if default args. * testsuite/libgomp.oacc-c-c++-common/vprop.c: Remove dg-xfail-run-if default args. gcc/testsuite: Remove dg-skip-if, dg-xfail-if, dg-xfail-run-if default args. From-SVN: r249339
2017-06-16Fix std::wbuffer_convert::sync()Jonathan Wakely1-0/+39
* include/bits/locale_conv.h (wbuffer_convert::sync): Fix condition. * testsuite/22_locale/conversions/buffer/2.cc: New. From-SVN: r249255
2017-06-15Use pthread effective-target in testsuiteRainer Orth2-4/+6
* testsuite: Add dg-require-effective-target pthread to -pthread tests. Remove explicit target lists from dg-do and dg-options. * testsuite/30_threads/async/forced_unwind.cc: Remove explit target list from dg-options. * testsuite/30_threads/packaged_task/forced_unwind.cc: Likewise. * 30_threads/shared_mutex/cons/1.cc: Likewise. Pass -pthread for all targets. * 30_threads/shared_mutex/try_lock/1.cc: Likewise. * 30_threads/shared_mutex/try_lock/2.cc: Likewise. * 30_threads/shared_mutex/unlock/1.cc: Likewise. * testsuite/30_threads/this_thread/57060.cc: Require c++11 via dg-require-effective-target. From-SVN: r249217
2017-03-17Fix alignment bugs in std::codecvt_utf16Jonathan Wakely2-0/+316
* src/c++11/codecvt.cc (range): Add non-type template parameter and define oerloaded operators for reading and writing code units. (range<Elem, false>): Define partial specialization for accessing wide characters in potentially unaligned byte ranges. (ucs2_span(const char16_t*, const char16_t*, ...)) (ucs4_span(const char16_t*, const char16_t*, ...)): Change parameters to range<const char16_t, false> in order to avoid unaligned reads. (__codecvt_utf16_base<char16_t>::do_out) (__codecvt_utf16_base<char32_t>::do_out) (__codecvt_utf16_base<wchar_t>::do_out): Use range specialization for unaligned data to avoid unaligned writes. (__codecvt_utf16_base<char16_t>::do_in) (__codecvt_utf16_base<char32_t>::do_in) (__codecvt_utf16_base<wchar_t>::do_in): Likewise for writes. Return error if there are unprocessable trailing bytes. (__codecvt_utf16_base<char16_t>::do_length) (__codecvt_utf16_base<char32_t>::do_length) (__codecvt_utf16_base<wchar_t>::do_length): Pass arguments of type range<const char16_t, false> to span functions. * testsuite/22_locale/codecvt/codecvt_utf16/misaligned.cc: New test. From-SVN: r246245
2017-03-16PR libstdc++/80041 fix codecvt_utf16<wchar_t> to use UTF-16 not UTF-8Jonathan Wakely1-0/+87
PR libstdc++/80041 * src/c++11/codecvt.cc (__codecvt_utf16_base<wchar_t>::do_out) (__codecvt_utf16_base<wchar_t>::do_in): Convert char arguments to char16_t to work with UTF-16 instead of UTF-8. * testsuite/22_locale/codecvt/codecvt_utf16/80041.cc: New test. From-SVN: r246202
2017-03-16Fix encoding() and max_length() values for codecvt facetsJonathan Wakely4-1/+239
* src/c++11/codecvt.cc (codecvt<char16_t, char, mbstate_t>) (codecvt<char32_t, char, mbstate_t>, __codecvt_utf8_base<char16_t>) (__codecvt_utf8_base<char32_t>, __codecvt_utf8_base<wchar_t>) (__codecvt_utf16_base<char16_t>, __codecvt_utf16_base<char32_t>) (__codecvt_utf16_base<wchar_t>, __codecvt_utf8_utf16_base<char16_t>) (__codecvt_utf8_utf16_base<char32_t>) (__codecvt_utf8_utf16_base<wchar_t>): Fix do_encoding() and do_max_length() return values. * testsuite/22_locale/codecvt/codecvt_utf16/members.cc: New test. * testsuite/22_locale/codecvt/codecvt_utf8/members.cc: New test. * testsuite/22_locale/codecvt/codecvt_utf8_utf16/members.cc: New test. From-SVN: r246201
2017-03-16PR libstdc++/79980 fix BOM detection, maxcode checks, UCS2 handlingJonathan Wakely2-0/+209
PR libstdc++/79980 * include/bits/locale_conv.h (__do_str_codecvt): Set __count on error path. * src/c++11/codecvt.cc (operator&=, operator|=, operator~): Overloads for manipulating codecvt_mode values. (read_utf16_bom): Compare input to BOM constants instead of integral constants that depend on endianness. Take mode parameter by reference and adjust it, to distinguish between no BOM present and UTF-16BE BOM present. (ucs4_in, ucs2_span, ucs4_span): Adjust calls to read_utf16_bom. (surrogates): New enumeration type. (utf16_in, utf16_out): Add surrogates parameter to choose between UTF-16 and UCS2 behaviour. (utf16_span, ucs2_span): Use std::min not std::max. (ucs2_out): Use std::min not std::max. Disallow surrogate pairs. (ucs2_in): Likewise. Adjust calls to read_utf16_bom. * testsuite/22_locale/codecvt/codecvt_utf16/79980.cc: New test. * testsuite/22_locale/codecvt/codecvt_utf8/79980.cc: New test. From-SVN: r246200