summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2022-07-01 11:40:29 +0100
committerJonathan Wakely <jwakely@redhat.com>2022-08-03 12:32:13 +0100
commitcff25d209b3e0f085fe69869617c50048de87e75 (patch)
tree9ec5b1ad0b140402dfdc3ecb09095bd7ad1c965f /libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
parente562236851e06091256593aa0d3fbda60a28e45b (diff)
libstdc++: Add nodiscard attribute to filesystem operations
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. (cherry picked from commit f7a148304a71f3d3ad6845b7966fdc3af88c9e45)
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc')
-rw-r--r--libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
index bc7ef0de2b7..5e618b25025 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
@@ -31,7 +31,7 @@ test01()
const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
std::error_code ec;
auto p = __gnu_test::nonexistent_path();
- canonical( p, ec );
+ (void) canonical( p, ec );
VERIFY( ec );
create_directory(p);
@@ -90,7 +90,7 @@ test02()
#if __cpp_exceptions
fs::path e1, e2;
try {
- canonical(p);
+ (void) canonical(p);
} catch (const fs::filesystem_error& e) {
e1 = e.path1();
e2 = e.path2();