[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
This commit is contained in:
Louis Dionne 2021-07-27 17:30:47 -04:00
parent 6ff73efea9
commit 2e4755ff60
11 changed files with 23 additions and 23 deletions

View File

@ -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

View File

@ -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)
{

View File

@ -360,7 +360,7 @@ public:
__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

View File

@ -107,7 +107,6 @@ void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier);
template<class _CompletionF>
class __barrier_base {
ptrdiff_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());

View File

@ -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)
{

View File

@ -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;

View File

@ -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

View File

@ -796,7 +796,7 @@ void __construct_backward_with_exception_guarantees(_Alloc&, _Tp* __begin1, _Tp*
ptrdiff_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

View File

@ -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
{

View File

@ -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)

View File

@ -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)