[libcxx-commits] [libcxx] 2e4755f - [libc++] Fix a few warnings in system headers with GCC
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jul 27 17:09:09 PDT 2021
Author: Louis Dionne
Date: 2021-07-27T20:09:01-04:00
New Revision: 2e4755ff6058b5032b77ccca04aa6dab7db081a5
URL: https://github.com/llvm/llvm-project/commit/2e4755ff6058b5032b77ccca04aa6dab7db081a5
DIFF: https://github.com/llvm/llvm-project/commit/2e4755ff6058b5032b77ccca04aa6dab7db081a5.diff
LOG: [libc++] Fix a few warnings in system headers with GCC
This isn't fixing all of them, but at least it's making some progress.
Differential Revision: https://reviews.llvm.org/D106283
Added:
Modified:
libcxx/include/__config
libcxx/include/__hash_table
libcxx/include/__ranges/transform_view.h
libcxx/include/barrier
libcxx/include/charconv
libcxx/include/cmath
libcxx/include/compare
libcxx/include/memory
libcxx/include/random
libcxx/include/regex
libcxx/include/semaphore
Removed:
################################################################################
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 9a5343c14d5ff..3cf23694f8789 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -531,7 +531,7 @@ typedef __char32_t char32_t;
#define _LIBCPP_NORETURN __attribute__((noreturn))
-#if !__EXCEPTIONS
+#if !defined(__EXCEPTIONS)
# define _LIBCPP_NO_EXCEPTIONS
#endif
@@ -1023,7 +1023,8 @@ typedef unsigned int char32_t;
#if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC)
# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
_Pragma("GCC diagnostic push") \
- _Pragma("GCC diagnostic ignored \"-Wdeprecated\"")
+ _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \
+ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
# define _LIBCPP_SUPPRESS_DEPRECATED_POP \
_Pragma("GCC diagnostic pop")
#else
diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table
index f28100eba6917..df0f7c80db2e3 100644
--- a/libcxx/include/__hash_table
+++ b/libcxx/include/__hash_table
@@ -741,9 +741,9 @@ public:
private:
#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
- __hash_const_local_iterator(__next_pointer __node, size_t __bucket,
+ __hash_const_local_iterator(__next_pointer __node_ptr, size_t __bucket,
size_t __bucket_count, const void* __c) _NOEXCEPT
- : __node_(__node),
+ : __node_(__node_ptr),
__bucket_(__bucket),
__bucket_count_(__bucket_count)
{
@@ -753,9 +753,9 @@ private:
}
#else
_LIBCPP_INLINE_VISIBILITY
- __hash_const_local_iterator(__next_pointer __node, size_t __bucket,
+ __hash_const_local_iterator(__next_pointer __node_ptr, size_t __bucket,
size_t __bucket_count) _NOEXCEPT
- : __node_(__node),
+ : __node_(__node_ptr),
__bucket_(__bucket),
__bucket_count_(__bucket_count)
{
diff --git a/libcxx/include/__ranges/transform_view.h b/libcxx/include/__ranges/transform_view.h
index 9a7ffa1aa8b30..4243dc0366e9a 100644
--- a/libcxx/include/__ranges/transform_view.h
+++ b/libcxx/include/__ranges/transform_view.h
@@ -360,7 +360,7 @@ class transform_view<_View, _Fn>::__sentinel {
__sentinel() = default;
_LIBCPP_HIDE_FROM_ABI
- constexpr explicit __sentinel(sentinel_t<_Base> __end_) : __end_(__end_) {}
+ constexpr explicit __sentinel(sentinel_t<_Base> __end) : __end_(__end) {}
// Note: `__i` should always be `__sentinel<false>`, but directly using
// `__sentinel<false>` is ill-formed when `_Const` is false
diff --git a/libcxx/include/barrier b/libcxx/include/barrier
index 0ba9d20a69ac8..e26dba65329a7 100644
--- a/libcxx/include/barrier
+++ b/libcxx/include/barrier
@@ -107,7 +107,6 @@ void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier);
template<class _CompletionF>
class __barrier_base {
-
ptr
diff _t __expected;
unique_ptr<__barrier_algorithm_base,
void (*)(__barrier_algorithm_base*)> __base;
@@ -146,7 +145,7 @@ public:
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void wait(arrival_token&& __old_phase) const
{
- auto const __test_fn = [=]() -> bool {
+ auto const __test_fn = [this, __old_phase]() -> bool {
return __phase.load(memory_order_acquire) != __old_phase;
};
__libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy());
diff --git a/libcxx/include/charconv b/libcxx/include/charconv
index 4a5c65df7c75f..de34112d8eb37 100644
--- a/libcxx/include/charconv
+++ b/libcxx/include/charconv
@@ -612,13 +612,13 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
return __subject_seq_combinator(
__first, __last, __value,
- [](const char* __p, const char* __last, _Tp& __value,
+ [](const char* __p, const char* __lastx, _Tp& __value,
int __base) -> from_chars_result {
using __tl = numeric_limits<_Tp>;
auto __digits = __tl::digits / log2f(float(__base));
_Tp __a = __in_pattern(*__p++, __base).__val, __b = 0;
- for (int __i = 1; __p != __last; ++__i, ++__p)
+ for (int __i = 1; __p != __lastx; ++__i, ++__p)
{
if (auto __c = __in_pattern(*__p, __base))
{
@@ -636,7 +636,7 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
break;
}
- if (__p == __last || !__in_pattern(*__p, __base))
+ if (__p == __lastx || !__in_pattern(*__p, __base))
{
if (__tl::max() - __a >= __b)
{
diff --git a/libcxx/include/cmath b/libcxx/include/cmath
index a520685caa8d1..adf83c2b0a7b2 100644
--- a/libcxx/include/cmath
+++ b/libcxx/include/cmath
@@ -621,7 +621,7 @@ _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
if (__t == 1) return __b;
const _Fp __x = __a + __t * (__b - __a);
- if (__t > 1 == __b > __a)
+ if ((__t > 1) == (__b > __a))
return __b < __x ? __x : __b;
else
return __x < __b ? __x : __b;
diff --git a/libcxx/include/compare b/libcxx/include/compare
index c7bfb45f6e290..e924bffed1652 100644
--- a/libcxx/include/compare
+++ b/libcxx/include/compare
@@ -449,7 +449,7 @@ __compute_comp_type(const _ClassifyCompCategory (&__types)[_Size]) {
return _StrongOrd;
}
-template <class ..._Ts>
+template <class ..._Ts, bool _False = false>
constexpr auto __get_comp_type() {
using _CCC = _ClassifyCompCategory;
constexpr _CCC __type_kinds[] = {_StrongOrd, __type_to_enum<_Ts>()...};
@@ -463,7 +463,7 @@ constexpr auto __get_comp_type() {
else if constexpr (_Cat == _StrongOrd)
return strong_ordering::equivalent;
else
- static_assert(_Cat != _Cat, "unhandled case");
+ static_assert(_False, "unhandled case");
}
} // namespace __comp_detail
diff --git a/libcxx/include/memory b/libcxx/include/memory
index 4f73a81a2d86e..fdb8943530084 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -796,7 +796,7 @@ void __construct_backward_with_exception_guarantees(_Alloc&, _Tp* __begin1, _Tp*
ptr
diff _t _Np = __end1 - __begin1;
__end2 -= _Np;
if (_Np > 0)
- _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp));
+ _VSTD::memcpy(static_cast<void*>(__end2), static_cast<void const*>(__begin1), _Np * sizeof(_Tp));
}
struct __destruct_n
diff --git a/libcxx/include/random b/libcxx/include/random
index 85d03ee039f18..4a8c2a79267be 100644
--- a/libcxx/include/random
+++ b/libcxx/include/random
@@ -1731,7 +1731,7 @@ struct __is_seed_sequence
template <unsigned long long __a, unsigned long long __c,
unsigned long long __m, unsigned long long _Mp,
bool _MightOverflow = (__a != 0 && __m != 0 && __m-1 > (_Mp-__c)/__a),
- bool _OverflowOK = ((__m|__m-1) > __m), // m = 2^n
+ bool _OverflowOK = ((__m | (__m-1)) > __m), // m = 2^n
bool _SchrageOK = (__a != 0 && __m != 0 && __m % __a <= __m / __a)> // r <= q
struct __lce_alg_picker
{
diff --git a/libcxx/include/regex b/libcxx/include/regex
index 55f1d34b51f5a..e47cf9fca5d27 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -2003,14 +2003,14 @@ class __l_anchor_multiline
{
typedef __owns_one_state<_CharT> base;
- bool __multiline;
+ bool __multiline_;
public:
typedef _VSTD::__state<_CharT> __state;
_LIBCPP_INLINE_VISIBILITY
__l_anchor_multiline(bool __multiline, __node<_CharT>* __s)
- : base(__s), __multiline(__multiline) {}
+ : base(__s), __multiline_(__multiline) {}
virtual void __exec(__state&) const;
};
@@ -2025,7 +2025,7 @@ __l_anchor_multiline<_CharT>::__exec(__state& __s) const
__s.__do_ = __state::__accept_but_not_consume;
__s.__node_ = this->first();
}
- else if (__multiline &&
+ else if (__multiline_ &&
!__s.__at_first_ &&
__is_eol(*_VSTD::prev(__s.__current_)))
{
@@ -4574,7 +4574,7 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
if (__hd == -1)
__throw_regex_error<regex_constants::error_escape>();
__sum = 16 * __sum + static_cast<unsigned>(__hd);
- // drop through
+ // fallthrough
case 'x':
++__first;
if (__first == __last)
diff --git a/libcxx/include/semaphore b/libcxx/include/semaphore
index 20c9b1e337300..906f62e0f07aa 100644
--- a/libcxx/include/semaphore
+++ b/libcxx/include/semaphore
@@ -98,7 +98,7 @@ public:
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void acquire()
{
- auto const __test_fn = [=]() -> bool {
+ auto const __test_fn = [this]() -> bool {
auto __old = __a.load(memory_order_relaxed);
return (__old != 0) && __a.compare_exchange_strong(__old, __old - 1, memory_order_acquire, memory_order_relaxed);
};
@@ -108,7 +108,7 @@ public:
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
bool try_acquire_for(chrono::duration<Rep, Period> const& __rel_time)
{
- auto const __test_fn = [=]() -> bool {
+ auto const __test_fn = [this]() -> bool {
auto __old = __a.load(memory_order_acquire);
while(1) {
if (__old == 0)
More information about the libcxx-commits
mailing list