[libcxx] r290469 - fix sign comparison warnings
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 23 16:24:44 PST 2016
Author: ericwf
Date: Fri Dec 23 18:24:44 2016
New Revision: 290469
URL: http://llvm.org/viewvc/llvm-project?rev=290469&view=rev
Log:
fix sign comparison warnings
Modified:
libcxx/trunk/include/__bit_reference
libcxx/trunk/include/deque
libcxx/trunk/include/istream
libcxx/trunk/include/random
libcxx/trunk/include/regex
libcxx/trunk/test/libcxx/test/config.py
Modified: libcxx/trunk/include/__bit_reference
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__bit_reference?rev=290469&r1=290468&r2=290469&view=diff
==============================================================================
--- libcxx/trunk/include/__bit_reference (original)
+++ libcxx/trunk/include/__bit_reference Fri Dec 23 18:24:44 2016
@@ -163,7 +163,7 @@ __find_bool_true(__bit_iterator<_Cp, _Is
{
typedef __bit_iterator<_Cp, _IsConst> _It;
typedef typename _It::__storage_type __storage_type;
- static const unsigned __bits_per_word = _It::__bits_per_word;
+ static const int __bits_per_word = _It::__bits_per_word;
// do first partial word
if (__first.__ctz_ != 0)
{
@@ -199,7 +199,7 @@ __find_bool_false(__bit_iterator<_Cp, _I
{
typedef __bit_iterator<_Cp, _IsConst> _It;
typedef typename _It::__storage_type __storage_type;
- static const unsigned __bits_per_word = _It::__bits_per_word;
+ const int __bits_per_word = _It::__bits_per_word;
// do first partial word
if (__first.__ctz_ != 0)
{
@@ -251,7 +251,7 @@ __count_bool_true(__bit_iterator<_Cp, _I
typedef __bit_iterator<_Cp, _IsConst> _It;
typedef typename _It::__storage_type __storage_type;
typedef typename _It::difference_type difference_type;
- static const unsigned __bits_per_word = _It::__bits_per_word;
+ const int __bits_per_word = _It::__bits_per_word;
difference_type __r = 0;
// do first partial word
if (__first.__ctz_ != 0)
@@ -282,7 +282,7 @@ __count_bool_false(__bit_iterator<_Cp, _
typedef __bit_iterator<_Cp, _IsConst> _It;
typedef typename _It::__storage_type __storage_type;
typedef typename _It::difference_type difference_type;
- static const unsigned __bits_per_word = _It::__bits_per_word;
+ const int __bits_per_word = _It::__bits_per_word;
difference_type __r = 0;
// do first partial word
if (__first.__ctz_ != 0)
@@ -324,7 +324,7 @@ __fill_n_false(__bit_iterator<_Cp, false
{
typedef __bit_iterator<_Cp, false> _It;
typedef typename _It::__storage_type __storage_type;
- static const unsigned __bits_per_word = _It::__bits_per_word;
+ const int __bits_per_word = _It::__bits_per_word;
// do first partial word
if (__first.__ctz_ != 0)
{
@@ -354,7 +354,7 @@ __fill_n_true(__bit_iterator<_Cp, false>
{
typedef __bit_iterator<_Cp, false> _It;
typedef typename _It::__storage_type __storage_type;
- static const unsigned __bits_per_word = _It::__bits_per_word;
+ const int __bits_per_word = _It::__bits_per_word;
// do first partial word
if (__first.__ctz_ != 0)
{
@@ -412,7 +412,7 @@ __copy_aligned(__bit_iterator<_Cp, _IsCo
typedef __bit_iterator<_Cp, _IsConst> _In;
typedef typename _In::difference_type difference_type;
typedef typename _In::__storage_type __storage_type;
- static const unsigned __bits_per_word = _In::__bits_per_word;
+ const int __bits_per_word = _In::__bits_per_word;
difference_type __n = __last - __first;
if (__n > 0)
{
@@ -461,7 +461,7 @@ __copy_unaligned(__bit_iterator<_Cp, _Is
typedef __bit_iterator<_Cp, _IsConst> _In;
typedef typename _In::difference_type difference_type;
typedef typename _In::__storage_type __storage_type;
- static const unsigned __bits_per_word = _In::__bits_per_word;
+ static const int __bits_per_word = _In::__bits_per_word;
difference_type __n = __last - __first;
if (__n > 0)
{
@@ -551,7 +551,7 @@ __copy_backward_aligned(__bit_iterator<_
typedef __bit_iterator<_Cp, _IsConst> _In;
typedef typename _In::difference_type difference_type;
typedef typename _In::__storage_type __storage_type;
- static const unsigned __bits_per_word = _In::__bits_per_word;
+ const int __bits_per_word = _In::__bits_per_word;
difference_type __n = __last - __first;
if (__n > 0)
{
@@ -600,7 +600,7 @@ __copy_backward_unaligned(__bit_iterator
typedef __bit_iterator<_Cp, _IsConst> _In;
typedef typename _In::difference_type difference_type;
typedef typename _In::__storage_type __storage_type;
- static const unsigned __bits_per_word = _In::__bits_per_word;
+ const int __bits_per_word = _In::__bits_per_word;
difference_type __n = __last - __first;
if (__n > 0)
{
@@ -718,7 +718,7 @@ __swap_ranges_aligned(__bit_iterator<__C
typedef __bit_iterator<__C1, false> _I1;
typedef typename _I1::difference_type difference_type;
typedef typename _I1::__storage_type __storage_type;
- static const unsigned __bits_per_word = _I1::__bits_per_word;
+ const int __bits_per_word = _I1::__bits_per_word;
difference_type __n = __last - __first;
if (__n > 0)
{
@@ -768,7 +768,7 @@ __swap_ranges_unaligned(__bit_iterator<_
typedef __bit_iterator<__C1, false> _I1;
typedef typename _I1::difference_type difference_type;
typedef typename _I1::__storage_type __storage_type;
- static const unsigned __bits_per_word = _I1::__bits_per_word;
+ const int __bits_per_word = _I1::__bits_per_word;
difference_type __n = __last - __first;
if (__n > 0)
{
@@ -959,7 +959,7 @@ __equal_unaligned(__bit_iterator<_Cp, _I
typedef __bit_iterator<_Cp, _IC1> _It;
typedef typename _It::difference_type difference_type;
typedef typename _It::__storage_type __storage_type;
- static const unsigned __bits_per_word = _It::__bits_per_word;
+ static const int __bits_per_word = _It::__bits_per_word;
difference_type __n = __last1 - __first1;
if (__n > 0)
{
@@ -1041,7 +1041,7 @@ __equal_aligned(__bit_iterator<_Cp, _IC1
typedef __bit_iterator<_Cp, _IC1> _It;
typedef typename _It::difference_type difference_type;
typedef typename _It::__storage_type __storage_type;
- static const unsigned __bits_per_word = _It::__bits_per_word;
+ static const int __bits_per_word = _It::__bits_per_word;
difference_type __n = __last1 - __first1;
if (__n > 0)
{
Modified: libcxx/trunk/include/deque
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/deque?rev=290469&r1=290468&r2=290469&view=diff
==============================================================================
--- libcxx/trunk/include/deque (original)
+++ libcxx/trunk/include/deque Fri Dec 23 18:24:44 2016
@@ -2735,7 +2735,7 @@ deque<_Tp, _Allocator>::erase(const_iter
difference_type __pos = __f - __b;
iterator __p = __b + __pos;
allocator_type& __a = __base::__alloc();
- if (__pos <= (__base::size() - 1) / 2)
+ if (static_cast<size_t>(__pos) <= (__base::size() - 1) / 2)
{ // erase from front
_VSTD::move_backward(__b, __p, _VSTD::next(__p));
__alloc_traits::destroy(__a, _VSTD::addressof(*__b));
@@ -2773,7 +2773,7 @@ deque<_Tp, _Allocator>::erase(const_iter
if (__n > 0)
{
allocator_type& __a = __base::__alloc();
- if (__pos <= (__base::size() - __n) / 2)
+ if (static_cast<size_t>(__pos) <= (__base::size() - __n) / 2)
{ // erase from front
iterator __i = _VSTD::move_backward(__b, __p, __p + __n);
for (; __b != __i; ++__b)
Modified: libcxx/trunk/include/istream
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/istream?rev=290469&r1=290468&r2=290469&view=diff
==============================================================================
--- libcxx/trunk/include/istream (original)
+++ libcxx/trunk/include/istream Fri Dec 23 18:24:44 2016
@@ -1647,7 +1647,7 @@ operator>>(basic_istream<_CharT, _Traits
{
basic_string<_CharT, _Traits> __str;
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
- streamsize __c = 0;
+ size_t __c = 0;
ios_base::iostate __err = ios_base::goodbit;
_CharT __zero = __ct.widen('0');
_CharT __one = __ct.widen('1');
Modified: libcxx/trunk/include/random
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/random?rev=290469&r1=290468&r2=290469&view=diff
==============================================================================
--- libcxx/trunk/include/random (original)
+++ libcxx/trunk/include/random Fri Dec 23 18:24:44 2016
@@ -2817,6 +2817,7 @@ class _LIBCPP_TYPE_VIS_ONLY discard_bloc
static_assert( 0 < __r, "discard_block_engine invalid parameters");
static_assert(__r <= __p, "discard_block_engine invalid parameters");
+ static_assert(__r <= INT_MAX, "discard_block_engine invalid parameters");
public:
// types
typedef typename _Engine::result_type result_type;
@@ -2918,7 +2919,7 @@ template<class _Engine, size_t __p, size
typename discard_block_engine<_Engine, __p, __r>::result_type
discard_block_engine<_Engine, __p, __r>::operator()()
{
- if (__n_ >= __r)
+ if (__n_ >= static_cast<int>(__r))
{
__e_.discard(__p - __r);
__n_ = 0;
Modified: libcxx/trunk/include/regex
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=290469&r1=290468&r2=290469&view=diff
==============================================================================
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Fri Dec 23 18:24:44 2016
@@ -6186,7 +6186,7 @@ private:
_Position __position_;
const value_type* __result_;
value_type __suffix_;
- ptrdiff_t _N_;
+ ptrdiff_t __n_;
vector<int> __subs_;
public:
@@ -6269,10 +6269,10 @@ public:
private:
void __init(_BidirectionalIterator __a, _BidirectionalIterator __b);
void __establish_result () {
- if (__subs_[_N_] == -1)
+ if (__subs_[__n_] == -1)
__result_ = &__position_->prefix();
else
- __result_ = &(*__position_)[__subs_[_N_]];
+ __result_ = &(*__position_)[__subs_[__n_]];
}
};
@@ -6281,7 +6281,7 @@ regex_token_iterator<_BidirectionalItera
regex_token_iterator()
: __result_(nullptr),
__suffix_(),
- _N_(0)
+ __n_(0)
{
}
@@ -6292,7 +6292,7 @@ regex_token_iterator<_BidirectionalItera
{
if (__position_ != _Position())
__establish_result ();
- else if (__subs_[_N_] == -1)
+ else if (__subs_[__n_] == -1)
{
__suffix_.matched = true;
__suffix_.first = __a;
@@ -6309,7 +6309,7 @@ regex_token_iterator<_BidirectionalItera
const regex_type& __re, int __submatch,
regex_constants::match_flag_type __m)
: __position_(__a, __b, __re, __m),
- _N_(0),
+ __n_(0),
__subs_(1, __submatch)
{
__init(__a, __b);
@@ -6321,7 +6321,7 @@ regex_token_iterator<_BidirectionalItera
const regex_type& __re, const vector<int>& __submatches,
regex_constants::match_flag_type __m)
: __position_(__a, __b, __re, __m),
- _N_(0),
+ __n_(0),
__subs_(__submatches)
{
__init(__a, __b);
@@ -6336,7 +6336,7 @@ regex_token_iterator<_BidirectionalItera
initializer_list<int> __submatches,
regex_constants::match_flag_type __m)
: __position_(__a, __b, __re, __m),
- _N_(0),
+ __n_(0),
__subs_(__submatches)
{
__init(__a, __b);
@@ -6352,7 +6352,7 @@ regex_token_iterator<_BidirectionalItera
const int (&__submatches)[_Np],
regex_constants::match_flag_type __m)
: __position_(__a, __b, __re, __m),
- _N_(0),
+ __n_(0),
__subs_(__submatches, __submatches + _Np)
{
__init(__a, __b);
@@ -6364,7 +6364,7 @@ regex_token_iterator<_BidirectionalItera
: __position_(__x.__position_),
__result_(__x.__result_),
__suffix_(__x.__suffix_),
- _N_(__x._N_),
+ __n_(__x.__n_),
__subs_(__x.__subs_)
{
if (__x.__result_ == &__x.__suffix_)
@@ -6386,7 +6386,7 @@ regex_token_iterator<_BidirectionalItera
else
__result_ = __x.__result_;
__suffix_ = __x.__suffix_;
- _N_ = __x._N_;
+ __n_ = __x.__n_;
__subs_ = __x.__subs_;
if ( __result_ != nullptr && __result_ != &__suffix_ )
@@ -6409,7 +6409,7 @@ regex_token_iterator<_BidirectionalItera
return false;
if (__result_ == &__suffix_ || __x.__result_ == &__x.__suffix_)
return false;
- return __position_ == __x.__position_ && _N_ == __x._N_ &&
+ return __position_ == __x.__position_ && __n_ == __x.__n_ &&
__subs_ == __x.__subs_;
}
@@ -6420,14 +6420,14 @@ regex_token_iterator<_BidirectionalItera
_Position __prev = __position_;
if (__result_ == &__suffix_)
__result_ = nullptr;
- else if (_N_ + 1 < __subs_.size())
+ else if (static_cast<size_t>(__n_ + 1) < __subs_.size())
{
- ++_N_;
+ ++__n_;
__establish_result();
}
else
{
- _N_ = 0;
+ __n_ = 0;
++__position_;
if (__position_ != _Position())
__establish_result();
Modified: libcxx/trunk/test/libcxx/test/config.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=290469&r1=290468&r2=290469&view=diff
==============================================================================
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Fri Dec 23 18:24:44 2016
@@ -659,13 +659,11 @@ class Configuration(object):
# These warnings should be enabled in order to support the MSVC
# team using the test suite; They enable the warnings below and
# expect the test suite to be clean.
- self.cxx.addWarningFlagIfSupported('-Wno-sign-compare')
+ self.cxx.addWarningFlagIfSupported('-Wsign-compare')
self.cxx.addWarningFlagIfSupported('-Wunused-variable')
self.cxx.addWarningFlagIfSupported('-Wunused-parameter')
# FIXME: Enable the two warnings below.
self.cxx.addWarningFlagIfSupported('-Wno-conversion')
- # TODO(EricWF) Remove the unused warnings once the test suite
- # compiles clean with them.
self.cxx.addWarningFlagIfSupported('-Wno-unused-local-typedef')
std = self.get_lit_conf('std', None)
if std in ['c++98', 'c++03']:
More information about the cfe-commits
mailing list