Fix warnings about unsigned long long as well.

This commit is contained in:
Victor Zverovich 2014-02-15 10:02:02 -08:00
parent 7325ebc965
commit 7561ff27e5

View File

@ -70,12 +70,6 @@
# define FMT_NOEXCEPT(expr) # define FMT_NOEXCEPT(expr)
#endif #endif
#if FMT_GCC_VERSION >= 406
# define FMT_GCC_DIAGNOSTIC
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wlong-long"
#endif
#if _MSC_VER #if _MSC_VER
# pragma warning(push) # pragma warning(push)
# pragma warning(disable: 4521) # pragma warning(disable: 4521)
@ -87,8 +81,10 @@ namespace fmt {
// that don't support the diagnostic pragma. // that don't support the diagnostic pragma.
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ typedef long long LongLong; __extension__ typedef long long LongLong;
__extension__ typedef unsigned long long ULongLong;
#else #else
typedef long long LongLong; typedef long long LongLong;
typedef unsigned long long ULongLong;
#endif #endif
namespace internal { namespace internal {
@ -241,7 +237,7 @@ template <>
struct IntTraits<long> : SignedIntTraits<long, unsigned long> {}; struct IntTraits<long> : SignedIntTraits<long, unsigned long> {};
template <> template <>
struct IntTraits<LongLong> : SignedIntTraits<LongLong, unsigned long long> {}; struct IntTraits<LongLong> : SignedIntTraits<LongLong, ULongLong> {};
template <typename T> template <typename T>
struct IsLongDouble { enum {VALUE = 0}; }; struct IsLongDouble { enum {VALUE = 0}; };
@ -542,7 +538,7 @@ DEFINE_INT_FORMATTERS(long)
DEFINE_INT_FORMATTERS(unsigned) DEFINE_INT_FORMATTERS(unsigned)
DEFINE_INT_FORMATTERS(unsigned long) DEFINE_INT_FORMATTERS(unsigned long)
DEFINE_INT_FORMATTERS(LongLong) DEFINE_INT_FORMATTERS(LongLong)
DEFINE_INT_FORMATTERS(unsigned long long) DEFINE_INT_FORMATTERS(ULongLong)
/** /**
\rst \rst
@ -732,8 +728,8 @@ class BasicWriter {
/** /**
Formats *value* and writes it to the stream. Formats *value* and writes it to the stream.
*/ */
BasicWriter &operator<<(unsigned long long value) { BasicWriter &operator<<(ULongLong value) {
return *this << IntFormatSpec<unsigned long long>(value); return *this << IntFormatSpec<ULongLong>(value);
} }
BasicWriter &operator<<(double value) { BasicWriter &operator<<(double value) {
@ -984,7 +980,7 @@ class BasicFormatter {
long long_value; long long_value;
unsigned long ulong_value; unsigned long ulong_value;
LongLong long_long_value; LongLong long_long_value;
unsigned long long ulong_long_value; ULongLong ulong_long_value;
long double long_double_value; long double long_double_value;
const void *pointer_value; const void *pointer_value;
StringValue string; StringValue string;
@ -1000,7 +996,7 @@ class BasicFormatter {
Arg(unsigned long value) : type(ULONG), ulong_value(value), formatter(0) {} Arg(unsigned long value) : type(ULONG), ulong_value(value), formatter(0) {}
Arg(LongLong value) Arg(LongLong value)
: type(LONG_LONG), long_long_value(value), formatter(0) {} : type(LONG_LONG), long_long_value(value), formatter(0) {}
Arg(unsigned long long value) Arg(ULongLong value)
: type(ULONG_LONG), ulong_long_value(value), formatter(0) {} : type(ULONG_LONG), ulong_long_value(value), formatter(0) {}
Arg(float value) : type(DOUBLE), double_value(value), formatter(0) {} Arg(float value) : type(DOUBLE), double_value(value), formatter(0) {}
Arg(double value) : type(DOUBLE), double_value(value), formatter(0) {} Arg(double value) : type(DOUBLE), double_value(value), formatter(0) {}
@ -1066,8 +1062,6 @@ class BasicFormatter {
int num_open_braces_; int num_open_braces_;
int next_arg_index_; int next_arg_index_;
typedef unsigned long long ULongLong;
friend class internal::FormatterProxy<Char>; friend class internal::FormatterProxy<Char>;
// Forbid copying from a temporary as in the following example: // Forbid copying from a temporary as in the following example:
@ -1293,12 +1287,12 @@ class FormatInt {
private: private:
// Buffer should be large enough to hold all digits (digits10 + 1), // Buffer should be large enough to hold all digits (digits10 + 1),
// a sign and a null character. // a sign and a null character.
enum {BUFFER_SIZE = std::numeric_limits<unsigned long long>::digits10 + 3}; enum {BUFFER_SIZE = std::numeric_limits<ULongLong>::digits10 + 3};
mutable char buffer_[BUFFER_SIZE]; mutable char buffer_[BUFFER_SIZE];
char *str_; char *str_;
// Formats value in reverse and returns the number of digits. // Formats value in reverse and returns the number of digits.
char *FormatDecimal(unsigned long long value) { char *FormatDecimal(ULongLong value) {
char *buffer_end = buffer_ + BUFFER_SIZE - 1; char *buffer_end = buffer_ + BUFFER_SIZE - 1;
while (value >= 100) { while (value >= 100) {
// 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
@ -1320,7 +1314,7 @@ class FormatInt {
} }
void FormatSigned(LongLong value) { void FormatSigned(LongLong value) {
unsigned long long abs_value = value; ULongLong abs_value = value;
bool negative = value < 0; bool negative = value < 0;
if (negative) if (negative)
abs_value = 0 - value; abs_value = 0 - value;
@ -1335,7 +1329,7 @@ class FormatInt {
explicit FormatInt(LongLong value) { FormatSigned(value); } explicit FormatInt(LongLong value) { FormatSigned(value); }
explicit FormatInt(unsigned value) : str_(FormatDecimal(value)) {} explicit FormatInt(unsigned value) : str_(FormatDecimal(value)) {}
explicit FormatInt(unsigned long value) : str_(FormatDecimal(value)) {} explicit FormatInt(unsigned long value) : str_(FormatDecimal(value)) {}
explicit FormatInt(unsigned long long value) : str_(FormatDecimal(value)) {} explicit FormatInt(ULongLong value) : str_(FormatDecimal(value)) {}
/** /**
Returns the number of characters written to the output buffer. Returns the number of characters written to the output buffer.
@ -1428,10 +1422,6 @@ inline Formatter<Write> Print(StringRef format) {
} }
} }
#ifdef FMT_GCC_DIAGNOSTIC
# pragma GCC diagnostic pop
#endif
#if _MSC_VER #if _MSC_VER
# pragma warning(pop) # pragma warning(pop)
#endif #endif