[gcc r9-8349] libstdc++: Fix some warnings in filesystem tests
Jonathan Wakely
redi@gcc.gnu.org
Thu Mar 5 17:44:00 GMT 2020
https://gcc.gnu.org/g:128418afd7ee1bad9185eb88a6e224c2faf90792
commit r9-8349-g128418afd7ee1bad9185eb88a6e224c2faf90792
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Mar 5 17:32:58 2020 +0000
libstdc++: Fix some warnings in filesystem tests
There's a -Wunused-but-set-variable warning in operations/all.cc which
can be fixed with [[maybe_unused]].
The statements in operations/copy.cc give -Wunused-value warnings. I
think I meant to use |= rather than !=.
And operations/file_size.cc gets -Wsign-compare warnings.
Backport from mainline
2020-03-05 Jonathan Wakely <jwakely@redhat.com>
* testsuite/27_io/filesystem/operations/all.cc: Mark unused variable.
* testsuite/27_io/filesystem/operations/copy.cc: Fix typo.
* testsuite/experimental/filesystem/operations/copy.cc: Likewise.
* testsuite/27_io/filesystem/operations/file_size.cc: Use correct type
for return value, and in comparison.
* testsuite/experimental/filesystem/operations/file_size.cc: Likewise.
Diff:
---
libstdc++-v3/ChangeLog | 10 ++++++++++
libstdc++-v3/testsuite/27_io/filesystem/operations/all.cc | 2 +-
libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc | 2 +-
.../testsuite/27_io/filesystem/operations/file_size.cc | 12 ++++++------
.../testsuite/experimental/filesystem/operations/copy.cc | 2 +-
.../experimental/filesystem/operations/file_size.cc | 12 ++++++------
6 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 85758af..2f36d84 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,6 +1,16 @@
2020-03-05 Jonathan Wakely <jwakely@redhat.com>
Backport from mainline
+ 2020-03-05 Jonathan Wakely <jwakely@redhat.com>
+
+ * testsuite/27_io/filesystem/operations/all.cc: Mark unused variable.
+ * testsuite/27_io/filesystem/operations/copy.cc: Fix typo.
+ * testsuite/experimental/filesystem/operations/copy.cc: Likewise.
+ * testsuite/27_io/filesystem/operations/file_size.cc: Use correct type
+ for return value, and in comparison.
+ * testsuite/experimental/filesystem/operations/file_size.cc: Likewise.
+
+ Backport from mainline
2019-09-27 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/91910
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/all.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/all.cc
index 026aa57..075906e 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/all.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/all.cc
@@ -39,7 +39,7 @@ main()
const std::filesystem::perm_options permopts{};
std::filesystem::space_info sp;
std::error_code ec;
- bool b;
+ bool b [[maybe_unused]];
std::uintmax_t size;
std::filesystem::absolute(p);
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
index b19b0f4..9513ecf 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/copy.cc
@@ -57,7 +57,7 @@ test01()
VERIFY( !exists(to) );
ec.clear();
- opts != fs::copy_options::recursive;
+ opts |= fs::copy_options::recursive;
fs::copy("/", to, opts, ec);
VERIFY( ec == std::make_error_code(std::errc::is_a_directory) );
VERIFY( !exists(to) );
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/file_size.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/file_size.cc
index 57c9e96..4c55aa0 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/file_size.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/file_size.cc
@@ -29,9 +29,9 @@ void
test01()
{
std::error_code ec;
- size_t size = fs::file_size(".", ec);
+ auto size = fs::file_size(".", ec);
VERIFY( ec == std::errc::is_a_directory );
- VERIFY( size == -1 );
+ VERIFY( size == (std::uintmax_t)-1 );
try {
size = fs::file_size(".");
@@ -40,7 +40,7 @@ test01()
ec = e.code();
}
VERIFY( ec == std::errc::is_a_directory );
- VERIFY( size == -1 );
+ VERIFY( size == (std::uintmax_t)-1 );
}
void
@@ -49,9 +49,9 @@ test02()
fs::path p = __gnu_test::nonexistent_path();
std::error_code ec;
- size_t size = fs::file_size(p, ec);
+ auto size = fs::file_size(p, ec);
VERIFY( ec );
- VERIFY( size == -1 );
+ VERIFY( size == (std::uintmax_t)-1 );
try {
size = fs::file_size(p);
@@ -60,7 +60,7 @@ test02()
ec = e.code();
}
VERIFY( ec );
- VERIFY( size == -1 );
+ VERIFY( size == (std::uintmax_t)-1 );
}
int
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc
index 6102811..477ec2a 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/copy.cc
@@ -57,7 +57,7 @@ test01()
VERIFY( !exists(to) );
ec.clear();
- opts != fs::copy_options::recursive;
+ opts |= fs::copy_options::recursive;
fs::copy("/", to, opts, ec);
VERIFY( ec == std::make_error_code(std::errc::is_a_directory) );
VERIFY( !exists(to) );
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/file_size.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/file_size.cc
index b54776a..7acd1ef 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/operations/file_size.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/file_size.cc
@@ -29,9 +29,9 @@ void
test01()
{
std::error_code ec;
- size_t size = fs::file_size(".", ec);
+ auto size = fs::file_size(".", ec);
VERIFY( ec == std::errc::is_a_directory );
- VERIFY( size == -1 );
+ VERIFY( size == (std::uintmax_t)-1 );
try {
size = fs::file_size(".");
@@ -40,7 +40,7 @@ test01()
ec = e.code();
}
VERIFY( ec == std::errc::is_a_directory );
- VERIFY( size == -1 );
+ VERIFY( size == (std::uintmax_t)-1 );
}
void
@@ -49,9 +49,9 @@ test02()
fs::path p = __gnu_test::nonexistent_path();
std::error_code ec;
- size_t size = fs::file_size(p, ec);
+ auto size = fs::file_size(p, ec);
VERIFY( ec );
- VERIFY( size == -1 );
+ VERIFY( size == (std::uintmax_t)-1 );
try {
size = fs::file_size(p);
@@ -60,7 +60,7 @@ test02()
ec = e.code();
}
VERIFY( ec );
- VERIFY( size == -1 );
+ VERIFY( size == (std::uintmax_t)-1 );
}
int
More information about the Libstdc++-cvs
mailing list