Merge pull request #220 from inguin/master

Fix warnings
This commit is contained in:
Victor Zverovich 2015-11-04 09:55:36 -05:00
commit 5b7dd17dff
2 changed files with 10 additions and 7 deletions

View File

@ -52,7 +52,7 @@
using fmt::internal::Arg; using fmt::internal::Arg;
// Check if exceptions are disabled. // Check if exceptions are disabled.
#if __GNUC__ && !__EXCEPTIONS #if defined(__GNUC__) && !defined(__EXCEPTIONS)
# define FMT_EXCEPTIONS 0 # define FMT_EXCEPTIONS 0
#endif #endif
#if defined(_MSC_VER) && !_HAS_EXCEPTIONS #if defined(_MSC_VER) && !_HAS_EXCEPTIONS
@ -1265,7 +1265,7 @@ FMT_FUNC void fmt::print(std::ostream &os, CStringRef format_str, ArgList args)
FMT_FUNC void fmt::print_colored(Color c, CStringRef format, ArgList args) { FMT_FUNC void fmt::print_colored(Color c, CStringRef format, ArgList args) {
char escape[] = "\x1b[30m"; char escape[] = "\x1b[30m";
escape[3] = '0' + static_cast<char>(c); escape[3] = static_cast<char>('0' + c);
std::fputs(escape, stdout); std::fputs(escape, stdout);
print(format, args); print(format, args);
std::fputs(RESET_COLOR, stdout); std::fputs(RESET_COLOR, stdout);

View File

@ -105,6 +105,9 @@ inline uint32_t clzll(uint64_t x) {
// Disable the warning about declaration shadowing because it affects too // Disable the warning about declaration shadowing because it affects too
// many valid cases. // many valid cases.
# pragma GCC diagnostic ignored "-Wshadow" # pragma GCC diagnostic ignored "-Wshadow"
// Disable the warning about implicit conversions that may change the sign of
// an integer; silencing it otherwise would require many explicit casts.
# pragma GCC diagnostic ignored "-Wsign-conversion"
# endif # endif
# if __cplusplus >= 201103L || defined __GXX_EXPERIMENTAL_CXX0X__ # if __cplusplus >= 201103L || defined __GXX_EXPERIMENTAL_CXX0X__
# define FMT_HAS_GXX_CXX11 1 # define FMT_HAS_GXX_CXX11 1
@ -778,7 +781,7 @@ inline void format_decimal(Char *buffer, UInt value, unsigned num_digits) {
// Integer division is slow so do it for a group of two digits instead // Integer division is slow so do it for a group of two digits instead
// of for every digit. The idea comes from the talk by Alexandrescu // of for every digit. The idea comes from the talk by Alexandrescu
// "Three Optimization Tips for C++". See speed-test for a comparison. // "Three Optimization Tips for C++". See speed-test for a comparison.
unsigned index = (value % 100) * 2; unsigned index = static_cast<unsigned>((value % 100) * 2);
value /= 100; value /= 100;
*--buffer = Data::DIGITS[index + 1]; *--buffer = Data::DIGITS[index + 1];
*--buffer = Data::DIGITS[index]; *--buffer = Data::DIGITS[index];
@ -911,7 +914,7 @@ struct WCharHelper<T, wchar_t> {
template <typename T> template <typename T>
class IsConvertibleToInt { class IsConvertibleToInt {
private: protected:
typedef char yes[1]; typedef char yes[1];
typedef char no[2]; typedef char no[2];
@ -2330,7 +2333,7 @@ void BasicWriter<Char>::write_int(T value, Spec spec) {
Char *p = get(prepare_int_buffer(num_digits, spec, prefix, prefix_size)); Char *p = get(prepare_int_buffer(num_digits, spec, prefix, prefix_size));
n = abs_value; n = abs_value;
do { do {
*p-- = '0' + (n & 1); *p-- = static_cast<Char>('0' + (n & 1));
} while ((n >>= 1) != 0); } while ((n >>= 1) != 0);
break; break;
} }
@ -2345,7 +2348,7 @@ void BasicWriter<Char>::write_int(T value, Spec spec) {
Char *p = get(prepare_int_buffer(num_digits, spec, prefix, prefix_size)); Char *p = get(prepare_int_buffer(num_digits, spec, prefix, prefix_size));
n = abs_value; n = abs_value;
do { do {
*p-- = '0' + (n & 7); *p-- = static_cast<Char>('0' + (n & 7));
} while ((n >>= 3) != 0); } while ((n >>= 3) != 0);
break; break;
} }
@ -2810,7 +2813,7 @@ class FormatInt {
// Integer division is slow so do it for a group of two digits instead // Integer division is slow so do it for a group of two digits instead
// of for every digit. The idea comes from the talk by Alexandrescu // of for every digit. The idea comes from the talk by Alexandrescu
// "Three Optimization Tips for C++". See speed-test for a comparison. // "Three Optimization Tips for C++". See speed-test for a comparison.
unsigned index = (value % 100) * 2; unsigned index = static_cast<unsigned>((value % 100) * 2);
value /= 100; value /= 100;
*--buffer_end = internal::Data::DIGITS[index + 1]; *--buffer_end = internal::Data::DIGITS[index + 1];
*--buffer_end = internal::Data::DIGITS[index]; *--buffer_end = internal::Data::DIGITS[index];