summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
AgeCommit message (Collapse)Author
2022-08-04libstdc++: Make std::string_view(Range&&) constructor explicitlinaro-local/ci/tcwg_bmk_llvm_fx/llvm-master-aarch64-cpu2017-O2Jonathan Wakely
The P2499R0 paper was recently approved for C++23. libstdc++-v3/ChangeLog: * include/std/string_view (basic_string_view(Range&&)): Add explicit as per P2499R0. * testsuite/21_strings/basic_string_view/cons/char/range_c++20.cc: Adjust implicit conversions. Check implicit conversions fail. * testsuite/21_strings/basic_string_view/cons/wchar_t/range_c++20.cc: Likewise.
2022-08-04libstdc++: Add comparisons to std::default_sentinel_t (LWG 3719)Jonathan Wakely
This library defect was recently approved for C++23. libstdc++-v3/ChangeLog: * include/bits/fs_dir.h (directory_iterator): Add comparison with std::default_sentinel_t. Remove redundant operator!= for C++20. * (recursive_directory_iterator): Likewise. * include/bits/iterator_concepts.h [!__cpp_lib_concepts] (default_sentinel_t, default_sentinel): Define even if concepts are not supported. * include/bits/regex.h (regex_iterator): Add comparison with std::default_sentinel_t. Remove redundant operator!= for C++20. (regex_token_iterator): Likewise. (regex_token_iterator::_M_end_of_seq()): Add noexcept. * testsuite/27_io/filesystem/iterators/lwg3719.cc: New test. * testsuite/28_regex/iterators/regex_iterator/lwg3719.cc: New test. * testsuite/28_regex/iterators/regex_token_iterator/lwg3719.cc: New test.
2022-08-04libstdc++: Update value of __cpp_lib_ios_noreplace macroJonathan Wakely
My P2467R1 proposal was accepted for C++23 so there's an official value for this macro now. libstdc++-v3/ChangeLog: * include/bits/ios_base.h (__cpp_lib_ios_noreplace): Update value to 202207L. * include/std/version (__cpp_lib_ios_noreplace): Likewise. * testsuite/27_io/basic_ofstream/open/char/noreplace.cc: Check for new value. * testsuite/27_io/basic_ofstream/open/wchar_t/noreplace.cc: Likewise.
2022-07-20libstdc++: Fix std::common_iterator triviality [PR100823]Jonathan Wakely
This fixes the remaining problem reported in the PR, that the special members should be trivial. This can be done by constraining the non-trivial versions and adding defaulted overloads that will be used when the union members are trivial. Making these members trivial alters the argument passing ABI and so isn't suitable for backporting to release branches. libstdc++-v3/ChangeLog: PR libstdc++/100823 * include/bits/stl_iterator.h (common_iterator): Define destructor, copy constructor and move constructor as trivial when the underlying types allow. * testsuite/24_iterators/common_iterator/100823.cc: Check triviality of special members.
2022-07-20libstdc++: Fix std::common_iterator assignment [PR100823]Jonathan Wakely
This fixes the following conformance problems reported in the PR: - Move constructor and move assignment should be defined. - Copy assignment from a valueless object should be allowed. Assignment is completely rewritten by this patch, as the previous version had a number of problems. The converting assignment failed to handle the case of assigning a new value to a valueless object, which should work. It only accepted lvalue arguments, so wasn't usable to implement the move assignment operator. Finally, it enforced the precondition that the argument is not valueless, which is correct for the converting assignment but not for the copy assignment. A new _M_assign member is added to handle all cases of assignment (copying from an lvalue, moving from an rvalue, and converting from a different type). The not valueless precondition is checked in the converting assignment before calling _M_assign, so isn't enforced for copy and move assignment. The new function no longer uses a switch, so handles valueless objects as the LHS or RHS of the assignment. libstdc++-v3/ChangeLog: PR libstdc++/100823 * include/bits/stl_iterator.h (common_iterator): Define move constructor and move assignment operator. (common_iterator::_M_assign): New function implementing assignment. (common_iterator::operator=): Use _M_assign. (common_iterator::_S_valueless): New constant. * testsuite/24_iterators/common_iterator/100823.cc: New test.
2022-07-20libstdc++: Fix minor bugs in std::common_iteratorJonathan Wakely
The noexcept-specifier for some std::common_iterator constructors was incorrectly using an rvalue as the first argument of std::is_nothrow_assignable_v. This gave the wrong answer for some types, e.g. std::common_iterator<int*, S>, because an rvalue of scalar type cannot be assigned to. Also fix the friend declaration to use the same constraints as on the definition of the class template. G++ fails to diagnose this error, due to PR c++/96830. Finally, the copy constructor was using std::move for its argument in some cases, which should be removed. libstdc++-v3/ChangeLog: * include/bits/stl_iterator.h (common_iterator): Fix incorrect uses of is_nothrow_assignable_v. Fix inconsistent constraints on friend declaration. Do not move argument in copy constructor. * testsuite/24_iterators/common_iterator/1.cc: Check for noexcept constructibnle/assignable.
2022-07-19libstdc++: Complete __gnu_debug::string Standard conformityFrançois Dumont
Add testsuite/testsuite_string.h header to help testing __gnu_debug::basic_string like std::basic_string depending on _GLIBCXX_DEBUG. Add using of base type methods in __gnu_debug::basic_string to make use of the method overloads when there is no debug version. Fix _GLIBCXX_DEBUG_PEDANTIC assertions in <debug/string>. This header has to be used directly like __gnu_debug::string, it is not included by _GLIBCXX_DEBUG. It means that _GLIBCXX_DEBUG_PEDANTIC is not considered to define __glibcxx_check_string and __glibcxx_check_string_len which are then empty macros. Now those macros are defined directly in <debug/string> and properly consider _GLIBCXX_DEBUG_PEDANTIC. libstdc++-v3/ChangeLog: * include/debug/debug.h [_GLIBCXX_DEBUG](__glibcxx_requires_string): Define using _GLIBCXX_DEBUG_PEDASSERT. [_GLIBCXX_DEBUG](__glibcxx_requires_string_len): Likewise. * include/debug/macros.h (__glibcxx_check_string, __glibcxx_check_string_len): Move... * include/debug/string (__glibcxx_check_string, __glibcxx_check_string_len): ...here. And define depending on _GLIBCXX_DEBUG_PEDANTIC no matter if _GLIBCXX_DEBUG is defined. Add using of std::string find, rfind, find_first_of, find_last_of, find_first_not_of and find_last_not_of. Remove debug implementations having no debug assertion. * testsuite/util/testsuite_string.h: New file. Provides __gnu_test::string and __gnu_test::wtring which definition depends on _GLIBCXX_DEBUG. * testsuite/21_strings/basic_string/debug/find1_neg.cc: New test case. * testsuite/21_strings/basic_string/debug/find2_neg.cc: New test case. * testsuite/21_strings/basic_string/operations/find/char/1.cc: Include <testsuite_string.h> and use __gnu_test::string. * testsuite/21_strings/basic_string/operations/find/char/2.cc: Likewise. * testsuite/21_strings/basic_string/operations/find/char/3.cc: Likewise. * testsuite/21_strings/basic_string/operations/find/char/4.cc: Likewise. * testsuite/21_strings/basic_string/operations/find/char/5.cc: Likewise. * testsuite/21_strings/basic_string/operations/find/char/6.cc: Likewise. * testsuite/21_strings/basic_string/operations/find/wchar_t/1.cc: Include <testsuite_string.h> and use __gnu_test::wstring. * testsuite/21_strings/basic_string/operations/find/wchar_t/2.cc: Likewise. * testsuite/21_strings/basic_string/operations/find/wchar_t/3.cc: Likewise. * testsuite/21_strings/basic_string/operations/find/wchar_t/4.cc: Likewise. * testsuite/21_strings/basic_string/operations/find/wchar_t/5.cc: Likewise. * testsuite/21_strings/basic_string/operations/find/wchar_t/6.cc: Likewise.
2022-07-15c++: Add __reference_con{struc,ver}ts_from_temporary [PR104477]Marek Polacek
This patch implements C++23 P2255R2, which adds two new type traits to detect reference binding to a temporary. They can be used to detect code like std::tuple<const std::string&> t("meow"); which is incorrect because it always creates a dangling reference, because the std::string temporary is created inside the selected constructor of std::tuple, and not outside it. There are two new compiler builtins, __reference_constructs_from_temporary and __reference_converts_from_temporary. The former is used to simulate direct- and the latter copy-initialization context. But I had a hard time finding a test where there's actually a difference. Under DR 2267, both of these are invalid: struct A { } a; struct B { explicit B(const A&); }; const B &b1{a}; const B &b2(a); so I had to peruse [over.match.ref], and eventually realized that the difference can be seen here: struct G { operator int(); // #1 explicit operator int&&(); // #2 }; int&& r1(G{}); // use #2 (no temporary) int&& r2 = G{}; // use #1 (a temporary is created to be bound to int&&) The implementation itself was rather straightforward because we already have the conv_binds_ref_to_prvalue function. The main function here is ref_xes_from_temporary. I've changed the return type of ref_conv_binds_directly to tristate, because previously the function didn't distinguish between an invalid conversion and one that binds to a prvalue. Since it no longer returns a bool, I removed the _p suffix. The patch also adds the relevant class and variable templates to <type_traits>. PR c++/104477 gcc/c-family/ChangeLog: * c-common.cc (c_common_reswords): Add __reference_constructs_from_temporary and __reference_converts_from_temporary. * c-common.h (enum rid): Add RID_REF_CONSTRUCTS_FROM_TEMPORARY and RID_REF_CONVERTS_FROM_TEMPORARY. gcc/cp/ChangeLog: * call.cc (ref_conv_binds_directly_p): Rename to ... (ref_conv_binds_directly): ... this. Add a new bool parameter. Change the return type to tristate. * constraint.cc (diagnose_trait_expr): Handle CPTK_REF_CONSTRUCTS_FROM_TEMPORARY and CPTK_REF_CONVERTS_FROM_TEMPORARY. * cp-tree.h: Include "tristate.h". (enum cp_trait_kind): Add CPTK_REF_CONSTRUCTS_FROM_TEMPORARY and CPTK_REF_CONVERTS_FROM_TEMPORARY. (ref_conv_binds_directly_p): Rename to ... (ref_conv_binds_directly): ... this. (ref_xes_from_temporary): Declare. * cxx-pretty-print.cc (pp_cxx_trait_expression): Handle CPTK_REF_CONSTRUCTS_FROM_TEMPORARY and CPTK_REF_CONVERTS_FROM_TEMPORARY. * method.cc (ref_xes_from_temporary): New. * parser.cc (cp_parser_primary_expression): Handle RID_REF_CONSTRUCTS_FROM_TEMPORARY and RID_REF_CONVERTS_FROM_TEMPORARY. (cp_parser_trait_expr): Likewise. (warn_for_range_copy): Adjust to call ref_conv_binds_directly. * semantics.cc (trait_expr_value): Handle CPTK_REF_CONSTRUCTS_FROM_TEMPORARY and CPTK_REF_CONVERTS_FROM_TEMPORARY. (finish_trait_expr): Likewise. libstdc++-v3/ChangeLog: * include/std/type_traits (reference_constructs_from_temporary, reference_converts_from_temporary): New class templates. (reference_constructs_from_temporary_v, reference_converts_from_temporary_v): New variable templates. (__cpp_lib_reference_from_temporary): Define for C++23. * include/std/version (__cpp_lib_reference_from_temporary): Define for C++23. * testsuite/20_util/variable_templates_for_traits.cc: Test reference_constructs_from_temporary_v and reference_converts_from_temporary_v. * testsuite/20_util/reference_from_temporary/value.cc: New test. * testsuite/20_util/reference_from_temporary/value2.cc: New test. * testsuite/20_util/reference_from_temporary/version.cc: New test. gcc/testsuite/ChangeLog: * g++.dg/ext/reference_constructs_from_temporary1.C: New test. * g++.dg/ext/reference_converts_from_temporary1.C: New test.
2022-07-12libstdc++: Check for EOF if extraction avoids buffer overflow [PR106248]Jonathan Wakely
In r11-2581-g17abcc77341584 (for LWG 2499) I added overflow checks to the pre-C++20 operator>>(istream&, char*) overload. Those checks can cause extraction to stop after filling the buffer, where previously it would have tried to extract another character and stopped at EOF. When that happens we no longer set eofbit in the stream state, which is consistent with the behaviour of the new C++20 overload, but is an observable and unexpected change in the C++17 behaviour. What makes it worse is that the behaviour change is dependent on optimization, because __builtin_object_size is used to detect the buffer size and that only works when optimizing. To avoid the unexpected and optimization-dependent change in behaviour, set eofbit manually if we stopped extracting because of the buffer size check, but had reached EOF anyway. If the stream's rdstate() != goodbit or width() is non-zero and smaller than the buffer, there's nothing to do. Otherwise, we filled the buffer and need to check for EOF, and maybe set eofbit. The new check is guarded by #ifdef __OPTIMIZE__ because otherwise __builtin_object_size is useless. There's no point compiling and emitting dead code that can't be eliminated because we're not optimizing. We could add extra checks that the next character in the buffer is not whitespace, to detect the case where we stopped early and prevented a buffer overflow that would have happened otherwise. That would allow us to assert or set badbit in the stream state when undefined behaviour was prevented. However, those extra checks would increase the size of the function, potentially reducing the likelihood of it being inlined, and so making the buffer size detection less reliable. It seems preferable to prevent UB and silently truncate, rather than miss the UB and allow the overflow to happen. libstdc++-v3/ChangeLog: PR libstdc++/106248 * include/std/istream [C++17] (operator>>(istream&, char*)): Set eofbit if we stopped extracting at EOF. * testsuite/27_io/basic_istream/extractors_character/char/pr106248.cc: New test. * testsuite/27_io/basic_istream/extractors_character/wchar_t/pr106248.cc: New test.
2022-07-05libstdc++: testsuite: why cast getpid resultAlexandre Oliva
Add a comment next to the getpid call to explain why the typecast is needed. for libstdc++-v3/ChangeLog * testsuite/util/testsuite_fs.h (nonexistent_path): Explain why we need the typecast.
2022-07-05libstdc++: testsuite: cast getpid resultAlexandre Oliva
On vxworks, in kernel mode, getpid's return type is a pointer type, so std::to_string on it fails overload resolution. Restore the type cast from the original patch that suggested adding the pid. for libstdc++-v3/ChangeLog * testsuite/util/testsuite_fs.h (nonexistent_path): Convert the getpid result to an integral type.
2022-07-01libstdc++: Add nodiscard attribute to filesystem operationsJonathan Wakely
Some of these are not truly "pure" because they access the file system, e.g. exists and file_size, but they do not modify anything and are only useful for the return value. If you really want to use one of those functions just to check whether an error is reported (either via an exception or an error_code& argument) you can still do so, but you need to cast the discarded result to void. Several tests need such a change, because they were indeed only calling the functions to check for expected errors. libstdc++-v3/ChangeLog: * include/bits/fs_ops.h: Add nodiscard to all pure functions. * include/experimental/bits/fs_ops.h: Likewise. * testsuite/27_io/filesystem/operations/all.cc: Do not discard results of absolute and canonical. * testsuite/27_io/filesystem/operations/absolute.cc: Cast discarded result to void. * testsuite/27_io/filesystem/operations/canonical.cc: Likewise. * testsuite/27_io/filesystem/operations/exists.cc: Likewise. * testsuite/27_io/filesystem/operations/is_empty.cc: Likewise. * testsuite/27_io/filesystem/operations/read_symlink.cc: Likewise. * testsuite/27_io/filesystem/operations/status.cc: Likewise. * testsuite/27_io/filesystem/operations/symlink_status.cc: Likewise. * testsuite/27_io/filesystem/operations/temp_directory_path.cc: Likewise. * testsuite/experimental/filesystem/operations/canonical.cc: Likewise. * testsuite/experimental/filesystem/operations/exists.cc: Likewise. * testsuite/experimental/filesystem/operations/is_empty.cc: Likewise. * testsuite/experimental/filesystem/operations/read_symlink.cc: Likewise. * testsuite/experimental/filesystem/operations/temp_directory_path.cc: Likewise.
2022-06-30libstdc++: Improve exceptions thrown from fs::temp_directory_pathJonathan Wakely
Currently the throwing overload of fs::temp_directory_path() will discard the path that was obtained from the environment. When it fails because the path doesn't resolve to a directory you get an unhelpful error like: filesystem error: temp_directory_path: Not a directory It would be better to also print the path in that case, e.g. filesystem error: temp_directory_path: Not a directory [/home/bob/tmp] libstdc++-v3/ChangeLog: * src/c++17/fs_ops.cc (fs::temp_directory_path()): Include path in exception. (fs::temp_directory_path(error_code&)): Rearrange to more closely match the structure of the first overload. * src/filesystem/ops.cc (fs::temp_directory_path): Likewise. * testsuite/27_io/filesystem/operations/temp_directory_path.cc: Check that exception contains the path. * testsuite/experimental/filesystem/operations/temp_directory_path.cc: Likewise.
2022-06-30libstdc++: Fix experimental::filesystem::status on Windows [PR88881]Jonathan Wakely
Although the Filesystem TS isn't properly supported on Windows (unlike the C++17 Filesystem lib), most tests do pass. Two of the failures are due to PR 88881 which was only fixed for std::filesystem not the TS. This applies the fix to the TS implementation too. libstdc++-v3/ChangeLog: PR libstdc++/88881 * src/filesystem/ops.cc (has_trailing_slash): New helper function. (fs::status): Strip trailing slashes. (fs::symlink_status): Likewise. * testsuite/experimental/filesystem/operations/temp_directory_path.cc: Clean the environment before each test and use TMP instead of TMPDIR so the test passes on Windows.
2022-06-28libstdc++: testsuite: Guard use of C99 std::log2Jonathan Wakely
This prevents the test from failing if the only thing not supported is the text printed to the log about the size of the floating-point type. libstdc++-v3/ChangeLog: * testsuite/20_util/from_chars/4.cc: Only use log2 if C99 math functions are available.
2022-06-27libstdc++: testsuite: use cmath long double overloadsAlexandre Oliva
In case we need to supplement the C standard library with additional definitions for float and long double, the declarations expected to be in the C headers may not be there. Rely on the cmath overloads instead. for libstdc++-v3/ChangeLog * testsuite/20_util/to_chars/long_double.cc: Use cmath long double overloads for nexttoward and ldexp.
2022-06-27libstdc++: testsuite: require cmath for exp simdAlexandre Oliva
simd_math.h assumes declarations for many C99 functions to be present, that libstdc++ doesn't add to target systems that don't have them in the C library. Add the C99 math requirement to tests for simd features, so that they don't fail because of limitations of the target C library. for libstdc++-v3/ChangeLog * testsuite/experimental/simd/standard_abi_usable.cc: Require cmath support. * testsuite/experimental/simd/standard_abi_usable_2.cc: Likewise.
2022-06-27libstdc++: testsuite: complex proj requirementsAlexandre Oliva
The template version of complex::proj returns its argument without testing for infinities, and that's all we have when neither C99 complex nor C99 math functions are available, and it seems too hard to do better without isinf and copysign. I suppose just calling them and expecting users will supply specializations as needed has been ruled out, and so has refraining from defining it when it can't be implemented correctly. It's pointless to run the proj.cc test under these circumstances, so arrange for it to be skipped. In an unusual way, after trying to introduce dg-require tests for ccomplex-or-cmath, and found their results to be misleading due to variations across -std=* versions. for libstdc++-v3/ChangeLog * testsuite/26_numerics/complex/proj.cc: Skip test in the circumstances in which the implementation of proj is known to be broken.
2022-06-27libstdc++: testsuite: conditionalize another symlink testAlexandre Oliva
In the recent patch that introduced NO_SYMLINKS, I missed one of the testcases that created symlinks. for libstdc++-v3/ChangeLog * testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc (test06): Don't create symlinks when NO_SYMLINKS is defined.
2022-06-27libstdc++: xfail experimental/net tests on rtemsAlexandre Oliva
Some net/timer/waitable tests fail on rtems because poll() is not available. The above, as well as net/internet/resolver/ops tests and net/timer/waitable/cons.cc, will fail early at runtime unless mkfifo is enabled in the RTEMS configuration, because the io_context ctor throws when pipe() fails. However, even enabling pipes and adjusting the net_ts link command to use --gc-sections for -lbsd as recommended, both net/internet/resolver/ops still fail at runtime. for libstdc++-v3/ChangeLog * testsuite/lib/dg-options.exp (add_options_for_net_ts): Add -Wl,--gc-sections for RTEMS targets. * testsuite/experimental/net/timer/waitable/dest.cc: Link-time xfail on RTEMS. * testsuite/experimental/net/timer/waitable/ops.cc: Likewise. * testsuite/experimental/net/internet/resolver/ops/lookup.cc: Execution-time xfail on RTEMS. * testsuite/experimental/net/internet/resolver/ops/reverse.cc: Likewise.
2022-06-27libstdc++: testsuite: Add missing <string> headerJonathan Wakely
libstdc++-v3/ChangeLog: * testsuite/ext/mt_allocator/22309_thread.cc: Include <string>.
2022-06-27libstdc++: testsuite: avoid predicable mkstempJoel Brobecker
We have noticed that, on RTEMS, a small number of testscases are failing because two calls to this method return the same filename. This happens for instance in 27_io/filesystem/operations/copy_file.cc where it does: auto from = __gnu_test::nonexistent_path(); auto to = __gnu_test::nonexistent_path(); We tracked this issue down to the fact that the implementation of mkstemp on that system appears to use a very predictable algorithm for chosing the name of the temporary file, where the same filename appears to be tried in the same order, regardless of past calls. So, as long as the file gets deleted after a call to mkstemp (something we do here in our nonexistent_path method), the next call to mkstemps ends up returning the same filename, causing the collision we se above. This commit enhances the __gnu_test::nonexistent_path method to introduce in the filename being returned a counter which gets incremented at every call of this method. Co-authored-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * testsuite/util/testsuite_fs.h (__gnu_test::nonexistent_path): Always include a counter in the filename returned.
2022-06-23libstdc++: xfail rename tests on rtemsAlexandre Oliva
::rename on RTEMS does not meet several POSIX requirements, despite compliance with C and C++ standards. ::std::filesystem::rename, in turn, has requirements borrowed from POSIX, so it would have to be a lot more than a simple wrapper around ::rename on RTEMS, and even then fall short. Until RTEMS reimplements ::rename for POSIX compliance, expect filesystem rename tests to fail on it. for libstdc++-v3/ChangeLog * testsuite/27_io/filesystem/operations/rename.cc: xfail on rtems. * testsuite/experimental/filesystem/operations/rename.cc: Likewise.
2022-06-23libstdc++: testsuite: skip fs last_write_time tests if dummyAlexandre Oliva
The last_write_time functions are defined in ways that are useful, or that fail immediately, depending on various macros. When they fail immediately, the filesystem last_write_time.cc tests fail noisily, but the fail is entirely expected. Define NO_LAST_WRITE_TIME in the last_write_time.cc tests, according to the macros that select implementations of last_write_time, and use it through the new dg-require-target-fs-lwt to skip tests that are expected to fail. for libstdc++-v3/ChangeLog * testsuite/util/testsuite_fs.h (NO_LAST_WRITE_TIME): Define when appropriate. * testsuite/lib/libstdc++.exp (check_v3_target_fs_last_write_time): New. * testsuite/lib/dg-options.exp (dg-require-target-fs-lwt): New. * testsuite/27_io/filesystem/operations/last_write_time.cc: Skip the test if the features are unavailable. * testsuite/experimental/filesystem/operations/last_write_time.cc: Likewise.
2022-06-23libstdc++: testsuite: skip fs space tests on dummy implementationsAlexandre Oliva
The do_space function is defined in ways that are useful, or that fail immediately, depending on various macros. When it fails immediately, the filesystem space.cc tests fail noisily, but the fail is entirely expected. Define NO_SPACE in testsuite_fs.h, according to the macros that select implementations of do_space, and use it to skip tests that are expected to fail, through a new dg-require. for libstdc++-v3/ChangeLog * testsuite/util/testsuite_fs.h (NO_SPACE): Define if appropriate. * testsuite/lib/libstdc++.exp (check_v3_target_fs_space): New. * testsuite/lib/dg-options.exp (dg-require-target-fs-space): New. * testsuite/27_io/filesystem/operations/space.cc: Require target-fs-space. * testsuite/experimental/filesystem/operations/space.cc: Likewise.
2022-06-23libstdc++: testsuite: conditionalize symlink testsAlexandre Oliva
Several filesystem tests expect to be able to create symlinks even when !defined (_GLIBCXX_HAVE_SYMLINK), and fail predictably, reducing the amount of testing of other filesystem features. They are already skipped for mingw targets. I've extended the skipping to other targets in which _GLIBCXX_HAVE_SYMLINK is undefined, through a new NO_SYMLINKS macro in testsuite_fs.h that guards skippable portions of tests, and dg-require-target-fs-symlinks for tests that would be reduced to nothing. for libstdc++-v3/ChangeLog * testsuite/util/testsuite_fs.h (NO_SYMLINKS): Define on mingw and when create_symlink is a dummy. * testsuite/27_io/filesystem/operations/symlink_status.cc: Drop mingw xfail. (test01, test02): Don't create symlinks when NO_SYMLINKS is defined. * testsuite/27_io/filesystem/operations/canonical.cc (test03): Likewise. * testsuite/27_io/filesystem/operations/copy.cc (test02): Likewise. * testsuite/27_io/filesystem/operations/create_directories.cc (test04): Likewise. * testsuite/27_io/filesystem/operations/create_directory.cc (test01): Likewise. * testsuite/27_io/filesystem/operations/permissions.cc (test03, test04): Likewise. * testsuite/27_io/filesystem/operations/remove.cc (test01): Likewise. * testsuite/27_io/filesystem/operations/remove_all.cc (test01): Likewise. * testsuite/27_io/filesystem/operations/rename.cc (test_symlinks): Likewise. * testsuite/27_io/filesystem/operations/weakly_canonical.cc (test01): Likewise. * testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc (test06): Likewise. * testsuite/experimental/filesystem/operations/copy.cc (test01): Likewise. * testsuite/experimental/filesystem/operations/create_directories.cc (test04): Likewise. * testsuite/experimental/filesystem/operations/create_directory.cc (test01): Likewise. * testsuite/experimental/filesystem/operations/permissions.cc (test03, test04): Likewise. * testsuite/experimental/filesystem/operations/remove.cc (test01): Likewise. * testsuite/experimental/filesystem/operations/remove_all.cc (test01): Likewise. * testsuite/experimental/filesystem/operations/rename.cc (test01): Likewise. * testsuite/lib/libstdc++.exp (v3_check_preprocessor_condition): Add optional inc parameter. Add it to the test program after include bits/c++config.h. (check_v3_target_fs_symlinks): New. * testsuite/lib/dg-options.exp (dg-require-target-fs-symlinks): New. * testsuite/27_io/filesystem/operations/read_symlink.cc: Replace mingw xfail with require target-fs-symlinks. * testsuite/experimental/filesystem/operations/read_symlink.cc: Likewise.
2022-06-23libstdc++: testsuite: avoid predictable mkstempAlexandre Oliva
This patch was originally meant to reduce the likelihood that nonexistent_path() returns the same pathname for from and to. It was prompted by a target system with a non-random implementation of mkstemp, that returns a predictable sequence of filenames and selects the first one that isn't already taken. That turned out not to be enough: nonexistent_path adds a suffix to the filename chosen by mkstemp and removes the file it created, so mkstemp may very well insist on the same basename, and the case that doesn't use mkstemp doesn't even check whether the file already exists. Anyway, by the time I realized this wasn't enough, I'd already implemented some of the changes, and I figured I might as well contribute them, even though they don't really solve any problem, and even if they did, they'd be just a partial solution. for libstdc++-v3/ChangeLog * testsuite/27_io/filesystem/operations/copy.cc (test02): Select TO after creating FROM. (test03, test04): Likewise. * testsuite/experimental/filesystem/operations/copy.cc (test02, test03, test04): Likewise.
2022-06-23libstdc++: testsuite: tolerate non-cancelling sleepAlexandre Oliva
Though sleep, nanosleep and clock_nanosleep are all POSIX cancellation points, not all target systems follow this POSIX requirement. 30_threads/thread/native_handle/cancel.cc will run until it times out on such systems. Rather than failing a C++ library test because of a limitation of the target system, this patch gives the test a chance to successfully exercise the features it intends to exercise, by introducing a cancellation point in a loop that would otherwise run indefinitely on systems exhibiting this limitation. for libstdc++-v3/ChangeLog * testsuite/30_threads/thread/native_handle/cancel.cc: Add an explicit cancellation point in case sleep_for lacks one.
2022-06-23libstdc++: testsuite: use -lbsd for net_ts on RTEMSAlexandre Oliva
Networking functions that net_ts tests rely on are defined in libbsd on RTEMS, so link with it. for libstdc++-v3/ChangeLog * testsuite/lib/dg-options.exp (add_options_for_net_ts): Add -lbsd for RTEMS targets.
2022-06-23libstdc++: Properly remove temporary directories in filesystem testsJonathan Wakely
Although these tests use filesystem::remove_all to clean up, that fails because it uses recursive_directory_iterator which is intentionally bodged by the custom readdir defined in the test. Just use POSIX rmdir to clean up. We don't need to use _rmdir or _wrmdir for Windows, because we'll never reach test02() on targets where the custom readdir doesn't interpose the one from libc. libstdc++-v3/ChangeLog: * testsuite/27_io/filesystem/iterators/error_reporting.cc: Use rmdir to remove directories. * testsuite/experimental/filesystem/iterators/error_reporting.cc: Likewise.
2022-06-23libstdc++: Simplify test by not using std::log2Jonathan Wakely
This test uses std::log2 without including <cmath>, but it doesn't need to use it at all. Just get the number of digits from numeric_limits instead. libstdc++-v3/ChangeLog: * testsuite/26_numerics/random/random_device/entropy.cc: Use numeric_limits<unsigned>::digits.
2022-06-21libstdc++: testsuite: call sched_yield for nonpreemptive targetsAlexandre Oliva
As in the gcc testsuite, systems without preemptive multi-threading require sched_yield calls to be placed at points in which a context switch might be needed to enable the test to complete. for libstdc++-v3/ChangeLog * testsuite/30_threads/this_thread/60421.cc (test02): Call sched_yield.
2022-06-21libstdc++: testsuite: require cmath for nexttowardlAlexandre Oliva
nexttowardl is only expected to be available with C99 math, but 20_util/to_chars/long_double.cc uses it unconditionally. State the cmath requirement in the test. for libstdc++-v3/ChangeLog * testsuite/20_util/to_chars/long_double.cc: Require cmath.
2022-06-21libstdc++: testsuite: work around bitset namespace pollutionAlexandre Oliva
rtems6 declares a global struct bitset in a header file included indirectly by sys/types.h, that ambiguates the unqualified references to bitset after "using namespace std" in the testsuite. Work around the namespace pollution with using declarations of std::bitset. for libstdc++-v3/ChangeLog * testsuite/23_containers/bitset/cons/dr1325-2.cc: Work around global struct bitset. * testsuite/23_containers/bitset/ext/15361.cc: Likewise. * testsuite/23_containers/bitset/input/1.cc: Likewise. * testsuite/23_containers/bitset/to_string/1.cc: Likewise. * testsuite/23_containers/bitset/to_string/dr396.cc: Likewise.
2022-06-17libstdc++: Add missing #include <string> to new testJonathan Wakely
Somehow I pushed a different version of this test to the one I actually tested. libstdc++-v3/ChangeLog: * testsuite/21_strings/basic_string/cons/char/105995.cc: Add missing #include.
2022-06-16libstdc++: Support constexpr global std::string for size < 15 [PR105995]Jonathan Wakely
I don't think this is required by the standard, but it's easy to support. libstdc++-v3/ChangeLog: PR libstdc++/105995 * include/bits/basic_string.h (_M_use_local_data): Initialize the entire SSO buffer. * testsuite/21_strings/basic_string/cons/char/105995.cc: New test.
2022-06-15libstdc++: [_Hashtable] Insert range of types convertible to value_type PR ↵François Dumont
105717 Fix insertion of range of instances convertible to value_type. libstdc++-v3/ChangeLog: PR libstdc++/105717 * include/bits/hashtable_policy.h (_ConvertToValueType): New. * include/bits/hashtable.h (_Hashtable<>::_M_insert_unique_aux): New. (_Hashtable<>::_M_insert(_Arg&&, const _NodeGenerator&, true_type)): Use latters. (_Hashtable<>::_M_insert(_Arg&&, const _NodeGenerator&, false_type)): Likewise. (_Hashtable(_InputIterator, _InputIterator, size_type, const _Hash&, const _Equal&, const allocator_type&, true_type)): Use this.insert range. (_Hashtable(_InputIterator, _InputIterator, size_type, const _Hash&, const _Equal&, const allocator_type&, false_type)): Use _M_insert. * testsuite/23_containers/unordered_map/cons/56112.cc: Check how many times conversion is done. * testsuite/23_containers/unordered_map/insert/105717.cc: New test. * testsuite/23_containers/unordered_set/insert/105717.cc: New test.
2022-06-14libstdc++: Inline all basic_string::compare overloads [PR59048]Jonathan Wakely
Defining the compare member functions inline allows calls to traits_type::length and std::min to be inlined, taking advantage of constant expression arguments. When not inline, the compiler prefers to use the explicit instantiation definitions in libstdc++.so and can't take advantage of constant arguments. libstdc++-v3/ChangeLog: PR libstdc++/59048 * include/bits/basic_string.h (compare): Define inline. * include/bits/basic_string.tcc (compare): Remove out-of-line definitions. * include/bits/cow_string.h (compare): Define inline. * testsuite/21_strings/basic_string/operations/compare/char/3.cc: New test.
2022-06-14libstdc++: Check for size overflow in constexpr allocation [PR105957]Jonathan Wakely
libstdc++-v3/ChangeLog: PR libstdc++/105957 * include/bits/allocator.h (allocator::allocate): Check for overflow in constexpr allocation. * testsuite/20_util/allocator/105975.cc: New test.
2022-06-13libstdc++: Use type_identity_t for non-deducible std::atomic_xxx argsJonathan Wakely
This is LWG 3220 which is about to become Tentatively Ready. libstdc++-v3/ChangeLog: * include/std/atomic (__atomic_val_t): Use __type_identity_t instead of atomic<T>::value_type, as per LWG 3220. * testsuite/29_atomics/atomic/lwg3220.cc: New test.
2022-06-10libstdc++: Make std::lcm and std::gcd detect overflow [PR105844]Jonathan Wakely
When I fixed PR libstdc++/92978 I introduced a regression whereby std::lcm(INT_MIN, 1) and std::lcm(50000, 49999) would no longer produce errors during constant evaluation. Those calls are undefined, because they violate the preconditions that |m| and the result can be represented in the return type (which is int in both those cases). The regression occurred because __absu<unsigned>(INT_MIN) is well-formed, due to the explicit casts to unsigned in that new helper function, and the out-of-range multiplication is well-formed, because unsigned arithmetic wraps instead of overflowing. To fix 92978 I made std::gcm and std::lcm calculate |m| and |n| immediately, yielding a common unsigned type that was used to calculate the result. That was partly correct, but there's no need to use an unsigned type. Doing so only suppresses the overflow errors so the compiler can't detect them. This change replaces __absu with __abs_r that returns the common type (not its corresponding unsigned type). This way we can detect overflow in __abs_r when required, while still supporting the most-negative value when it can be represented in the result type. To detect LCM results that are out of range of the result type we still need explicit checks, because neither constant evaluation nor UBsan will complain about unsigned wrapping for cases such as std::lcm(500000u, 499999u). We can detect those overflows efficiently by using __builtin_mul_overflow and asserting. libstdc++-v3/ChangeLog: PR libstdc++/105844 * include/experimental/numeric (experimental::gcd): Simplify assertions. Use __abs_r instead of __absu. (experimental::lcm): Likewise. Remove use of __detail::__lcm so overflow can be detected. * include/std/numeric (__detail::__absu): Rename to __abs_r and change to allow signed result type, so overflow can be detected. (__detail::__lcm): Remove. (gcd): Simplify assertions. Use __abs_r instead of __absu. (lcm): Likewise. Remove use of __detail::__lcm so overflow can be detected. * testsuite/26_numerics/gcd/gcd_neg.cc: Adjust dg-error lines. * testsuite/26_numerics/lcm/lcm_neg.cc: Likewise. * testsuite/26_numerics/gcd/105844.cc: New test. * testsuite/26_numerics/lcm/105844.cc: New test.
2022-06-10libstdc++: Make std::hash<basic_string<>> allocator-agnostic (LWG 3705)Jonathan Wakely
This new library issue was recently moved to Tentatively Ready by an LWG poll, so I'm making the change on trunk. As noted in PR libstc++/105907 the std::hash specializations for PMR strings were not treated as slow hashes by the unordered containers, so this change preserves that. The new specializations for custom allocators are also not treated as slow, for the same reason. For the versioned namespace (i.e. unstable ABI) we don't have to worry about that, so can enable hash code caching for all basic_string specializations. libstdc++-v3/ChangeLog: * include/bits/basic_string.h (__hash_str_base): New class template. (hash<basic_string<C, char_traits<C>, A>>): Define partial specialization for each of the standard character types. (hash<string>, hash<wstring>, hash<u8string>, hash<u16string>) (hash<u32string>): Remove explicit specializations. * include/std/string (__hash_string_base): Remove class template. (hash<pmr::string>, hash<pmr::wstring>, hash<pmr::u8string>) (hash<pmr::u16string>, hash<pmr::u32string>): Remove explicit specializations. * testsuite/21_strings/basic_string/hash/hash.cc: Test with custom allocators. * testsuite/21_strings/basic_string/hash/hash_char8_t.cc: Likewise.
2022-05-26libstdc++: Move std::iostream_category() definition to new fileJonathan Wakely
This fixes a missing symbol when the dual ABI is disabled, e.g. for the versioned namespace build. libstdc++-v3/ChangeLog: * src/c++11/Makefile.am: Add new source file. * src/c++11/Makefile.in: Regenerate. * src/c++11/cxx11-ios_failure.cc (iostream_category): Move to ... * src/c++11/ios_errcat.cc: New file. * testsuite/27_io/ios_base/failure/error_code.cc: Check that std::iostream_category() is defined and used for std::io_errc.
2022-05-26libstdc++: Add constexpr to std::counted_iterator post-increment (LWG 3643)Jonathan Wakely
libstdc++-v3/ChangeLog: * include/bits/stl_iterator.h (counted_iterator::operator++(int)): Add 'constexpr' as per LWG 3643. * testsuite/24_iterators/counted_iterator/lwg3643.cc: New test.
2022-05-26libstdc++: Rename tests like .../wchar_t/1.cc to .../wchar_t.ccJonathan Wakely
There's no need to have directories containing a single test file, we can rename the files to the directory names and remove the directories. The dejagnu proc that filters out wchar_t tests just checks for "wchar_t" anywhere in the path, so will work just as well on wchar_t.cc or constexpr-wchar_t.cc paths. libstdc++-v3/ChangeLog: * testsuite/21_strings/basic_string/modifiers/pop_back/char/1.cc: Moved to... * testsuite/21_strings/basic_string/modifiers/pop_back/char.cc: ...here. * testsuite/21_strings/basic_string/modifiers/pop_back/wchar_t/1.cc: Moved to... * testsuite/21_strings/basic_string/modifiers/pop_back/wchar_t.cc: ...here. * testsuite/21_strings/basic_string/modifiers/swap/wchar_t/constexpr.cc: Moved to... * testsuite/21_strings/basic_string/modifiers/swap/constexpr-wchar_t.cc: ...here. * testsuite/21_strings/basic_string/modifiers/swap/char/constexpr.cc: Moved to... * testsuite/21_strings/basic_string/modifiers/swap/constexpr.cc: ...here. * testsuite/21_strings/basic_string/operations/contains/char/1.cc: Moved to... * testsuite/21_strings/basic_string/operations/contains/char.cc: ...here. * testsuite/21_strings/basic_string/operations/contains/wchar_t/1.cc: Moved to... * testsuite/21_strings/basic_string/operations/contains/wchar_t.cc: ...here. * testsuite/21_strings/basic_string/operations/data/char/1.cc: Moved to... * testsuite/21_strings/basic_string/operations/data/char.cc: ...here. * testsuite/21_strings/basic_string/operations/data/wchar_t/1.cc: Moved to... * testsuite/21_strings/basic_string/operations/data/wchar_t.cc: ...here. * testsuite/21_strings/basic_string/operations/ends_with/char/1.cc: Moved to... * testsuite/21_strings/basic_string/operations/ends_with/char.cc: ...here. * testsuite/21_strings/basic_string/operations/ends_with/wchar_t/1.cc: Moved to... * testsuite/21_strings/basic_string/operations/ends_with/wchar_t.cc: ...here. * testsuite/21_strings/basic_string/operations/starts_with/char/1.cc: Moved to... * testsuite/21_strings/basic_string/operations/starts_with/char.cc: ...here. * testsuite/21_strings/basic_string/operations/starts_with/wchar_t/1.cc: Moved to... * testsuite/21_strings/basic_string/operations/starts_with/wchar_t.cc: ...here. * testsuite/21_strings/basic_string/operations/substr/char/1.cc: Moved to... * testsuite/21_strings/basic_string/operations/substr/char.cc: ...here. * testsuite/21_strings/basic_string/operations/substr/wchar_t/1.cc: Moved to... * testsuite/21_strings/basic_string/operations/substr/wchar_t.cc: ...here. * testsuite/21_strings/basic_string/range_access/char/1.cc: Moved to... * testsuite/21_strings/basic_string/range_access/char.cc: ...here. * testsuite/21_strings/basic_string/range_access/wchar_t/1.cc: Moved to... * testsuite/21_strings/basic_string/range_access/wchar_t.cc: ...here. * testsuite/21_strings/basic_string_view/modifiers/remove_prefix/char/1.cc: Moved to... * testsuite/21_strings/basic_string_view/modifiers/remove_prefix/char.cc: ...here. * testsuite/21_strings/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc: Moved to... * testsuite/21_strings/basic_string_view/modifiers/remove_prefix/wchar_t.cc: ...here. * testsuite/21_strings/basic_string_view/modifiers/remove_suffix/char/1.cc: Moved to... * testsuite/21_strings/basic_string_view/modifiers/remove_suffix/char.cc: ...here. * testsuite/21_strings/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc: Moved to... * testsuite/21_strings/basic_string_view/modifiers/remove_suffix/wchar_t.cc: ...here. * testsuite/21_strings/basic_string_view/modifiers/swap/char/1.cc: Moved to... * testsuite/21_strings/basic_string_view/modifiers/swap/char.cc: ...here. * testsuite/21_strings/basic_string_view/modifiers/swap/wchar_t/1.cc: Moved to... * testsuite/21_strings/basic_string_view/modifiers/swap/wchar_t.cc: ...here. * testsuite/21_strings/basic_string_view/operations/contains/char/1.cc: Moved to... * testsuite/21_strings/basic_string_view/operations/contains/char.cc: ...here. * testsuite/21_strings/basic_string_view/operations/contains/wchar_t/1.cc: Moved to... * testsuite/21_strings/basic_string_view/operations/contains/wchar_t.cc: ...here. * testsuite/21_strings/basic_string_view/operations/data/char/1.cc: Moved to... * testsuite/21_strings/basic_string_view/operations/data/char.cc: ...here. * testsuite/21_strings/basic_string_view/operations/data/wchar_t/1.cc: Moved to... * testsuite/21_strings/basic_string_view/operations/data/wchar_t.cc: ...here. * testsuite/21_strings/basic_string_view/operations/ends_with/char/1.cc: Moved to... * testsuite/21_strings/basic_string_view/operations/ends_with/char.cc: ...here. * testsuite/21_strings/basic_string_view/operations/ends_with/wchar_t/1.cc: Moved to... * testsuite/21_strings/basic_string_view/operations/ends_with/wchar_t.cc: ...here. * testsuite/21_strings/basic_string_view/operations/starts_with/char/1.cc: Moved to... * testsuite/21_strings/basic_string_view/operations/starts_with/char.cc: ...here. * testsuite/21_strings/basic_string_view/operations/starts_with/wchar_t/1.cc: Moved to... * testsuite/21_strings/basic_string_view/operations/starts_with/wchar_t.cc: ...here. * testsuite/21_strings/basic_string_view/operations/substr/char/1.cc: Moved to... * testsuite/21_strings/basic_string_view/operations/substr/char.cc: ...here. * testsuite/21_strings/basic_string_view/operations/substr/wchar_t/1.cc: Moved to... * testsuite/21_strings/basic_string_view/operations/substr/wchar_t.cc: ...here. * testsuite/21_strings/basic_string_view/range_access/char/1.cc: Moved to... * testsuite/21_strings/basic_string_view/range_access/char.cc: ...here. * testsuite/21_strings/basic_string_view/range_access/wchar_t/1.cc: Moved to... * testsuite/21_strings/basic_string_view/range_access/wchar_t.cc: ...here. * testsuite/21_strings/basic_string/requirements/explicit_instantiation/char/1.cc: Moved to... * testsuite/21_strings/basic_string/requirements/explicit_instantiation/char.cc: ...here. * testsuite/21_strings/basic_string/requirements/explicit_instantiation/char16_t/1.cc: Moved to... * testsuite/21_strings/basic_string/requirements/explicit_instantiation/char16_t.cc: ...here. * testsuite/21_strings/basic_string/requirements/explicit_instantiation/char32_t/1.cc: Moved to... * testsuite/21_strings/basic_string/requirements/explicit_instantiation/char32_t.cc: ...here. * testsuite/21_strings/basic_string/requirements/explicit_instantiation/char8_t/1.cc: Moved to... * testsuite/21_strings/basic_string/requirements/explicit_instantiation/char8_t.cc: ...here. * testsuite/21_strings/basic_string/requirements/explicit_instantiation/1.cc: Moved to... * testsuite/21_strings/basic_string/requirements/explicit_instantiation/int.cc: ...here. * testsuite/21_strings/basic_string/requirements/explicit_instantiation/wchar_t/1.cc: Moved to... * testsuite/21_strings/basic_string/requirements/explicit_instantiation/wchar_t.cc: ...here. * testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char/1.cc: Moved to... * testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char.cc: ...here. * testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc: Moved to... * testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char16_t.cc: ...here. * testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc: Moved to... * testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char32_t.cc: ...here. * testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char8_t/1.cc: Moved to... * testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char8_t.cc: ...here. * testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/1.cc: Moved to... * testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/int.cc: ...here. * testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc: Moved to... * testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/wchar_t.cc: ...here. * testsuite/21_strings/char_traits/requirements/explicit_instantiation/char/1.cc: Moved to... * testsuite/21_strings/char_traits/requirements/explicit_instantiation/char.cc: ...here. * testsuite/21_strings/char_traits/requirements/explicit_instantiation/char16_t/1.cc: Moved to... * testsuite/21_strings/char_traits/requirements/explicit_instantiation/char16_t.cc: ...here. * testsuite/21_strings/char_traits/requirements/explicit_instantiation/char32_t/1.cc: Moved to... * testsuite/21_strings/char_traits/requirements/explicit_instantiation/char32_t.cc: ...here. * testsuite/21_strings/char_traits/requirements/explicit_instantiation/char8_t/1.cc: Moved to... * testsuite/21_strings/char_traits/requirements/explicit_instantiation/char8_t.cc: ...here. * testsuite/21_strings/char_traits/requirements/explicit_instantiation/short/1.cc: Moved to... * testsuite/21_strings/char_traits/requirements/explicit_instantiation/short.cc: ...here. * testsuite/21_strings/char_traits/requirements/explicit_instantiation/wchar_t/1.cc: Moved to... * testsuite/21_strings/char_traits/requirements/explicit_instantiation/wchar_t.cc: ...here.
2022-05-26libstdc++: Remove redundancy in test pathnamesJonathan Wakely
Repeating "explicit_instantiation" in these long pathnames is not necessary. libstdc++-v3/ChangeLog: * testsuite/20_util/duration/requirements/explicit_instantiation/explicit_instantiation.cc: Moved to... * testsuite/20_util/duration/requirements/explicit_instantiation.cc: ...here. * testsuite/20_util/time_point/requirements/explicit_instantiation/explicit_instantiation.cc: Moved to... * testsuite/20_util/time_point/requirements/explicit_instantiation.cc: ...here. * testsuite/20_util/unique_ptr/requirements/explicit_instantiation/explicit_instantiation.cc: Moved to... * testsuite/20_util/unique_ptr/requirements/explicit_instantiation.cc: ...here.
2022-05-25c++: strict constexpr and local varsJason Merrill
A change I was working on made constexpr_searcher.cc start to fail, and when I looked at it I wondered why it had been accepted before. This turned out to be because we try to be more flexible about constant-evaluation of static initializers, as allowed, but we were wrongly doing the same for non-static initializers as well. gcc/cp/ChangeLog: * constexpr.cc (maybe_constant_init_1): Only pass false for strict when initializing a variable of static duration. libstdc++-v3/ChangeLog: * testsuite/20_util/function_objects/constexpr_searcher.cc: Add constexpr. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/constexpr-local4.C: New test.
2022-05-20libstdc++: Reduce <random> test iterations for simulatorsJonathan Wakely
Some of these tests take several minutes on a simulator like cris-elf, so we can conditionally run fewer iterations. The testDiscreteDist helper already supports custom sizes so we just need to make use of that when { target simulator } matches. The relevant code is sufficiently tested on other targets, so we're not losing anything by only running a small number of iterators for sims. libstdc++-v3/ChangeLog: * testsuite/26_numerics/random/bernoulli_distribution/operators/values.cc: Run fewer iterations for simulator targets. * testsuite/26_numerics/random/binomial_distribution/operators/values.cc: Likewise. * testsuite/26_numerics/random/discrete_distribution/operators/values.cc: Likewise. * testsuite/26_numerics/random/geometric_distribution/operators/values.cc: Likewise. * testsuite/26_numerics/random/negative_binomial_distribution/operators/values.cc: Likewise. * testsuite/26_numerics/random/poisson_distribution/operators/values.cc: Likewise. * testsuite/26_numerics/random/uniform_int_distribution/operators/values.cc: Likewise.
2022-05-19libstdc++: Avoid including <cstdint> for std::char_traitsJonathan Wakely
We should prefer the __UINT_LEAST16_TYPE__ and __UINT_LEAST32_TYPE__ macros, if available, so that we don't need all of <cstdint> in every header that uses std::char_traits. libstdc++-v3/ChangeLog: * include/bits/char_traits.h: Only include <cstdint> when necessary. * include/std/stacktrace: Use __UINTPTR_TYPE__ instead of uintptr_t. * src/c++11/cow-stdexcept.cc: Include <stdint.h>. * src/c++17/floating_to_chars.cc: Likewise. * testsuite/20_util/assume_aligned/1.cc: Include <cstdint>. * testsuite/20_util/assume_aligned/3.cc: Likewise. * testsuite/20_util/shared_ptr/creation/array.cc: Likewise.
2022-05-19libstdc++: Ensure pmr aliases work without <memory_resource>Jonathan Wakely
Currently the alias templates for std::pmr::vector, std::pmr::string etc. are defined using a forward declaration for polymorphic_allocator. This means you can't actually use the alias templates unless you also include <memory_resource>. The rationale for that is that it's a fairly large header, and most users don't need it. This isn't uncontroversial though, and LWG 3681 questions whether it's even conforming. This change adds a new <bits/memory_resource.h> header with the minimum needed to use polymorphic_allocator and the std::pmr container aliases. Including <memory_resource> is still necessary to use the program-wide resource objects, or the pool resources or monotonic buffer resource. libstdc++-v3/ChangeLog: * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/bits/memory_resource.h: New file. * include/std/deque: Include <bits/memory_resource.h>. * include/std/forward_list: Likewise. * include/std/list: Likewise. * include/std/map: Likewise. * include/std/memory_resource (pmr::memory_resource): Move to new <bits/memory_resource.h> header. (pmr::polymorphic_allocator): Likewise. * include/std/regex: Likewise. * include/std/set: Likewise. * include/std/stacktrace: Likewise. * include/std/string: Likewise. * include/std/unordered_map: Likewise. * include/std/unordered_set: Likewise. * include/std/vector: Likewise. * testsuite/21_strings/basic_string/types/pmr_typedefs.cc: Remove <memory_resource> header and check construction. * testsuite/23_containers/deque/types/pmr_typedefs.cc: Likewise. * testsuite/23_containers/forward_list/pmr_typedefs.cc: Likewise. * testsuite/23_containers/list/pmr_typedefs.cc: Likewise. * testsuite/23_containers/map/pmr_typedefs.cc: Likewise. * testsuite/23_containers/multimap/pmr_typedefs.cc: Likewise. * testsuite/23_containers/multiset/pmr_typedefs.cc: Likewise. * testsuite/23_containers/set/pmr_typedefs.cc: Likewise. * testsuite/23_containers/unordered_map/pmr_typedefs.cc: Likewise. * testsuite/23_containers/unordered_multimap/pmr_typedefs.cc: Likewise. * testsuite/23_containers/unordered_multiset/pmr_typedefs.cc: Likewise. * testsuite/23_containers/unordered_set/pmr_typedefs.cc: Likewise. * testsuite/23_containers/vector/pmr_typedefs.cc: Likewise. * testsuite/28_regex/match_results/pmr_typedefs.cc: Likewise. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/variadic-tuple.C: Qualify function to avoid ADL finding std::make_tuple.