summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/27_io
Commit message (Collapse)AuthorAgeFilesLines
* libstdc++: Fix error reporting in filesystem::copy [PR99290]Jonathan Wakely2022-04-281-0/+29
| | | | | | | | | | | | | | | | The recursive calls to filesystem::copy should stop if any of them reports an error. libstdc++-v3/ChangeLog: PR libstdc++/99290 * src/c++17/fs_ops.cc (fs::copy): Pass error_code to directory_iterator constructor, and check on each iteration. * src/filesystem/ops.cc (fs::copy): Likewise. * testsuite/27_io/filesystem/operations/copy.cc: Check for errors during recursion. * testsuite/experimental/filesystem/operations/copy.cc: Likewise.
* libstdc++: Define std::hash<std::filesystem::path> (LWG 3657)Jonathan Wakely2022-04-261-0/+10
| | | | | | | | | | This DR was approved at the February 2022 plenary. libstdc++-v3/ChangeLog: * include/bits/fs_path.h (hash<filesystem::path>): Define. * testsuite/27_io/filesystem/path/nonmember/hash_value.cc: Check std::hash specialization.
* libstdc++: Do not use dirent::d_type unconditionallyJonathan Wakely2022-02-021-0/+4
| | | | | | | | | | | | These new tests should not use the d_type member unless it's actually present on the OS. libstdc++-v3/ChangeLog: * testsuite/27_io/filesystem/iterators/error_reporting.cc: Use autoconf macro to check whether d_type is present. * testsuite/experimental/filesystem/iterators/error_reporting.cc: Likewise.
* libstdc++: Add more tests for filesystem directory iteratorsJonathan Wakely2022-02-012-0/+67
| | | | | | | | | | | | | | | | The PR 97731 test was added to verify a fix to the Filesystem TS code, but we should also have the same test to avoid similar regressions in the C++17 std::filesystem code. Also add tests for directory_options::follow_directory_symlink libstdc++-v3/ChangeLog: * testsuite/27_io/filesystem/iterators/97731.cc: New test. * testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc: Check follow_directory_symlink option. * testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc: Likewise.
* libstdc++: Reset filesystem::recursive_directory_iterator on errorJonathan Wakely2022-02-011-0/+135
| | | | | | | | | | | | | | | | | | The standard requires directory iterators to become equal to the end iterator value if they report an error. Some members functions of filesystem::recursive_directory_iterator fail to do that. libstdc++-v3/ChangeLog: * src/c++17/fs_dir.cc (recursive_directory_iterator::increment): Reset state to past-the-end iterator on error. (fs::recursive_directory_iterator::pop(error_code&)): Likewise. (fs::recursive_directory_iterator::pop()): Check _M_dirs before it might get reset. * src/filesystem/dir.cc (recursive_directory_iterator): Likewise, for the TS implementation. * testsuite/27_io/filesystem/iterators/error_reporting.cc: New test. * testsuite/experimental/filesystem/iterators/error_reporting.cc: New test.
* libstdc++ testsuite: Don't run lwg3464.cc tests on simulatorsHans-Peter Nilsson2022-01-302-2/+2
| | | | | | | | | | | | These tests have always been failing for my autotester running a cris-elf simulator; when unrestrained they take about 20 minutes each, compared to the (doubled) timeout of 720 seconds, of a total 2h40min for the whole of the libstdc++-v3 testsuite. The tests cover counter overflow and are already disabled for LP64 targets. * testsuite/27_io/basic_istream/get/char/lwg3464.cc: Don't run on simulator targets. * testsuite/27_io/basic_istream/get/wchar_t/lwg3464.cc: Likewise.
* libstdc++: Fix std::spanstream move assignment [PR104032]Jonathan Wakely2022-01-231-0/+113
| | | | | | | | | | | libstdc++-v3/ChangeLog: PR libstdc++/104032 * include/std/spanstream (basic_spanbuf(basic_spanbuf&&)): Use mem-initializer for _M_buf. (basic_spanbuf::Operator=(basic_spanbuf&&)): Fix ill-formed member access. * testsuite/27_io/spanstream/2.cc: New test.
* libstdc++: Add attribute to features deprecated in C++17 [PR91260]Jonathan Wakely2022-01-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are a lot of things in the C++ standard library which were deprecated in C++11, and more in C++17. Some of them were removed after deprecation and are no longer present in the standard at all. We have not removed these from libstdc++ because keeping them as non-standard extensions is conforming, and avoids gratuitously breaking user code, and in some cases we need to keep using them to avoid ABI changes. But we should at least give a warning for using them. That has not been done previously because of the library's own uses of them (e.g. the std::iterator class template used as a base class). This adds deprecated attributes to the relevant components, and then goes through the whole library to add diagnostic pragmas where needed to suppress warnings about our internal uses of them. The tests are updated to either expect the additional warnings, or to suppress them where we aren't interested in them. libstdc++-v3/ChangeLog: PR libstdc++/91260 PR libstdc++/91383 PR libstdc++/95065 * include/backward/binders.h (bind1st, bind2nd): Add deprecated attribute. * include/bits/refwrap.h (_Maybe_unary_or_binary_function): Disable deprecated warnings for base classes. (_Reference_wrapper_base): Likewise. * include/bits/shared_ptr_base.h (_Sp_owner_less): Likewise. * include/bits/stl_bvector.h (_Bit_iterator_base): Likewise. * include/bits/stl_function.h (unary_function, binary_function): Add deprecated attribute. (unary_negate, not1, binary_negate, not2, ptr_fun) (pointer_to_unary_function, pointer_to_binary_function) (mem_fun_t, const_mem_fun_t, mem_fun_ref_t, const_mem_fun_ref_t) (mem_fun1_t, const_mem_fun1_t, mem_fun_ref1_t) (const_mem_fun1_ref_t, mem_fun, mem_fun_ref): Add deprecated attributes. * include/bits/stl_iterator.h: Disable deprecated warnings for std::iterator base classes. * include/bits/stl_iterator_base_types.h (iterator): Add deprecated attribute. * include/bits/stl_map.h (map::value_compare): Disable deprecated warnings for base class. * include/bits/stl_multimap.h (multimap::value_compare): Likewise. * include/bits/stl_raw_storage_iter.h (raw_storage_iterator): Add deprecated attribute. * include/bits/stl_tempbuf.h (get_temporary_buffer): Likewise. * include/bits/stream_iterator.h: Disable deprecated warnings. * include/bits/streambuf_iterator.h: Likewise. * include/ext/bitmap_allocator.h: Remove unary_function base classes. * include/ext/functional: Disable deprecated warnings. * include/ext/rope: Likewise. * include/ext/throw_allocator.h: Likewise. * include/std/type_traits (result_of): Add deprecated attribute. * include/tr1/functional: Disable deprecated warnings. * include/tr1/functional_hash.h: Likewise. * testsuite/20_util/function_objects/binders/1.cc: Add -Wno-disable-deprecations. * testsuite/20_util/function_objects/binders/3113.cc: Likewise. * testsuite/20_util/function_objects/constexpr.cc: Add dg-warning. * testsuite/20_util/raw_storage_iterator/base.cc: Likewise. * testsuite/20_util/raw_storage_iterator/dr2127.cc: Likewise. * testsuite/20_util/raw_storage_iterator/requirements/base_classes.cc: Likewise. * testsuite/20_util/raw_storage_iterator/requirements/explicit_instantiation/1.cc: Likewise. * testsuite/20_util/raw_storage_iterator/requirements/typedefs.cc: Likewise. * testsuite/20_util/reference_wrapper/24803.cc: Likewise. * testsuite/20_util/reference_wrapper/typedefs.cc: Enable for C++20 and check for absence of nested types. * testsuite/20_util/shared_ptr/comparison/less.cc: Remove std::binary_function base class. * testsuite/20_util/temporary_buffer.cc: Add dg-warning. * testsuite/21_strings/basic_string/cons/char/69092.cc: Remove std::iterator base class. * testsuite/24_iterators/back_insert_iterator/requirements/base_classes.cc: Likewise. * testsuite/24_iterators/front_insert_iterator/requirements/base_classes.cc: Likewise. * testsuite/24_iterators/insert_iterator/requirements/base_classes.cc: Likewise. * testsuite/24_iterators/istream_iterator/requirements/base_classes.cc: Likewise. * testsuite/24_iterators/istreambuf_iterator/92285.cc: Likewise. * testsuite/24_iterators/istreambuf_iterator/requirements/base_classes.cc: Likewise. * testsuite/24_iterators/ostream_iterator/requirements/base_classes.cc: Likewise. * testsuite/24_iterators/ostreambuf_iterator/requirements/base_classes.cc: Likewise. * testsuite/24_iterators/reverse_iterator/requirements/base_classes.cc: Likewise. * testsuite/25_algorithms/copy/34595.cc: Likewise. * testsuite/25_algorithms/minmax/3.cc: Remove std::binary_function base class. * testsuite/25_algorithms/all_of/requirements/explicit_instantiation/2.cc: Disable deprecated warnings. * testsuite/25_algorithms/all_of/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/any_of/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/any_of/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/copy_if/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/copy_if/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/count_if/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/count_if/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/find_end/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/find_end/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/find_first_of/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/find_first_of/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/find_if/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/find_if/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/for_each/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/for_each/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/is_partitioned/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/is_partitioned/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/is_permutation/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/is_permutation/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/none_of/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/none_of/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/partition/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/partition/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/partition_copy/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/partition_copy/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/partition_point/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/partition_point/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/remove_copy_if/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/remove_copy_if/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/remove_if/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/remove_if/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/replace_copy_if/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/replace_copy_if/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/replace_if/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/replace_if/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/search/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/search/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/search_n/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/search_n/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/stable_partition/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/stable_partition/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/25_algorithms/transform/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/transform/requirements/explicit_instantiation/pod.cc: Likewise. * testsuite/27_io/basic_filebuf/underflow/wchar_t/9178.cc: Add dg-warning. * testsuite/ext/pb_ds/example/priority_queue_erase_if.cc: Likewise. * testsuite/ext/pb_ds/example/priority_queue_split_join.cc: Likewise. * testsuite/tr1/3_function_objects/reference_wrapper/typedefs.cc: Disable deprecated warnings. * testsuite/tr1/6_containers/hash/requirements/base_classes.cc: Likewise. * testsuite/util/regression/trait/erase_if_fn.hpp: Remove std::unary_function base classes. * testsuite/util/testsuite_iterators.h (output_iterator_wrapper): Remove std::iterator base classes.
* Update copyright years.Jakub Jelinek2022-01-031083-1083/+1083
|
* libstdc++: Implement std::ios_base::noreplace for C++23 [PR59769]Jonathan Wakely2021-12-092-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | This implements my P2467R0 proposal to support opening an fstream in exclusive mode. The new constant is also supported pre-C++23 as std::ios_base::__noreplace. This proposal hasn't been approved for C++23 yet, but I am confident it will be, as this is restoring a feture found in pre-ISO C++ iostreams implementations (and still present in the MSVC library as _Noreplace). If the proposal fails for C++23 we can remove the ios::noreplace name and just keep ios::__noreplace as an extension. libstdc++-v3/ChangeLog: PR libstdc++/59769 * config/io/basic_file_stdio.cc (fopen_mode): Add support for exclusive mode. * include/bits/ios_base.h (_S_noreplace): Define new enumerator. (ios_base::__noreplace): Define. (ios_base::noreplace): Define for C++23. * include/std/version (__cpp_lib_ios_noreplace): Define. * testsuite/27_io/basic_ofstream/open/char/noreplace.cc: New test. * testsuite/27_io/basic_ofstream/open/wchar_t/noreplace.cc: New test.
* libstdc++: Fix dg-do directive for tests supposed to be runJonathan Wakely2021-11-261-1/+1
| | | | | | | | | libstdc++-v3/ChangeLog: * testsuite/23_containers/unordered_map/modifiers/move_assign.cc: Change dg-do compile to run. * testsuite/27_io/basic_istream/extractors_character/wchar_t/lwg2499.cc: Likewise.
* libstdc++: Replace hyphens in effective target keywordsJonathan Wakely2021-11-2434-34/+34
| | | | | | | | | | | | | | | | 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.
* libstdc++: Improve tests for stringstream constructors in C++20Jonathan Wakely2021-11-196-88/+633
| | | | | | | | | | | | | | | | | This ensures all constructors are checked. libstdc++-v3/ChangeLog: * testsuite/27_io/basic_istringstream/cons/char/1.cc: Check all constructors. * testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc: Likewise. * testsuite/27_io/basic_ostringstream/cons/char/1.cc: Likewise. * testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc: Likewise. * testsuite/27_io/basic_stringstream/cons/char/1.cc: Likewise. * testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc: Likewise.
* libstdc++: Implement std::spanstream for C++23Jonathan Wakely2021-11-132-0/+63
| | | | | | | | | | | | | | This implements the <spanstream> header, as proposed for C++23 by P0448R4. libstdc++-v3/ChangeLog: * include/Makefile.am: Add spanstream header. * include/Makefile.in: Regenerate. * include/precompiled/stdc++.h: Add spanstream header. * include/std/version (__cpp_lib_spanstream): Define. * include/std/spanstream: New file. * testsuite/27_io/spanstream/1.cc: New test. * testsuite/27_io/spanstream/version.cc: New test.
* Make full use of context-sensitive ranges in access warnings.Martin Sebor2021-10-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | gcc/ChangeLog: * builtins.c (check_strncat_sizes): Pass access_data ctor additional arguments. (expand_builtin_memcmp): Move code to gimple-ssa-warn-access.cc. (expand_builtin_fork_or_exec): Same. * gimple-array-bounds.cc (array_bounds_checker::check_mem_ref): Pass compute_objsize additional arguments. (inbounds_memaccess_p): Same. (array_bounds_checker::check_array_bounds): Add an assert. Stash statement in a member. (check_array_bounds_dom_walker::before_dom_children): Same. * gimple-array-bounds.h (array_bounds_checker::m_stmt): New member. * gimple-ssa-sprintf.c (get_destination_size): Add an argument. (handle_printf_call): Pass a new argument. * gimple-ssa-warn-access.cc (get_size_range): Add an argument. (check_access): Add an argument and pass it along to callees. (check_read_access): Make a member function. (pass_waccess::check_strcat): Pass access_data ctor additional arguments. (pass_waccess::check_strncat): Same. (pass_waccess::check_stxcpy): Same. (pass_waccess::check_stxncpy): Same. (pass_waccess::check_strncmp): Same. (pass_waccess::check_read_access): Same. (pass_waccess::check_builtin): Same. (pass_waccess::maybe_check_access_sizes): Same. (pass_waccess::maybe_check_dealloc_call): Same. * gimple-ssa-warn-access.h (check_read_access): Declare a new member function. * pointer-query.cc (compute_objsize_r): Add an argument. (gimple_call_return_array): Same. (gimple_call_alloc_size): Same. (access_ref::access_ref): Same. (access_ref::get_ref): Same. (pointer_query::get_ref): Same. (handle_min_max_size): Pass an arguments to callees. (handle_array_ref): Add an argument. (handle_mem_ref): Same. (compute_objsize): Same. * pointer-query.h (struct access_ref): Adjust signatures. (struct access_data): Same. (gimple_call_alloc_size): Add an argument. (gimple_parm_array_size): Same. (compute_objsize): Same. * tree-ssa-strlen.c (strlen_pass::adjust_last_stmt): Pass an additional argument to compute_objsize. (strlen_pass::maybe_warn_overflow): Same. (maybe_diag_stxncpy_trunc): Same. gcc/testsuite/ChangeLog: * gcc.dg/Wstringop-overflow-22.c: Correct typos. * gcc.dg/Wstringop-overflow-81.c: New test. libstdc++-v3/ChangeLog: * testsuite/21_strings/basic_string/capacity/1.cc: Also suppress -Wstringop-overread. * testsuite/27_io/filesystem/path/factory/u8path-char8_t.cc: Same.
* libstdc++: Rename files with the wrong extensionsJonathan Wakely2021-10-131-0/+0
| | | | | | | | | libstdc++-v3/ChangeLog: * testsuite/27_io/filesystem/path/construct/102592.C: Moved to... * testsuite/27_io/filesystem/path/construct/102592.cc: ...here. * testsuite/28_regex/match_results/102667.C: Moved to... * testsuite/28_regex/match_results/102667.cc: ...here.
* libstdc++: Fix dangling string_view in filesystem::path [PR102592]Jonathan Wakely2021-10-131-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When creating a path from a pair of non-contiguous iterators we pass the iterators to _S_convert(Iter, Iter). That function passes the iterators to __string_from_range to get a contiguous sequence of characters, and then calls _S_convert(const C*, const C*) to perform the encoding conversions. If the value type, C, is char8_t, then no conversion is needed and the _S_convert<char8_t>(const char8_t*, const char8_t*) specialization casts the pointer to const char* and returns a std::string_view that refs to the char8_t sequence. However, that sequence is owned by the std::u8string rvalue returned by __string_from_range, which goes out of scope when _S_convert(Iter, Iter) returns. That means the std::string_view is dangling and we get undefined behaviour when parsing it as a path. The same problem does not exist for the path members taking a "Source" argument, because those functions all convert a non-contiguous range into a basic_string<C> immediately, using __effective_range(__source). That means that the rvalue string returned by that function is still in scope for the full expression, so the string_view does not dangle. The solution for the buggy functions is to do the same thing, and call __string_from_range immediately, so that the returned rvalue is still in scope for the lifetime of the string_view returned by _S_convert. To avoid reintroducing the same problem, remove the _S_convert(Iter, Iter) overload that calls __string_from_range and returns a dangling view. libstdc++-v3/ChangeLog: PR libstdc++/102592 * include/bits/fs_path.h (path::path(Iter, Iter, format)) (path::append(Iter, Iter), path::concat(Iter, Iter)): Call __string_from_range directly, instead of two-argument overload of _S_convert. (path::_S_convert(Iter, Iter)): Remove. * testsuite/27_io/filesystem/path/construct/102592.C: New test.
* libstdc++: Move test that depends on wchar_t I/O to wchar_t sub-directoryJonathan Wakely2021-10-091-0/+0
| | | | | | | | | This fixes a FAIL when --disable-wchar_t is used. libstdc++-v3/ChangeLog: * testsuite/27_io/basic_filebuf/close/81256.cc: Moved to... * testsuite/27_io/basic_filebuf/close/wchar_t/81256.cc: ...here.
* libstdc++: Add missing _GLIBCXX_USE_WCHAR_T checks in testsuiteJonathan Wakely2021-10-095-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* libstdc++: Improve test for printing volatile pointersJonathan Wakely2021-10-051-4/+8
| | | | | | | libstdc++-v3/ChangeLog: * testsuite/27_io/basic_ostream/inserters_other/char/volatile_ptr.cc: Check result matches non-volatile pointer.
* libstdc++: Support printing volatile pointers (P1147R1)Jonathan Wakely2021-10-051-0/+11
| | | | | | | | | | | | To avoid needing to export a new symbol from the library (for now) the new member function uses __attribute__((always_inline)). libstdc++-v3/ChangeLog: * include/std/ostream (operator<<(const volatile void*)): Add new overload, as per P1147R1. * testsuite/27_io/basic_ostream/inserters_other/char/volatile_ptr.cc: New test.
* libstdc++: Rename tests with incorrect extensionJonathan Wakely2021-09-171-0/+0
| | | | | | | | | | | | | | The libstdc++ testsuite only runs .cc files, so these two old tests have never been run. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * testsuite/26_numerics/valarray/dr630-3.C: Moved to... * testsuite/26_numerics/valarray/dr630-3.cc: ...here. * testsuite/27_io/basic_iostream/cons/16251.C: Moved to... * testsuite/27_io/basic_iostream/cons/16251.cc: ...here.
* libstdc++: Skip filesystem tests that depend on permissions [PR90787]Jonathan Wakely2021-08-209-96/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tests that depend on filesystem permissions FAIL if run on Windows or as root. Add a helper function to detect those cases, so the tests can skip those checks gracefully. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/90787 * testsuite/27_io/filesystem/iterators/directory_iterator.cc: Use new __gnu_test::permissions_are_testable() function. * testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc: Likewise. * testsuite/27_io/filesystem/operations/exists.cc: Likewise. * testsuite/27_io/filesystem/operations/is_empty.cc: Likewise. * testsuite/27_io/filesystem/operations/remove.cc: Likewise. * testsuite/27_io/filesystem/operations/remove_all.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/iterators/directory_iterator.cc: Likewise. * testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc: Likewise. * testsuite/experimental/filesystem/operations/exists.cc: Likewise. * testsuite/experimental/filesystem/operations/is_empty.cc: Likewise. * testsuite/experimental/filesystem/operations/remove.cc: Likewise. * testsuite/experimental/filesystem/operations/remove_all.cc: Likewise. * testsuite/experimental/filesystem/operations/temp_directory_path.cc: Likewise. * testsuite/util/testsuite_fs.h (__gnu_test::permissions_are_testable): New function to guess whether testing permissions will work.
* libstdc++: Use secure_getenv for filesystem::temp_directory_path() [PR65018]Jonathan Wakely2021-07-301-0/+7
| | | | | | | | | | | | | | | | | | | | | | | This adds a configure check for the GNU extension secure_getenv and then uses it for looking up TMPDIR and similar variables. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/65018 * configure.ac: Check for secure_getenv. * config.h.in: Regenerate. * configure: Regenerate. * src/filesystem/ops-common.h (get_temp_directory_from_env): New helper function to obtain path from the environment. * src/c++17/fs_ops.cc (fs::temp_directory_path): Use new helper. * src/filesystem/ops.cc (fs::temp_directory_path): Likewise. * testsuite/27_io/filesystem/operations/temp_directory_path.cc: Print messages if test cannot be run. * testsuite/experimental/filesystem/operations/temp_directory_path.cc: Likewise. Fix incorrect condition. Use "TMP" to work with Windows as well as POSIX.
* libstdc++: Fix create_directories to resolve symlinks [PR101510]Jonathan Wakely2021-07-202-0/+27
| | | | | | | | | | | | | | | | | | | | | | | When filesystem__create_directories checks to see if the path already exists and resovles to a directory, it uses filesystem::symlink_status, which means it reports an error if the path is a symlink. It should use filesystem::status, so that the target directory is detected, and no error is reported. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/101510 * src/c++17/fs_ops.cc (fs::create_directories): Use status instead of symlink_status. * src/filesystem/ops.cc (fs::create_directories): Likewise. * testsuite/27_io/filesystem/operations/create_directories.cc: * testsuite/27_io/filesystem/operations/create_directory.cc: Do not test with symlinks on Windows. * testsuite/experimental/filesystem/operations/create_directories.cc: * testsuite/experimental/filesystem/operations/create_directory.cc: Do not test with symlinks on Windows.
* libstdc++: Add more tests for filesystem::create_directory [PR101510]Jonathan Wakely2021-07-201-0/+27
| | | | | | | | | | | | | | Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/101510 * src/c++17/fs_ops.cc (create_dir): Adjust whitespace. * testsuite/27_io/filesystem/operations/create_directory.cc: Test creating directory with name of existing symlink to directory. * testsuite/experimental/filesystem/operations/create_directory.cc: Likewise.
* libstdc++: Implement LWG 415 for std::wsJonathan Wakely2021-06-282-0/+154
| | | | | | | | | | | | | | For C++11 std::ws changed to be an unformatted input function, meaning it constructs a sentry and sets badbit on exceptions. libstdc++-v3/ChangeLog: * doc/xml/manual/intro.xml: Document LWG 415 change. * doc/html/manual/bugs.html: Regenerate. * include/bits/istream.tcc (ws): Create sentry and catch exceptions. * testsuite/27_io/basic_istream/ws/char/lwg415.cc: New test. * testsuite/27_io/basic_istream/ws/wchar_t/lwg415.cc: New test.
* libstdc++: Implement LWG 581 for std:ostream::flush()Jonathan Wakely2021-06-254-34/+94
| | | | | | | | | | | | | | | | | | | | LWG 581 changed ostream::flush() to an unformatted output function for C++11, but it was never implemented in libstdc++. libstdc++-v3/ChangeLog: * doc/xml/manual/intro.xml: Document LWG 581 change. * doc/html/manual/bugs.html: Regenerate. * include/bits/basic_ios.tcc: Whitespace. * include/bits/ostream.tcc (basic_ostream::flush()): Construct sentry. * testsuite/27_io/basic_ostream/flush/char/2.cc: Check additional cases. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: Likewise. * testsuite/27_io/basic_ostream/flush/wchar_t/2.cc: Likewise. * testsuite/27_io/basic_ostream/flush/wchar_t/exceptions_badbit_throw.cc: Likewise.
* libstdc++: Fix exception handling in std::ostream seek functionsJonathan Wakely2021-06-258-43/+351
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | N3168 added the requirement that the [ostream.seeks] functions create a sentry object. Nothing in the requirements of those functions says anything about catching exceptions and setting badbit. As well as not catching exceptions, this change results in another observable behaviour change. Previously seeking on a stream with eofbit set would work (as long as badbit and failbit weren't set). The construction of a sentry causes failbit to be set when eofbit is set, which causes the seek to fail. It is necessary to clear the eofbit before seeking now. libstdc++-v3/ChangeLog: * include/bits/ostream.tcc (sentry): Only set failbit if badbit is set, not if eofbit is set. (tellp, seekp, seekp): Create sentry object. Do not set badbit on exceptions. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: Adjust expected behaviour. * testsuite/27_io/basic_ostream/seekp/wchar_t/exceptions_badbit_throw.cc: Likewise. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: Likewise. * testsuite/27_io/basic_ostream/tellp/wchar_t/exceptions_badbit_throw.cc: Likewise. * testsuite/27_io/basic_ostream/seekp/char/n3168.cc: New test. * testsuite/27_io/basic_ostream/seekp/wchar_t/n3168.cc: New test. * testsuite/27_io/basic_ostream/tellp/char/n3168.cc: New test. * testsuite/27_io/basic_ostream/tellp/wchar_t/n3168.cc: New test.
* libstdc++: Fix filesystem::path comparisons for C++23Jonathan Wakely2021-06-111-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In C++23 there is a basic_string_view(Range&&) constructor, which is constrained to take a range (specifically, a contiguous_range). When the filesystem::path comparison operators call lhs.compare(rhs) the overload taking a string_view is considered, which means checking whether path satisfies the range concept. That satisfaction result changes depending whether path::iterator is complete, which is ill-formed; no diagnostic required. To avoid the problem, this change ensures that the overload resolution is performed in a context where path::iterator is complete and the range concept is satisfied. (The result of overload resolution is always that the compare(const path&) overload is the best match, but we still have to consider the compare(basic_string_view<value_type>) one to decide if it even participates in overload resolution). For std::filesystem::path we can't define the comparison operators later in the file, because they are hidden friends, so a new helper is introduced that gets defined when everything else is complete. For std::experimental::filesystem::path we can just move the definitions of the comparison operators later in the file. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/bits/fs_path.h (operator==, operator<=>): Use new _S_compare function. (path::_S_compare): New function to call path::compare in a context where path::iterator is complete. * include/experimental/bits/fs_path.h (operator<, operator==): Define after path::iterator is complete. * testsuite/27_io/filesystem/path/native/conv_c++23.cc: New test. * testsuite/experimental/filesystem/path/native/conv_c++23.cc: New test.
* libstdc++: Fix filesystem::path constraints for volatile [PR 100630]Jonathan Wakely2021-05-171-0/+14
| | | | | | | | | | | | | | | | | | | | | | The constraint check for filesystem::path construction uses decltype(__is_path_src(declval<Source>())) which mean it considers conversion from an rvalue. When Source is a volatile-qualified type it cannot use is_path_src(const Unknown&) because a const lvalue reference can only bind to a non-volatile rvalue. Since the relevant path members all have a const Source& parameter, the constraint should be defined in terms of declval<const Source&>(), not declval<Source>(). This avoids the problem of volatile-qualified rvalues, because we no longer use an rvalue at all. libstdc++-v3/ChangeLog: PR libstdc++/100630 * include/experimental/bits/fs_path.h (__is_constructible_from): Test construction from a const lvalue, not an rvalue. * testsuite/27_io/filesystem/path/construct/100630.cc: New test. * testsuite/experimental/filesystem/path/construct/100630.cc: New test.
* libstdc++: Remove redundant -std=gnu++17 option from remaining testsJonathan Wakely2021-05-104-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC defaults to -std=gnu++17 now anyway, and using it explicitly in the dg-options directive prevents running these tests with different modes such as -std=c++17 or -std=gnu++20. libstdc++-v3/ChangeLog: * testsuite/17_intro/headers/c++2017/all_attributes.cc: Remove -std=gnu++17 from dg-options directive. * testsuite/17_intro/headers/c++2017/all_no_exceptions.cc: Likewise. * testsuite/17_intro/headers/c++2017/all_pedantic_errors.cc: Likewise. * testsuite/17_intro/headers/c++2017/operator_names.cc: Likewise. * testsuite/17_intro/headers/c++2017/parallel_mode.cc: Likewise. * testsuite/17_intro/headers/c++2017/stdc++.cc: Likewise. * testsuite/17_intro/headers/c++2017/stdc++_multiple_inclusion.cc: Likewise. * testsuite/18_support/aligned_alloc/aligned_alloc.cc: Likewise. * testsuite/18_support/byte/81076.cc: Likewise. * testsuite/18_support/byte/global_neg.cc: Likewise. * testsuite/18_support/byte/ops.cc: Likewise. * testsuite/18_support/byte/requirements.cc: Likewise. * testsuite/18_support/headers/cfloat/values_c++17.cc: Likewise. * testsuite/18_support/launder/1.cc: Likewise. * testsuite/18_support/launder/nodiscard.cc: Likewise. * testsuite/18_support/launder/requirements.cc: Likewise. * testsuite/18_support/launder/requirements_neg.cc: Likewise. * testsuite/18_support/new_aligned.cc: Likewise. * testsuite/18_support/uncaught_exceptions/uncaught_exceptions.cc: Likewise. * testsuite/19_diagnostics/error_code/is_error_code_v.cc: Likewise. * testsuite/19_diagnostics/error_condition/hash.cc: Likewise. * testsuite/20_util/addressof/requirements/constexpr.cc: Likewise. * testsuite/20_util/as_const/1.cc: Likewise. * testsuite/20_util/as_const/rvalue_neg.cc: Likewise. * testsuite/20_util/bind/83427.cc: Likewise. * testsuite/20_util/bind/is_placeholder_v.cc: Likewise. * testsuite/20_util/bool_constant/requirements.cc: Likewise. * testsuite/20_util/duration/arithmetic/constexpr_c++17.cc: Likewise. * testsuite/20_util/duration/requirements/treat_as_floating_point_v.cc: Likewise. * testsuite/20_util/duration_cast/rounding.cc: Likewise. * testsuite/20_util/enable_shared_from_this/members/weak_from_this.cc: Likewise. * testsuite/20_util/from_chars/1_neg.cc: Likewise. * testsuite/20_util/from_chars/requirements.cc: Likewise. * testsuite/20_util/function/91456.cc: Likewise. * testsuite/20_util/function/cons/deduction.cc: Likewise. * testsuite/20_util/function_objects/83607.cc: Likewise. * testsuite/20_util/function_objects/invoke/59768.cc: Likewise. * testsuite/20_util/function_objects/mem_fn/80478.cc: Likewise. * testsuite/20_util/function_objects/not_fn/1.cc: Likewise. * testsuite/20_util/function_objects/not_fn/87538.cc: Likewise. * testsuite/20_util/has_unique_object_representations/requirements/explicit_instantiation.cc: Likewise. * testsuite/20_util/has_unique_object_representations/requirements/typedefs.cc: Likewise. * testsuite/20_util/has_unique_object_representations/value.cc: Likewise. * testsuite/20_util/hash/nullptr.cc: Likewise. * testsuite/20_util/in_place/requirements.cc: Likewise. * testsuite/20_util/is_aggregate/incomplete_neg.cc: Likewise. * testsuite/20_util/is_aggregate/requirements/explicit_instantiation.cc: Likewise. * testsuite/20_util/is_aggregate/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_aggregate/value.cc: Likewise. * testsuite/20_util/is_invocable/83395.cc: Likewise. * testsuite/20_util/is_invocable/91456.cc: Likewise. * testsuite/20_util/is_invocable/requirements/explicit_instantiation.cc: Likewise. * testsuite/20_util/is_invocable/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_invocable/value.cc: Likewise. * testsuite/20_util/is_literal_type/deprecated-1z.cc: Likewise. * testsuite/20_util/is_nothrow_constructible/94003.cc: Likewise. * testsuite/20_util/is_nothrow_invocable/83395.cc: Likewise. * testsuite/20_util/is_nothrow_invocable/requirements/explicit_instantiation.cc: Likewise. * testsuite/20_util/is_nothrow_invocable/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_nothrow_invocable/value.cc: Likewise. * testsuite/20_util/is_nothrow_swappable/requirements/explicit_instantiation.cc: Likewise. * testsuite/20_util/is_nothrow_swappable/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_nothrow_swappable/value.cc: Likewise. * testsuite/20_util/is_nothrow_swappable_with/requirements/explicit_instantiation.cc: Likewise. * testsuite/20_util/is_nothrow_swappable_with/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_nothrow_swappable_with/value.cc: Likewise. * testsuite/20_util/is_swappable/requirements/explicit_instantiation.cc: Likewise. * testsuite/20_util/is_swappable/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_swappable/value.cc: Likewise. * testsuite/20_util/is_swappable_with/requirements/explicit_instantiation.cc: Likewise. * testsuite/20_util/is_swappable_with/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_swappable_with/value.cc: Likewise. * testsuite/20_util/logical_traits/83134.cc: Likewise. * testsuite/20_util/logical_traits/requirements/explicit_instantiation.cc: Likewise. * testsuite/20_util/logical_traits/requirements/typedefs.cc: Likewise. * testsuite/20_util/logical_traits/value.cc: Likewise. * testsuite/20_util/pair/cons/deduction.cc: Likewise. * testsuite/20_util/pair/swap_cxx17.cc: Likewise. * testsuite/20_util/ratio/requirements/ratio_equal_v.cc: Likewise. * testsuite/20_util/reference_wrapper/83427.cc: Likewise. * testsuite/20_util/reference_wrapper/deduction.cc: Likewise. * testsuite/20_util/shared_ptr/casts/reinterpret.cc: Likewise. * testsuite/20_util/shared_ptr/cons/deduction.cc: Likewise. * testsuite/20_util/shared_ptr/requirements/weak_type.cc: Likewise. * testsuite/20_util/time_point/arithmetic/constexpr.cc: Likewise. * testsuite/20_util/time_point_cast/rounding.cc: Likewise. * testsuite/20_util/to_chars/3.cc: Likewise. * testsuite/20_util/to_chars/chars_format.cc: Likewise. * testsuite/20_util/to_chars/lwg3266.cc: Likewise. * testsuite/20_util/to_chars/requirements.cc: Likewise. * testsuite/20_util/tuple/78939.cc: Likewise. * testsuite/20_util/tuple/apply/1.cc: Likewise. * testsuite/20_util/tuple/apply/2.cc: Likewise. * testsuite/20_util/tuple/cons/deduction.cc: Likewise. * testsuite/20_util/tuple/make_from_tuple/1.cc: Likewise. * testsuite/20_util/tuple/make_from_tuple/2.cc: Likewise. * testsuite/20_util/tuple/swap_cxx17.cc: Likewise. * testsuite/20_util/tuple/tuple_size_v.cc: Likewise. * testsuite/20_util/unique_ptr/cons/deduction_neg.cc: Likewise. * testsuite/20_util/uses_allocator/requirements/uses_allocator_v.cc: Likewise. * testsuite/20_util/variable_templates_for_traits.cc: Likewise. * testsuite/20_util/void_t/1.cc: Likewise. * testsuite/20_util/weak_ptr/cons/deduction.cc: Likewise. * testsuite/24_iterators/container_access.cc: Likewise. * testsuite/24_iterators/headers/iterator/range_access_c++17.cc: Likewise. * testsuite/24_iterators/headers/iterator/synopsis_c++17.cc: Likewise. * testsuite/24_iterators/range_access/range_access_cpp17.cc: Likewise. * testsuite/24_iterators/range_access/range_access_cpp17_neg.cc: Likewise. * testsuite/26_numerics/gcd/gcd_neg.cc: Likewise. * testsuite/26_numerics/headers/cmath/functions_std_c++17.cc: Likewise. * testsuite/26_numerics/headers/cmath/hypot.cc: Likewise. * testsuite/26_numerics/headers/cmath/special_functions_global.cc: Likewise. * testsuite/26_numerics/lcm/1.cc: Likewise. * testsuite/26_numerics/lcm/lcm_neg.cc: Likewise. * testsuite/26_numerics/valarray/deduction.cc: Likewise. * testsuite/27_io/basic_ostream/inserters_other/char/lwg2221.cc: Likewise. * testsuite/27_io/manipulators/standard/char/quoted_sv.cc: Likewise. * testsuite/27_io/manipulators/standard/wchar_t/quoted_sv.cc: Likewise. * testsuite/27_io/types/4.cc: Likewise. * testsuite/28_regex/basic_regex/ctors/deduction.cc: Likewise. * testsuite/libstdc++-prettyprinters/91997.cc: Likewise. * testsuite/libstdc++-prettyprinters/cxx17.cc: Likewise.
* libstdc++: Remove redundant -std=gnu++17 options from filesystem testsJonathan Wakely2021-05-10111-111/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC defaults to -std=gnu++17 now anyway, and using it explicitly in the dg-options directive prevents running these tests with different modes such as -std=c++17 or -std=gnu++20. libstdc++-v3/ChangeLog: * testsuite/27_io/basic_filebuf/open/char/path.cc: Remove -std=gnu++17 from dg-options directive. * testsuite/27_io/basic_fstream/cons/char/path.cc: Likewise. * testsuite/27_io/basic_fstream/open/char/path.cc: Likewise. * testsuite/27_io/basic_ifstream/cons/char/path.cc: Likewise. * testsuite/27_io/basic_ifstream/open/char/path.cc: Likewise. * testsuite/27_io/basic_ofstream/cons/char/path.cc: Likewise. * testsuite/27_io/basic_ofstream/open/char/path.cc: Likewise. * testsuite/27_io/filesystem/directory_entry/86597.cc: Likewise. * testsuite/27_io/filesystem/directory_entry/lwg3171.cc: Likewise. * testsuite/27_io/filesystem/file_status/1.cc: Likewise. * testsuite/27_io/filesystem/filesystem_error/cons.cc: Likewise. * testsuite/27_io/filesystem/filesystem_error/copy.cc: Likewise. * testsuite/27_io/filesystem/iterators/91067.cc: Likewise. * testsuite/27_io/filesystem/iterators/caching.cc: Likewise. * testsuite/27_io/filesystem/iterators/directory_iterator.cc: Likewise. * testsuite/27_io/filesystem/iterators/pop.cc: Likewise. * testsuite/27_io/filesystem/iterators/recursion_pending.cc: Likewise. * testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc: Likewise. * testsuite/27_io/filesystem/operations/absolute.cc: Likewise. * testsuite/27_io/filesystem/operations/all.cc: Likewise. * testsuite/27_io/filesystem/operations/canonical.cc: Likewise. * testsuite/27_io/filesystem/operations/copy.cc: Likewise. * testsuite/27_io/filesystem/operations/copy_file.cc: Likewise. * testsuite/27_io/filesystem/operations/create_directories.cc: Likewise. * testsuite/27_io/filesystem/operations/create_directory.cc: Likewise. * testsuite/27_io/filesystem/operations/create_symlink.cc: Likewise. * testsuite/27_io/filesystem/operations/current_path.cc: Likewise. * testsuite/27_io/filesystem/operations/equivalent.cc: Likewise. * testsuite/27_io/filesystem/operations/exists.cc: Likewise. * testsuite/27_io/filesystem/operations/file_size.cc: Likewise. * testsuite/27_io/filesystem/operations/is_empty.cc: Likewise. * testsuite/27_io/filesystem/operations/last_write_time.cc: Likewise. * testsuite/27_io/filesystem/operations/permissions.cc: Likewise. * testsuite/27_io/filesystem/operations/proximate.cc: Likewise. * testsuite/27_io/filesystem/operations/read_symlink.cc: Likewise. * testsuite/27_io/filesystem/operations/relative.cc: Likewise. * testsuite/27_io/filesystem/operations/remove.cc: Likewise. * testsuite/27_io/filesystem/operations/remove_all.cc: Likewise. * testsuite/27_io/filesystem/operations/rename.cc: Likewise. * testsuite/27_io/filesystem/operations/resize_file.cc: Likewise. * testsuite/27_io/filesystem/operations/space.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/27_io/filesystem/operations/weakly_canonical.cc: Likewise. * testsuite/27_io/filesystem/path/append/path.cc: Likewise. * testsuite/27_io/filesystem/path/append/source.cc: Likewise. * testsuite/27_io/filesystem/path/assign/assign.cc: Likewise. * testsuite/27_io/filesystem/path/assign/copy.cc: Likewise. * testsuite/27_io/filesystem/path/compare/compare.cc: Likewise. * testsuite/27_io/filesystem/path/compare/lwg2936.cc: Likewise. * testsuite/27_io/filesystem/path/compare/path.cc: Likewise. * testsuite/27_io/filesystem/path/compare/strings.cc: Likewise. * testsuite/27_io/filesystem/path/concat/92853.cc: Likewise. * testsuite/27_io/filesystem/path/concat/94063.cc: Likewise. * testsuite/27_io/filesystem/path/concat/path.cc: Likewise. * testsuite/27_io/filesystem/path/concat/strings.cc: Likewise. * testsuite/27_io/filesystem/path/construct/80762.cc: Likewise. * testsuite/27_io/filesystem/path/construct/90281.cc: Likewise. * testsuite/27_io/filesystem/path/construct/90634.cc: Likewise. * testsuite/27_io/filesystem/path/construct/copy.cc: Likewise. * testsuite/27_io/filesystem/path/construct/default.cc: Likewise. * testsuite/27_io/filesystem/path/construct/format.cc: Likewise. * testsuite/27_io/filesystem/path/construct/locale.cc: Likewise. * testsuite/27_io/filesystem/path/construct/range.cc: Likewise. * testsuite/27_io/filesystem/path/construct/string_view.cc: Likewise. * testsuite/27_io/filesystem/path/decompose/extension.cc: Likewise. * testsuite/27_io/filesystem/path/decompose/filename.cc: Likewise. * testsuite/27_io/filesystem/path/decompose/parent_path.cc: Likewise. * testsuite/27_io/filesystem/path/decompose/relative_path.cc: Likewise. * testsuite/27_io/filesystem/path/decompose/root_directory.cc: Likewise. * testsuite/27_io/filesystem/path/decompose/root_name.cc: Likewise. * testsuite/27_io/filesystem/path/decompose/root_path.cc: Likewise. * testsuite/27_io/filesystem/path/decompose/stem.cc: Likewise. * testsuite/27_io/filesystem/path/factory/u8path-char8_t.cc: Likewise. * testsuite/27_io/filesystem/path/factory/u8path.cc: Likewise. * testsuite/27_io/filesystem/path/generation/normal.cc: Likewise. * testsuite/27_io/filesystem/path/generation/normal2.cc: Likewise. * testsuite/27_io/filesystem/path/generation/proximate.cc: Likewise. * testsuite/27_io/filesystem/path/generation/relative.cc: Likewise. * testsuite/27_io/filesystem/path/generic/94242.cc: Likewise. * testsuite/27_io/filesystem/path/generic/generic_string.cc: Likewise. * testsuite/27_io/filesystem/path/generic/utf.cc: Likewise. * testsuite/27_io/filesystem/path/generic/wchar_t.cc: Likewise. * testsuite/27_io/filesystem/path/io/dr2989.cc: Likewise. * testsuite/27_io/filesystem/path/itr/components.cc: Likewise. * testsuite/27_io/filesystem/path/itr/traversal.cc: Likewise. * testsuite/27_io/filesystem/path/modifiers/clear.cc: Likewise. * testsuite/27_io/filesystem/path/modifiers/make_preferred.cc: Likewise. * testsuite/27_io/filesystem/path/modifiers/remove_filename.cc: Likewise. * testsuite/27_io/filesystem/path/modifiers/replace_extension.cc: Likewise. * testsuite/27_io/filesystem/path/modifiers/replace_filename.cc: Likewise. * testsuite/27_io/filesystem/path/modifiers/swap.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/27_io/filesystem/path/nonmember/append.cc: Likewise. * testsuite/27_io/filesystem/path/nonmember/cmp.cc: Likewise. * testsuite/27_io/filesystem/path/nonmember/hash_value.cc: Likewise. * testsuite/27_io/filesystem/path/query/empty.cc: Likewise. * testsuite/27_io/filesystem/path/query/empty_neg.cc: * testsuite/27_io/filesystem/path/query/has_extension.cc: Likewise. * testsuite/27_io/filesystem/path/query/has_filename.cc: Likewise. * testsuite/27_io/filesystem/path/query/has_parent_path.cc: Likewise. * testsuite/27_io/filesystem/path/query/has_relative_path.cc: Likewise. * testsuite/27_io/filesystem/path/query/has_root_directory.cc: Likewise. * testsuite/27_io/filesystem/path/query/has_root_name.cc: Likewise. * testsuite/27_io/filesystem/path/query/has_root_path.cc: Likewise. * testsuite/27_io/filesystem/path/query/has_stem.cc: Likewise. * testsuite/27_io/filesystem/path/query/is_absolute.cc: Likewise. * testsuite/27_io/filesystem/path/query/is_relative.cc: Likewise. * testsuite/experimental/filesystem/path/construct/string_view.cc: Likewise.
* libstdc++: Adjust expected errors in tests when compiled as C++20Jonathan Wakely2021-05-101-0/+1
| | | | | | | | | | | libstdc++-v3/ChangeLog: * testsuite/20_util/scoped_allocator/69293_neg.cc: Add dg-error for additional errors in C++20. * testsuite/20_util/specialized_algorithms/memory_management_tools/destroy_neg.cc: Likewise. * testsuite/20_util/uses_allocator/69293_neg.cc: Likewise. * testsuite/27_io/filesystem/path/io/dr2989.cc: Likewise.
* libstdc++: Fix constraints for rvalue stream insertion/extractionJonathan Wakely2021-05-076-5/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The __rval_streamable() function was an attempt to test for convertibility cheaply and without confusing diagnostics. It doesn't work with Clang though, and is probably ill-formed. Replace that helper function with a check for derivation from ios_base, and use that in the alias templates __rvalue_stream_insertion_t and __rvalue_stream_extraction_t. Use concepts for the constraints when available. libstdc++-v3/ChangeLog: * include/std/istream (__rvalue_stream_extraction_t): Replace use of __rval_streamable. * include/std/ostream (__rvalue_stream_insertion_t): Likewise. (__rval_streamable): Remove. (_Require_derived_from_ios_base, __derived_from_ios_base): New helper for checking constraints. * testsuite/27_io/basic_istream/extractors_other/char/4.cc: Fix reference to the wrong subclause of the standard. * testsuite/27_io/basic_istream/extractors_other/wchar_t/4.cc: Likewise. * testsuite/27_io/basic_ostream/inserters_other/char/6.cc: Likewise. * testsuite/27_io/basic_ostream/inserters_other/wchar_t/6.cc: Likewise. * testsuite/27_io/basic_ostream/inserters_other/char/99692.cc: New test. * testsuite/27_io/filesystem/path/io/dr2989.cc: Adjust pruned errors.
* libstdc++: Implement LWG 1203 for rvalue iostreamsJonathan Wakely2021-04-309-224/+188
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements the resolution of LWG 1203 so that the constraints for rvalue stream insertion/extraction are simpler, and the return type is the original rvalue stream type not its base class. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/std/istream (operator>>(Istream&&, x&)): Simplify, as per LWG 1203. * include/std/ostream (operator<<(Ostream&&, const x&)): Likewise. * testsuite/27_io/basic_istream/extractors_character/char/lwg2499_neg.cc: Adjust dg-error pattern. * testsuite/27_io/basic_istream/extractors_character/wchar_t/lwg2499_neg.cc: Likewise. * testsuite/27_io/basic_istream/extractors_other/char/4.cc: Define is_extractable trait to replace std::__is_extractable. Make it work with rvalue streams as well as lvalues, to replace f() and g() helper functions. * testsuite/27_io/basic_istream/extractors_other/wchar_t/4.cc: Likewise. * testsuite/27_io/basic_ostream/inserters_other/char/6.cc: Define is_insertable trait to replace std::__is_insertable. Make it work with rvalue streams as well as lvalues, to replace f() and g() helper functions. * testsuite/27_io/basic_ostream/inserters_other/wchar_t/6.cc: Likewise. * testsuite/27_io/filesystem/path/io/dr2989.cc: Prune additional errors from new constraints. * testsuite/27_io/rvalue_streams-2.cc: Remove PR 80675 checks, which are no longer expected to compile. * testsuite/27_io/rvalue_streams.cc: Adjust existing test. Verify LWG 1203 changes.
* libstdc++: Fix filesystem::path construction from COW string [PR 99805]Jonathan Wakely2021-04-071-1/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calling the non-const data() member on a COW string makes it "leaked", possibly resulting in reallocating the string to ensure a unique owner. The path::_M_split_cmpts() member parses its _M_pathname string using string_view objects and then calls _M_pathname.data() to find the offset of each string_view from the start of the string. However because _M_pathname is non-const that will cause a COW string to reallocate if it happens to be shared with another string object. This results in the offsets calculated for each component being wrong (i.e. undefined) because the string views no longer refer to substrings of the _M_pathname member. The fix is to use the parse.offset(c) member which gets the offset safely. The bug only happens for the path(string_type&&) constructor and only for COW strings. When constructed from an lvalue string the string's contents are copied rather than just incrementing the refcount, so there's no reallocation when calling the non-const data() member. The testsuite changes check the lvalue case anyway, because we should probably change the deep copying to just be a refcount increment (by adding a path(const string_type&) constructor or an overload for __effective_range(const string_type&), for COW strings only). libstdc++-v3/ChangeLog: PR libstdc++/99805 * src/c++17/fs_path.cc (path::_M_split_cmpts): Do not call non-const member on _M_pathname, to avoid copy-on-write. * testsuite/27_io/filesystem/path/decompose/parent_path.cc: Check construction from strings that might be shared.
* libstdc++: Do not assume std::FILE is complete [PR 99270]Jonathan Wakely2021-02-251-1/+1
| | | | | | | | libstdc++-v3/ChangeLog: PR libstdc++/99270 * testsuite/27_io/headers/cstdio/types_std.cc: Use pointer to FILE instead of FILE.
* libstdc++: Fix filesystem::rename on Windows [PR 98985]Jonathan Wakely2021-02-121-0/+181
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The _wrename function won't overwrite an existing file, so use MoveFileEx instead. That allows renaming directories over files, which POSIX doesn't allow, so check for that case explicitly and report an error. Also document the deviation from the expected behaviour, and add a test for filesystem::rename which was previously missing. The Filesystem TS experimental::filesystem::rename doesn't have that extra code to handle directories correctly, so the relevant parts of the new test are not run on Windows. libstdc++-v3/ChangeLog: * doc/xml/manual/status_cxx2014.xml: Document implementation specific properties of std::experimental::filesystem::rename. * doc/xml/manual/status_cxx2017.xml: Document implementation specific properties of std::filesystem::rename. * doc/html/*: Regenerate. * src/c++17/fs_ops.cc (fs::rename): Implement correct behaviour for directories on Windows. * src/filesystem/ops-common.h (__gnu_posix::rename): Use MoveFileExW on Windows. * testsuite/27_io/filesystem/operations/rename.cc: New test. * testsuite/experimental/filesystem/operations/rename.cc: New test.
* libstdc++: XFAIL tests that depends on RTTIJonathan Wakely2021-02-121-0/+1
| | | | | | | | | | | | | | | The std::emit_on_flush manipulator depends on dynamic_cast, so fails without RTTI. The std::async code can't catch a forced_unwind exception when RTTI is disabled, so it can't rethrow it either, and the test aborts. libstdc++-v3/ChangeLog: * testsuite/27_io/basic_ostream/emit/1.cc: Expect test to fail if -fno-rtti is used. * testsuite/30_threads/async/forced_unwind.cc: Expect test to abort if -fno-rtti is used.
* libstdc++: Only use dynamic_cast in tests when RTTI is enabledJonathan Wakely2021-02-126-18/+42
| | | | | | | | | | | | | | | | | libstdc++-v3/ChangeLog: * testsuite/27_io/basic_istringstream/rdbuf/char/2832.cc: Use static_cast when RTTI is disabled. * testsuite/27_io/basic_istringstream/rdbuf/wchar_t/2832.cc: Likewise. * testsuite/27_io/basic_ostringstream/rdbuf/char/2832.cc: Likewise. * testsuite/27_io/basic_ostringstream/rdbuf/wchar_t/2832.cc: Likewise. * testsuite/27_io/basic_stringstream/str/char/2.cc: Likewise. * testsuite/27_io/basic_stringstream/str/wchar_t/2.cc: Likewise.
* libstdc++: Fix spelling of __MINGW32__ macrosJonathan Wakely2021-02-104-5/+5
| | | | | | | | | | | | | libstdc++-v3/ChangeLog: * testsuite/27_io/filesystem/operations/proximate.cc: Fix typo in __MINGW32__ macro name. * testsuite/27_io/filesystem/path/compare/lwg2936.cc: Likewise. * testsuite/27_io/filesystem/path/generation/proximate.cc: Likewise. * testsuite/27_io/filesystem/path/generation/relative.cc: Likewise. * testsuite/util/testsuite_fs.h: Likewise.
* libstdc++: Clear up directories created by testsJonathan Wakely2021-02-091-0/+2
| | | | | | | | | libstdc++-v3/ChangeLog: * testsuite/27_io/filesystem/operations/remove_all.cc: Remove test directory after making it writable again. * testsuite/experimental/filesystem/operations/remove_all.cc: Likewise.
* libstdc++: Fix narrow char test to use stringbuf not wstringbufJonathan Wakely2021-01-181-1/+1
| | | | | | | | | This seems to be a copy & paste error. libstdc++-v3/ChangeLog: * testsuite/27_io/basic_stringstream/cons/char/1.cc: Use stringbuf not wstringbuf.
* Update copyright years.Jakub Jelinek2021-01-041082-1082/+1082
|
* libstdc++: Fix the test for rvalue stream extractionVille Voutilainen2020-12-151-0/+2
| | | | | | | libstdc++-v3/ChangeLog: * testsuite/27_io/rvalue_streams.cc: Run the extraction to a char* for C++17 and lower only.
* libstdc++: Use longer timeout for istream::gcount() overflow testsJonathan Wakely2020-12-022-0/+2
| | | | | | | | | | | | On targets with 32-bit poitners these tests do extra work, so give them longer to run. libstdc++-v3/ChangeLog: * testsuite/27_io/basic_istream/ignore/char/94749.cc: Add dg-timeout-factor for ilp32 targets. * testsuite/27_io/basic_istream/ignore/wchar_t/94749.cc: Likewise.
* libstdc++: Use longer timeout for slow running testsJonathan Wakely2020-12-012-0/+2
| | | | | | | | | libstdc++-v3/ChangeLog: * testsuite/27_io/basic_istream/get/char/lwg3464.cc: Add dg-timeout-factor directive. * testsuite/27_io/basic_istream/get/wchar_t/lwg3464.cc: Likewise.
* libstdc++: Link test with libatomic if needed [PR 98003]Jonathan Wakely2020-12-011-2/+3
| | | | | | | | libstdc++-v3/ChangeLog: PR libstdc++/98003 * testsuite/27_io/basic_syncbuf/sync_ops/1.cc: Add options for libatomic.
* libstdc++: Fix -Wrange-loop-construct warnings in filesystem testsJonathan Wakely2020-11-2728-32/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many tests do `for (const path& p : test_paths)` where test_paths is an array of strings. To avoid -Wrange-loop-construct warnings the loop variable should be an object, not a reference bound to a temporary. libstdc++-v3/ChangeLog: * testsuite/27_io/filesystem/operations/absolute.cc: Avoid -Wrange-loop-construct warning. * testsuite/27_io/filesystem/path/append/source.cc: Likewise. * testsuite/27_io/filesystem/path/assign/copy.cc: Likewise. * testsuite/27_io/filesystem/path/compare/path.cc: Likewise. * testsuite/27_io/filesystem/path/construct/copy.cc: Likewise. * testsuite/27_io/filesystem/path/decompose/extension.cc: Likewise. * testsuite/27_io/filesystem/path/decompose/filename.cc: Likewise. * testsuite/27_io/filesystem/path/decompose/parent_path.cc: Likewise. * testsuite/27_io/filesystem/path/decompose/relative_path.cc: Likewise. * testsuite/27_io/filesystem/path/decompose/root_directory.cc: Likewise. * testsuite/27_io/filesystem/path/decompose/root_path.cc: Likewise. * testsuite/27_io/filesystem/path/itr/traversal.cc: Likewise. * testsuite/27_io/filesystem/path/modifiers/remove_filename.cc: Likewise. * testsuite/27_io/filesystem/path/modifiers/replace_extension.cc: Likewise. * testsuite/27_io/filesystem/path/modifiers/replace_filename.cc: Likewise. * testsuite/27_io/filesystem/path/nonmember/append.cc: Likewise. * testsuite/27_io/filesystem/path/nonmember/cmp.cc: Likewise. * testsuite/27_io/filesystem/path/nonmember/cmp_c++20.cc: Likewise. * testsuite/27_io/filesystem/path/nonmember/hash_value.cc: Likewise. * testsuite/27_io/filesystem/path/query/has_extension.cc: Likewise. * testsuite/27_io/filesystem/path/query/has_filename.cc: Likewise. * testsuite/27_io/filesystem/path/query/has_parent_path.cc: Likewise. * testsuite/27_io/filesystem/path/query/has_relative_path.cc: Likewise. * testsuite/27_io/filesystem/path/query/has_root_directory.cc: Likewise. * testsuite/27_io/filesystem/path/query/has_root_name.cc: Likewise. * testsuite/27_io/filesystem/path/query/has_root_path.cc: Likewise. * testsuite/27_io/filesystem/path/query/has_stem.cc: Likewise. * testsuite/27_io/filesystem/path/query/is_relative.cc: Likewise. * testsuite/experimental/filesystem/operations/absolute.cc: Likewise. * testsuite/experimental/filesystem/path/assign/copy.cc: Likewise. * testsuite/experimental/filesystem/path/compare/path.cc: Likewise. * testsuite/experimental/filesystem/path/construct/copy.cc: Likewise. * testsuite/experimental/filesystem/path/decompose/extension.cc: Likewise. * testsuite/experimental/filesystem/path/decompose/filename.cc: Likewise. * testsuite/experimental/filesystem/path/decompose/parent_path.cc: Likewise. * testsuite/experimental/filesystem/path/decompose/relative_path.cc: Likewise. * testsuite/experimental/filesystem/path/decompose/root_directory.cc: Likewise. * testsuite/experimental/filesystem/path/decompose/root_path.cc: Likewise. * testsuite/experimental/filesystem/path/itr/traversal.cc: Likewise. * testsuite/experimental/filesystem/path/modifiers/remove_filename.cc: Likewise. * testsuite/experimental/filesystem/path/modifiers/replace_extension.cc: Likewise. * testsuite/experimental/filesystem/path/modifiers/replace_filename.cc: Likewise. * testsuite/experimental/filesystem/path/nonmember/hash_value.cc: Likewise. * testsuite/experimental/filesystem/path/query/has_extension.cc: Likewise. * testsuite/experimental/filesystem/path/query/has_filename.cc: Likewise. * testsuite/experimental/filesystem/path/query/has_parent_path.cc: Likewise. * testsuite/experimental/filesystem/path/query/has_relative_path.cc: Likewise. * testsuite/experimental/filesystem/path/query/has_root_directory.cc: Likewise. * testsuite/experimental/filesystem/path/query/has_root_name.cc: Likewise. * testsuite/experimental/filesystem/path/query/has_root_path.cc: Likewise. * testsuite/experimental/filesystem/path/query/has_stem.cc: Likewise. * testsuite/experimental/filesystem/path/query/is_relative.cc: Likewise.