nuttx/libs/libxx/0001-libc-NFC-Fix-several-GCC-warnings-in-the-test-suite.patch
Xiang Xiao 8bc4a5b08a [libc++] Cherry pick patches from mainline to fix warnings
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-11-15 08:28:36 -03:00

136 lines
4.4 KiB
Diff

From c479e0c99459e4c5596c2a22829d0937224df0bf Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne@apple.com>
Date: Fri, 30 Oct 2020 11:19:07 -0400
Subject: [PATCH] [libc++] NFC: Fix several GCC warnings in the test suite
- Several -Wshadow warnings
- Several places where we did not initialize our base class explicitly
- Unused variable warnings
- Some tautological comparisons
- Some places where we'd pass null arguments to functions expecting
non-null (in unevaluated contexts)
- Add a few pragmas to turn off spurious warnings
- Fix warnings about declarations that don't declare anything
- Properly disable deprecation warnings in ext/ tests (the pragmas we
were using didn't work on GCC)
- Disable include_as_c.sh.cpp because GCC complains about C++ flags
when compiling as C. I couldn't find a way to fix this one properly,
so I'm disabling the test. This isn't great, but at least we'll be
able to enable warnings in the whole test suite with GCC.
---
src/filesystem/filesystem_common.h | 55 ++++++++++++-----------
1 file changed, 28 insertions(+), 27 deletions(-)
diff --git a/src/filesystem/filesystem_common.h libcxx/src/filesystem/filesystem_common.h
index fe5c42f5e6d..a7828ef3863 100644
--- a/src/filesystem/filesystem_common.h
+++ libcxx/src/filesystem/filesystem_common.h
@@ -13,8 +13,9 @@
#include "filesystem"
#include "array"
#include "chrono"
-#include "cstdlib"
#include "climits"
+#include "cstdlib"
+#include "ctime"
#include <unistd.h>
#include <sys/stat.h>
@@ -47,7 +48,7 @@ static string format_string_imp(const char* msg, ...) {
struct GuardVAList {
va_list& target;
bool active = true;
- GuardVAList(va_list& target) : target(target), active(true) {}
+ GuardVAList(va_list& tgt) : target(tgt), active(true) {}
void clear() {
if (active)
va_end(target);
@@ -134,50 +135,50 @@ path error_value<path>() {
template <class T>
struct ErrorHandler {
- const char* func_name;
- error_code* ec = nullptr;
- const path* p1 = nullptr;
- const path* p2 = nullptr;
+ const char* func_name_;
+ error_code* ec_ = nullptr;
+ const path* p1_ = nullptr;
+ const path* p2_ = nullptr;
ErrorHandler(const char* fname, error_code* ec, const path* p1 = nullptr,
const path* p2 = nullptr)
- : func_name(fname), ec(ec), p1(p1), p2(p2) {
- if (ec)
- ec->clear();
+ : func_name_(fname), ec_(ec), p1_(p1), p2_(p2) {
+ if (ec_)
+ ec_->clear();
}
- T report(const error_code& m_ec) const {
- if (ec) {
- *ec = m_ec;
+ T report(const error_code& ec) const {
+ if (ec_) {
+ *ec_ = ec;
return error_value<T>();
}
- string what = string("in ") + func_name;
- switch (bool(p1) + bool(p2)) {
+ string what = string("in ") + func_name_;
+ switch (bool(p1_) + bool(p2_)) {
case 0:
- __throw_filesystem_error(what, m_ec);
+ __throw_filesystem_error(what, ec);
case 1:
- __throw_filesystem_error(what, *p1, m_ec);
+ __throw_filesystem_error(what, *p1_, ec);
case 2:
- __throw_filesystem_error(what, *p1, *p2, m_ec);
+ __throw_filesystem_error(what, *p1_, *p2_, ec);
}
_LIBCPP_UNREACHABLE();
}
template <class... Args>
- T report(const error_code& m_ec, const char* msg, Args const&... args) const {
- if (ec) {
- *ec = m_ec;
+ T report(const error_code& ec, const char* msg, Args const&... args) const {
+ if (ec_) {
+ *ec_ = ec;
return error_value<T>();
}
string what =
- string("in ") + func_name + ": " + format_string(msg, args...);
- switch (bool(p1) + bool(p2)) {
+ string("in ") + func_name_ + ": " + format_string(msg, args...);
+ switch (bool(p1_) + bool(p2_)) {
case 0:
- __throw_filesystem_error(what, m_ec);
+ __throw_filesystem_error(what, ec);
case 1:
- __throw_filesystem_error(what, *p1, m_ec);
+ __throw_filesystem_error(what, *p1_, ec);
case 2:
- __throw_filesystem_error(what, *p1, *p2, m_ec);
+ __throw_filesystem_error(what, *p1_, *p2_, ec);
}
_LIBCPP_UNREACHABLE();
}
@@ -197,8 +198,8 @@ private:
using chrono::duration;
using chrono::duration_cast;
-using TimeSpec = struct ::timespec;
-using StatT = struct ::stat;
+using TimeSpec = std::timespec;
+using StatT = struct stat;
template <class FileTimeT, class TimeT,
bool IsFloat = is_floating_point<typename FileTimeT::rep>::value>
--
2.17.1