summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/constexpr.cc
AgeCommit message (Collapse)Author
2024-02-12libstdc++: Fix constexpr basic_string union member [PR113294]Paul Keir
A call to `basic_string::clear()` in the std::string move assignment operator leads to a constexpr error from an access of inactive union member `_M_local_buf` in the added test (`test_move()`). Changing `__str._M_local_buf` to `__str._M_use_local_data()` in `operator=(basic_string&& __str)` fixes this. PR libstdc++/113294 libstdc++-v3/ChangeLog: * include/bits/basic_string.h (basic_string::operator=): Use _M_use_local_data() instead of _M_local_buf on the moved-from string. * testsuite/21_strings/basic_string/modifiers/constexpr.cc (test_move): New test. Signed-off-by: Paul Keir <paul.keir@uws.ac.uk> Reviewed-by: Patrick Palka <ppalka@redhat.com> Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2023-09-16libstdc++: Remove dg-options "-std=gnu++20" from 21_strings testsJonathan Wakely
The testsuite will automatically select C++20 for these tests now, and removing the hardcoded -std option allows them to be tested for C++23 and C++26 as well. libstdc++-v3/ChangeLog: * testsuite/21_strings/basic_string/cons/char/105995.cc: Remove dg-options -std=gnu++20. * testsuite/21_strings/basic_string/cons/char/constexpr.cc: Likewise. * testsuite/21_strings/basic_string/cons/wchar_t/constexpr.cc: Likewise. * testsuite/21_strings/basic_string/erasure.cc: Likewise. * testsuite/21_strings/basic_string/hash/hash_char8_t.cc: Likewise. * testsuite/21_strings/basic_string/literals/constexpr.cc: Likewise. * testsuite/21_strings/basic_string/modifiers/constexpr.cc: Likewise. * testsuite/21_strings/basic_string/modifiers/swap/constexpr-wchar_t.cc: Likewise. * testsuite/21_strings/basic_string/modifiers/swap/constexpr.cc: Likewise. * testsuite/21_strings/basic_string/operations/ends_with/char.cc: Likewise. * testsuite/21_strings/basic_string/operations/ends_with/nonnull.cc: Likewise. * testsuite/21_strings/basic_string/operations/ends_with/wchar_t.cc: Likewise. * testsuite/21_strings/basic_string/operations/starts_with/char.cc: Likewise. * testsuite/21_strings/basic_string/operations/starts_with/nonnull.cc: Likewise. * testsuite/21_strings/basic_string/operations/starts_with/wchar_t.cc: Likewise. * testsuite/21_strings/basic_string/operators/char/cmp_c++20.cc: Likewise. * testsuite/21_strings/basic_string/operators/wchar_t/cmp_c++20.cc: Likewise. * testsuite/21_strings/basic_string_view/cons/char/range.cc: Likewise. * testsuite/21_strings/basic_string_view/operations/copy/char/constexpr.cc: Likewise. * testsuite/21_strings/basic_string_view/operations/copy/wchar_t/constexpr.cc: Likewise. * testsuite/21_strings/basic_string_view/operations/ends_with/char.cc: Likewise. * testsuite/21_strings/basic_string_view/operations/ends_with/nonnull.cc: Likewise. * testsuite/21_strings/basic_string_view/operations/ends_with/wchar_t.cc: Likewise. * testsuite/21_strings/basic_string_view/operations/starts_with/char.cc: Likewise. * testsuite/21_strings/basic_string_view/operations/starts_with/nonnull.cc: Likewise. * testsuite/21_strings/basic_string_view/operations/starts_with/wchar_t.cc: Likewise. * testsuite/21_strings/basic_string_view/operators/char/cmp_c++20.cc: Likewise. * testsuite/21_strings/basic_string_view/operators/wchar_t/cmp_c++20.cc: Likewise. * testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc: Likewise. * testsuite/21_strings/char_traits/requirements/constexpr_functions_c++20.cc: Likewise.
2021-11-24libstdc++: Replace hyphens in effective target keywordsJonathan Wakely
An effective target like foo-bar-baz will match a target selector of *-*-* and cause problems in the testsuite. Several libstdc++ et keywords are of the form foo-bar, which could still be a problem for *-* selectors. Replace hyphens with underscores in the et keywords "debug-mode", "cxx11-abi", etc. libstdc++-v3/ChangeLog: * testsuite/lib/libstdc++.exp: Rename effective target keywords to avoid dashes in the name. * testsuite/*: Update effective targe keywords.
2021-11-16libstdc++: Fix tests for constexpr std::stringJonathan Wakely
Some tests fail when run with -D_GLIBCXX_USE_CXX11_ABI or -stdgnu++20. libstdc++-v3/ChangeLog: * include/bits/basic_string.h (operator<=>): Use constexpr unconditionally. * testsuite/21_strings/basic_string/modifiers/constexpr.cc: Require cxx11-abit effective target. * testsuite/21_strings/headers/string/synopsis.cc: Add conditional constexpr to declarations, and adjust relational operators for C++20.
2021-11-16libstdc++: Implement constexpr std::basic_string for C++20Michael de Lang
This is only supported for the cxx11 ABI, not for COW strings. libstdc++-v3/ChangeLog: * include/bits/basic_string.h (basic_string, operator""s): Add constexpr for C++20. (basic_string::basic_string(basic_string&&)): Only copy initialized portion of the buffer. (basic_string::basic_string(basic_string&&, const Alloc&)): Likewise. * include/bits/basic_string.tcc (basic_string): Add constexpr for C++20. (basic_string::swap(basic_string&)): Only copy initialized portions of the buffers. (basic_string::_M_replace): Add constexpr implementation that doesn't depend on pointer comparisons. * include/bits/cow_string.h: Adjust comment. * include/ext/type_traits.h (__is_null_pointer): Add constexpr. * include/std/string (erase, erase_if): Add constexpr. * include/std/version (__cpp_lib_constexpr_string): Update value. * testsuite/21_strings/basic_string/cons/char/constexpr.cc: New test. * testsuite/21_strings/basic_string/cons/wchar_t/constexpr.cc: New test. * testsuite/21_strings/basic_string/literals/constexpr.cc: New test. * testsuite/21_strings/basic_string/modifiers/constexpr.cc: New test. * testsuite/21_strings/basic_string/modifiers/swap/char/constexpr.cc: New test. * testsuite/21_strings/basic_string/modifiers/swap/wchar_t/constexpr.cc: New test. * testsuite/21_strings/basic_string/version.cc: New test.