aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2022-07-01 11:40:29 +0100
committerJonathan Wakely <jwakely@redhat.com>2022-07-01 11:50:18 +0100
commitf7a148304a71f3d3ad6845b7966fdc3af88c9e45 (patch)
tree169d21fb9e406517c960e42f57c529a5e56589f3 /gcc
parent7780dc5b2d02785186583fc8eced3c9e3aec4552 (diff)
downloadgcc-f7a148304a71f3d3ad6845b7966fdc3af88c9e45.zip
gcc-f7a148304a71f3d3ad6845b7966fdc3af88c9e45.tar.gz
gcc-f7a148304a71f3d3ad6845b7966fdc3af88c9e45.tar.bz2
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.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions