public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-10773] libstdc++: Add nodiscard attribute to filesystem operations
@ 2023-05-16 12:50 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2023-05-16 12:50 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:5f8329722ecae1c96297b815f528b0c78093a172

commit r11-10773-g5f8329722ecae1c96297b815f528b0c78093a172
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Jul 1 11:40:29 2022 +0100

    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)

Diff:
---
 libstdc++-v3/include/bits/fs_ops.h                 | 79 ++++++++++++++++++++++
 libstdc++-v3/include/experimental/bits/fs_ops.h    | 71 +++++++++++++++++++
 .../27_io/filesystem/operations/absolute.cc        |  2 +-
 .../testsuite/27_io/filesystem/operations/all.cc   |  8 +--
 .../27_io/filesystem/operations/canonical.cc       |  4 +-
 .../27_io/filesystem/operations/exists.cc          |  2 +-
 .../27_io/filesystem/operations/is_empty.cc        |  4 +-
 .../27_io/filesystem/operations/read_symlink.cc    |  2 +-
 .../27_io/filesystem/operations/status.cc          |  2 +-
 .../27_io/filesystem/operations/symlink_status.cc  |  2 +-
 .../filesystem/operations/temp_directory_path.cc   |  4 +-
 .../filesystem/operations/canonical.cc             |  6 +-
 .../experimental/filesystem/operations/exists.cc   |  2 +-
 .../experimental/filesystem/operations/is_empty.cc |  4 +-
 .../filesystem/operations/read_symlink.cc          |  2 +-
 .../filesystem/operations/temp_directory_path.cc   |  4 +-
 16 files changed, 174 insertions(+), 24 deletions(-)

diff --git a/libstdc++-v3/include/bits/fs_ops.h b/libstdc++-v3/include/bits/fs_ops.h
index 5d7dfe155b5..ef01c1b824f 100644
--- a/libstdc++-v3/include/bits/fs_ops.h
+++ b/libstdc++-v3/include/bits/fs_ops.h
@@ -44,10 +44,16 @@ namespace filesystem
    *  @{
    */
 
+  [[nodiscard]]
   path absolute(const path& __p);
+
+  [[nodiscard]]
   path absolute(const path& __p, error_code& __ec);
 
+  [[nodiscard]]
   path canonical(const path& __p);
+
+  [[nodiscard]]
   path canonical(const path& __p, error_code& __ec);
 
   inline void
@@ -100,25 +106,34 @@ namespace filesystem
   void create_symlink(const path& __to, const path& __new_symlink,
 		      error_code& __ec) noexcept;
 
+  [[nodiscard]]
   path current_path();
+
+  [[nodiscard]]
   path current_path(error_code& __ec);
+
   void current_path(const path& __p);
   void current_path(const path& __p, error_code& __ec) noexcept;
 
+  [[nodiscard]]
   bool
   equivalent(const path& __p1, const path& __p2);
 
+  [[nodiscard]]
   bool
   equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept;
 
+  [[nodiscard]]
   inline bool
   exists(file_status __s) noexcept
   { return status_known(__s) && __s.type() != file_type::not_found; }
 
+  [[nodiscard]]
   inline bool
   exists(const path& __p)
   { return exists(status(__p)); }
 
+  [[nodiscard]]
   inline bool
   exists(const path& __p, error_code& __ec) noexcept
   {
@@ -131,63 +146,85 @@ namespace filesystem
     return false;
   }
 
+  [[nodiscard]]
   uintmax_t file_size(const path& __p);
+
+  [[nodiscard]]
   uintmax_t file_size(const path& __p, error_code& __ec) noexcept;
 
+  [[nodiscard]]
   uintmax_t hard_link_count(const path& __p);
+
+  [[nodiscard]]
   uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept;
 
+  [[nodiscard]]
   inline bool
   is_block_file(file_status __s) noexcept
   { return __s.type() == file_type::block; }
 
+  [[nodiscard]]
   inline bool
   is_block_file(const path& __p)
   { return is_block_file(status(__p)); }
 
+  [[nodiscard]]
   inline bool
   is_block_file(const path& __p, error_code& __ec) noexcept
   { return is_block_file(status(__p, __ec)); }
 
+  [[nodiscard]]
   inline bool
   is_character_file(file_status __s) noexcept
   { return __s.type() == file_type::character; }
 
+  [[nodiscard]]
   inline bool
   is_character_file(const path& __p)
   { return is_character_file(status(__p)); }
 
+  [[nodiscard]]
   inline bool
   is_character_file(const path& __p, error_code& __ec) noexcept
   { return is_character_file(status(__p, __ec)); }
 
+  [[nodiscard]]
   inline bool
   is_directory(file_status __s) noexcept
   { return __s.type() == file_type::directory; }
 
+  [[nodiscard]]
   inline bool
   is_directory(const path& __p)
   { return is_directory(status(__p)); }
 
+  [[nodiscard]]
   inline bool
   is_directory(const path& __p, error_code& __ec) noexcept
   { return is_directory(status(__p, __ec)); }
 
+  [[nodiscard]]
   bool is_empty(const path& __p);
+
+  [[nodiscard]]
   bool is_empty(const path& __p, error_code& __ec);
 
+  [[nodiscard]]
   inline bool
   is_fifo(file_status __s) noexcept
   { return __s.type() == file_type::fifo; }
 
+  [[nodiscard]]
   inline bool
   is_fifo(const path& __p)
   { return is_fifo(status(__p)); }
 
+  [[nodiscard]]
   inline bool
   is_fifo(const path& __p, error_code& __ec) noexcept
   { return is_fifo(status(__p, __ec)); }
 
+  [[nodiscard]]
   inline bool
   is_other(file_status __s) noexcept
   {
@@ -195,52 +232,67 @@ namespace filesystem
       && !is_symlink(__s);
   }
 
+  [[nodiscard]]
   inline bool
   is_other(const path& __p)
   { return is_other(status(__p)); }
 
+  [[nodiscard]]
   inline bool
   is_other(const path& __p, error_code& __ec) noexcept
   { return is_other(status(__p, __ec)); }
 
+  [[nodiscard]]
   inline bool
   is_regular_file(file_status __s) noexcept
   { return __s.type() == file_type::regular; }
 
+  [[nodiscard]]
   inline bool
   is_regular_file(const path& __p)
   { return is_regular_file(status(__p)); }
 
+  [[nodiscard]]
   inline bool
   is_regular_file(const path& __p, error_code& __ec) noexcept
   { return is_regular_file(status(__p, __ec)); }
 
+  [[nodiscard]]
   inline bool
   is_socket(file_status __s) noexcept
   { return __s.type() == file_type::socket; }
 
+  [[nodiscard]]
   inline bool
   is_socket(const path& __p)
   { return is_socket(status(__p)); }
 
+  [[nodiscard]]
   inline bool
   is_socket(const path& __p, error_code& __ec) noexcept
   { return is_socket(status(__p, __ec)); }
 
+  [[nodiscard]]
   inline bool
   is_symlink(file_status __s) noexcept
   { return __s.type() == file_type::symlink; }
 
+  [[nodiscard]]
   inline bool
   is_symlink(const path& __p)
   { return is_symlink(symlink_status(__p)); }
 
+  [[nodiscard]]
   inline bool
   is_symlink(const path& __p, error_code& __ec) noexcept
   { return is_symlink(symlink_status(__p, __ec)); }
 
+  [[nodiscard]]
   file_time_type  last_write_time(const path& __p);
+
+  [[nodiscard]]
   file_time_type  last_write_time(const path& __p, error_code& __ec) noexcept;
+
   void last_write_time(const path& __p, file_time_type __new_time);
   void last_write_time(const path& __p, file_time_type __new_time,
 		       error_code& __ec) noexcept;
@@ -257,19 +309,30 @@ namespace filesystem
   permissions(const path& __p, perms __prms, perm_options __opts,
 	      error_code& __ec) noexcept;
 
+  [[nodiscard]]
   inline path proximate(const path& __p, error_code& __ec)
   { return proximate(__p, current_path(), __ec); }
 
+  [[nodiscard]]
   path proximate(const path& __p, const path& __base = current_path());
+
+  [[nodiscard]]
   path proximate(const path& __p, const path& __base, error_code& __ec);
 
+  [[nodiscard]]
   path read_symlink(const path& __p);
+
+  [[nodiscard]]
   path read_symlink(const path& __p, error_code& __ec);
 
+  [[nodiscard]]
   inline path relative(const path& __p, error_code& __ec)
   { return relative(__p, current_path(), __ec); }
 
+  [[nodiscard]]
   path relative(const path& __p, const path& __base = current_path());
+
+  [[nodiscard]]
   path relative(const path& __p, const path& __base, error_code& __ec);
 
   bool remove(const path& __p);
@@ -284,22 +347,38 @@ namespace filesystem
   void resize_file(const path& __p, uintmax_t __size);
   void resize_file(const path& __p, uintmax_t __size, error_code& __ec) noexcept;
 
+  [[nodiscard]]
   space_info space(const path& __p);
+
+  [[nodiscard]]
   space_info space(const path& __p, error_code& __ec) noexcept;
 
+  [[nodiscard]]
   file_status status(const path& __p);
+
+  [[nodiscard]]
   file_status status(const path& __p, error_code& __ec) noexcept;
 
+  [[nodiscard]]
   inline bool status_known(file_status __s) noexcept
   { return __s.type() != file_type::none; }
 
+  [[nodiscard]]
   file_status symlink_status(const path& __p);
+
+  [[nodiscard]]
   file_status symlink_status(const path& __p, error_code& __ec) noexcept;
 
+  [[nodiscard]]
   path temp_directory_path();
+
+  [[nodiscard]]
   path temp_directory_path(error_code& __ec);
 
+  [[nodiscard]]
   path weakly_canonical(const path& __p);
+
+  [[nodiscard]]
   path weakly_canonical(const path& __p, error_code& __ec);
 
   /// @} group filesystem
diff --git a/libstdc++-v3/include/experimental/bits/fs_ops.h b/libstdc++-v3/include/experimental/bits/fs_ops.h
index 3231f50adac..e8278dd00c6 100644
--- a/libstdc++-v3/include/experimental/bits/fs_ops.h
+++ b/libstdc++-v3/include/experimental/bits/fs_ops.h
@@ -51,10 +51,16 @@ inline namespace v1
    * @{
    */
 
+  [[__nodiscard__]]
   path absolute(const path& __p, const path& __base = current_path());
 
+  [[__nodiscard__]]
   path canonical(const path& __p, const path& __base = current_path());
+
+  [[__nodiscard__]]
   path canonical(const path& __p, error_code& __ec);
+
+  [[__nodiscard__]]
   path canonical(const path& __p, const path& __base, error_code& __ec);
 
   inline void
@@ -66,6 +72,7 @@ inline namespace v1
   { copy(__from, __to, copy_options::none, __ec); }
 
   void copy(const path& __from, const path& __to, copy_options __options);
+
   void copy(const path& __from, const path& __to, copy_options __options,
 	    error_code& __ec) noexcept;
 
@@ -107,25 +114,34 @@ inline namespace v1
   void create_symlink(const path& __to, const path& __new_symlink,
 		      error_code& __ec) noexcept;
 
+  [[__nodiscard__]]
   path current_path();
+
+  [[__nodiscard__]]
   path current_path(error_code& __ec);
+
   void current_path(const path& __p);
   void current_path(const path& __p, error_code& __ec) noexcept;
 
+  [[__nodiscard__]]
   bool
   equivalent(const path& __p1, const path& __p2);
 
+  [[__nodiscard__]]
   bool
   equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept;
 
+  [[__nodiscard__]]
   inline bool
   exists(file_status __s) noexcept
   { return status_known(__s) && __s.type() != file_type::not_found; }
 
+  [[__nodiscard__]]
   inline bool
   exists(const path& __p)
   { return exists(status(__p)); }
 
+  [[__nodiscard__]]
   inline bool
   exists(const path& __p, error_code& __ec) noexcept
   {
@@ -138,63 +154,84 @@ inline namespace v1
     return false;
   }
 
+  [[__nodiscard__]]
   uintmax_t file_size(const path& __p);
+
+  [[__nodiscard__]]
   uintmax_t file_size(const path& __p, error_code& __ec) noexcept;
 
+  [[__nodiscard__]]
   uintmax_t hard_link_count(const path& __p);
+
+  [[__nodiscard__]]
   uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept;
 
+  [[__nodiscard__]]
   inline bool
   is_block_file(file_status __s) noexcept
   { return __s.type() == file_type::block; }
 
+  [[__nodiscard__]]
   inline bool
   is_block_file(const path& __p)
   { return is_block_file(status(__p)); }
 
+  [[__nodiscard__]]
   inline bool
   is_block_file(const path& __p, error_code& __ec) noexcept
   { return is_block_file(status(__p, __ec)); }
 
+  [[__nodiscard__]]
   inline bool
   is_character_file(file_status __s) noexcept
   { return __s.type() == file_type::character; }
 
+  [[__nodiscard__]]
   inline bool
   is_character_file(const path& __p)
   { return is_character_file(status(__p)); }
 
+  [[__nodiscard__]]
   inline bool
   is_character_file(const path& __p, error_code& __ec) noexcept
   { return is_character_file(status(__p, __ec)); }
 
+  [[__nodiscard__]]
   inline bool
   is_directory(file_status __s) noexcept
   { return __s.type() == file_type::directory; }
 
+  [[__nodiscard__]]
   inline bool
   is_directory(const path& __p)
   { return is_directory(status(__p)); }
 
+  [[__nodiscard__]]
   inline bool
   is_directory(const path& __p, error_code& __ec) noexcept
   { return is_directory(status(__p, __ec)); }
 
+  [[__nodiscard__]]
   bool is_empty(const path& __p);
+  [[__nodiscard__]]
   bool is_empty(const path& __p, error_code& __ec) noexcept;
 
+  [[__nodiscard__]]
   inline bool
   is_fifo(file_status __s) noexcept
   { return __s.type() == file_type::fifo; }
 
+  [[__nodiscard__]]
   inline bool
   is_fifo(const path& __p)
   { return is_fifo(status(__p)); }
 
+  [[__nodiscard__]]
   inline bool
   is_fifo(const path& __p, error_code& __ec) noexcept
   { return is_fifo(status(__p, __ec)); }
 
+  [[__nodiscard__]]
   inline bool
   is_other(file_status __s) noexcept
   {
@@ -202,52 +239,67 @@ inline namespace v1
       && !is_symlink(__s);
   }
 
+  [[__nodiscard__]]
   inline bool
   is_other(const path& __p)
   { return is_other(status(__p)); }
 
+  [[__nodiscard__]]
   inline bool
   is_other(const path& __p, error_code& __ec) noexcept
   { return is_other(status(__p, __ec)); }
 
+  [[__nodiscard__]]
   inline bool
   is_regular_file(file_status __s) noexcept
   { return __s.type() == file_type::regular; }
 
+  [[__nodiscard__]]
   inline bool
   is_regular_file(const path& __p)
   { return is_regular_file(status(__p)); }
 
+  [[__nodiscard__]]
   inline bool
   is_regular_file(const path& __p, error_code& __ec) noexcept
   { return is_regular_file(status(__p, __ec)); }
 
+  [[__nodiscard__]]
   inline bool
   is_socket(file_status __s) noexcept
   { return __s.type() == file_type::socket; }
 
+  [[__nodiscard__]]
   inline bool
   is_socket(const path& __p)
   { return is_socket(status(__p)); }
 
+  [[__nodiscard__]]
   inline bool
   is_socket(const path& __p, error_code& __ec) noexcept
   { return is_socket(status(__p, __ec)); }
 
+  [[__nodiscard__]]
   inline bool
   is_symlink(file_status __s) noexcept
   { return __s.type() == file_type::symlink; }
 
+  [[__nodiscard__]]
   inline bool
   is_symlink(const path& __p)
   { return is_symlink(symlink_status(__p)); }
 
+  [[__nodiscard__]]
   inline bool
   is_symlink(const path& __p, error_code& __ec) noexcept
   { return is_symlink(symlink_status(__p, __ec)); }
 
+  [[__nodiscard__]]
   file_time_type  last_write_time(const path& __p);
+
+  [[__nodiscard__]]
   file_time_type  last_write_time(const path& __p, error_code& __ec) noexcept;
+
   void last_write_time(const path& __p, file_time_type __new_time);
   void last_write_time(const path& __p, file_time_type __new_time,
 		       error_code& __ec) noexcept;
@@ -255,7 +307,10 @@ inline namespace v1
   void permissions(const path& __p, perms __prms);
   void permissions(const path& __p, perms __prms, error_code& __ec) noexcept;
 
+  [[__nodiscard__]]
   path read_symlink(const path& __p);
+
+  [[__nodiscard__]]
   path read_symlink(const path& __p, error_code& __ec);
 
   bool remove(const path& __p);
@@ -270,22 +325,38 @@ inline namespace v1
   void resize_file(const path& __p, uintmax_t __size);
   void resize_file(const path& __p, uintmax_t __size, error_code& __ec) noexcept;
 
+  [[__nodiscard__]]
   space_info space(const path& __p);
+
+  [[__nodiscard__]]
   space_info space(const path& __p, error_code& __ec) noexcept;
 
+  [[__nodiscard__]]
   file_status status(const path& __p);
+
+  [[__nodiscard__]]
   file_status status(const path& __p, error_code& __ec) noexcept;
 
+  [[__nodiscard__]]
   inline bool status_known(file_status __s) noexcept
   { return __s.type() != file_type::none; }
 
+  [[__nodiscard__]]
   file_status symlink_status(const path& __p);
+
+  [[__nodiscard__]]
   file_status symlink_status(const path& __p, error_code& __ec) noexcept;
 
+  [[__nodiscard__]]
   path system_complete(const path& __p);
+
+  [[__nodiscard__]]
   path system_complete(const path& __p, error_code& __ec);
 
+  [[__nodiscard__]]
   path temp_directory_path();
+
+  [[__nodiscard__]]
   path temp_directory_path(error_code& __ec);
 
   /// @} group filesystem-ts
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/absolute.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/absolute.cc
index 24d59799ef1..2bd7f694b3c 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/absolute.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/absolute.cc
@@ -84,7 +84,7 @@ test03()
   VERIFY( eabs.empty() );
 
   try {
-    absolute(path{});
+    (void) absolute(path{});
     VERIFY( false );
   } catch (const std::filesystem::filesystem_error& e) {
     VERIFY( e.code() == std::errc::invalid_argument );
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/all.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/all.cc
index 414c2d8d72c..9a922632eee 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/all.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/all.cc
@@ -42,11 +42,11 @@ main()
   bool b [[maybe_unused]];
   std::uintmax_t size;
 
-  std::filesystem::absolute(p);
-  std::filesystem::absolute(p, ec);
+  p2 = std::filesystem::absolute(p);
+  p2 = std::filesystem::absolute(p, ec);
 
-  std::filesystem::canonical(p);
-  std::filesystem::canonical(p, ec);
+  p2 = std::filesystem::canonical(p);
+  p2 = std::filesystem::canonical(p, ec);
 
   std::filesystem::copy(p, p);
   std::filesystem::copy(p, p, ec);
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/canonical.cc
index 172ef09ee85..dd42ffd403b 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();
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/exists.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/exists.cc
index f99a3346ed0..e97c34343ef 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/exists.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/exists.cc
@@ -95,7 +95,7 @@ test04()
   ec.clear();
   try
   {
-    exists(unr);
+    (void) exists(unr);
   }
   catch(const std::filesystem::filesystem_error& ex)
   {
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/is_empty.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/is_empty.cc
index 11605748501..b2d021af90e 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/is_empty.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/is_empty.cc
@@ -40,7 +40,7 @@ test01()
   VERIFY( !result );
 
   try {
-    fs::is_empty(p);
+    (void) fs::is_empty(p);
   } catch (const fs::filesystem_error& e) {
     ec2 = e.code();
   }
@@ -51,7 +51,7 @@ test01()
   VERIFY( !result );
 
   try {
-    fs::is_empty(p/"f");
+    (void) fs::is_empty(p/"f");
   } catch (const fs::filesystem_error& e) {
     ec2 = e.code();
   }
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
index 3a8244b8280..5221bf65082 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/read_symlink.cc
@@ -31,7 +31,7 @@ test01()
   auto p = __gnu_test::nonexistent_path();
   std::error_code ec;
 
-  read_symlink(p, ec);
+  (void) read_symlink(p, ec);
   VERIFY( ec );
 
   fs::path tgt = ".";
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/status.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/status.cc
index 4cabdcbe7f7..c2991f827ce 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/status.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/status.cc
@@ -74,7 +74,7 @@ test03()
   std::error_code ec2;
   fs::path p, p2;
   try {
-    fs::symlink_status(f.path);
+    (void) fs::symlink_status(f.path);
   } catch (const fs::filesystem_error& e) {
     caught = true;
     p = e.path1();
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
index bb4c185dd33..775aa21f2d4 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/symlink_status.cc
@@ -94,7 +94,7 @@ test03()
   std::error_code ec2;
   fs::path p, p2;
   try {
-    fs::symlink_status(f.path);
+    (void) fs::symlink_status(f.path);
   } catch (const fs::filesystem_error& e) {
     caught = true;
     p = e.path1();
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/temp_directory_path.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/temp_directory_path.cc
index 1cfda583be3..22cb23ad81e 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/temp_directory_path.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/temp_directory_path.cc
@@ -117,7 +117,7 @@ test03()
 
   std::error_code ec2;
   try {
-    fs::temp_directory_path();
+    (void) fs::temp_directory_path();
   } catch (const fs::filesystem_error& e) {
     ec2 = e.code();
   }
@@ -141,7 +141,7 @@ test04()
 
   std::error_code ec2;
   try {
-    fs::temp_directory_path();
+    (void) fs::temp_directory_path();
   } catch (const fs::filesystem_error& e) {
     ec2 = e.code();
   }
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/canonical.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/canonical.cc
index e54bf7c1f91..e41027f39e7 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/canonical.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/canonical.cc
@@ -30,11 +30,11 @@ test01()
 {
   std::error_code ec;
   auto p = __gnu_test::nonexistent_path();
-  canonical( p, ec );
+  (void) canonical( p, ec );
   VERIFY( ec );
 
   p = fs::current_path();
-  canonical( p, ec );
+  (void) canonical( p, ec );
   VERIFY( !ec );
 
   const auto root = fs::absolute("/");
@@ -67,7 +67,7 @@ test02()
   fs::path p = "rel", base = __gnu_test::nonexistent_path();
   fs::path e1, e2;
   try {
-    canonical(p, base);
+    (void) canonical(p, base);
   } catch (const fs::filesystem_error& e) {
     e1 = e.path1();
     e2 = e.path2();
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/exists.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/exists.cc
index 79fe970e9f3..39d99c7cece 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/exists.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/exists.cc
@@ -89,7 +89,7 @@ test04()
   ec.clear();
   try
   {
-    exists(unr);
+    (void) exists(unr);
   }
   catch(const std::experimental::filesystem::filesystem_error& ex)
   {
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/is_empty.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/is_empty.cc
index a474fa2a37f..21be254aad8 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/is_empty.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/is_empty.cc
@@ -41,7 +41,7 @@ test01()
   VERIFY( !result );
 
   try {
-    fs::is_empty(p);
+    (void) fs::is_empty(p);
   } catch (const fs::filesystem_error& e) {
     ec2 = e.code();
   }
@@ -52,7 +52,7 @@ test01()
   VERIFY( !result );
 
   try {
-    fs::is_empty(p/"f");
+    (void) fs::is_empty(p/"f");
   } catch (const fs::filesystem_error& e) {
     ec2 = e.code();
   }
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/read_symlink.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/read_symlink.cc
index 62bea22683c..a6ab109e30d 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/read_symlink.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/read_symlink.cc
@@ -32,7 +32,7 @@ test01()
   auto p = __gnu_test::nonexistent_path();
   std::error_code ec;
 
-  read_symlink(p, ec);
+  (void) read_symlink(p, ec);
   VERIFY( ec );
 
   fs::path tgt = ".";
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/temp_directory_path.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/temp_directory_path.cc
index b78f663dee9..43f515d7f7c 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/temp_directory_path.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/temp_directory_path.cc
@@ -118,7 +118,7 @@ test03()
 
   std::error_code ec2;
   try {
-    fs::temp_directory_path();
+    (void) fs::temp_directory_path();
   } catch (const fs::filesystem_error& e) {
     ec2 = e.code();
   }
@@ -142,7 +142,7 @@ test04()
 
   std::error_code ec2;
   try {
-    fs::temp_directory_path();
+    (void) fs::temp_directory_path();
   } catch (const fs::filesystem_error& e) {
     ec2 = e.code();
   }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-16 12:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-16 12:50 [gcc r11-10773] libstdc++: Add nodiscard attribute to filesystem operations Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).