fix compile warnings for Xcode

This commit is contained in:
Dix Lorenz 2015-02-06 12:43:01 +01:00
parent ba17cca432
commit de5b4812b2
2 changed files with 21 additions and 4 deletions

View File

@ -66,8 +66,10 @@ using fmt::internal::Arg;
#ifndef FMT_THROW
# if FMT_EXCEPTIONS
# define FMT_THROW(x) throw x
# define FMT_RETURNAFTERTHROW(x)
# else
# define FMT_THROW(x) assert(false)
# define FMT_RETURNAFTERTHROW(x) return x
# endif
#endif
@ -251,7 +253,7 @@ class WidthHandler : public fmt::internal::ArgVisitor<WidthHandler, unsigned> {
unsigned visit_unhandled_arg() {
FMT_THROW(fmt::FormatError("width is not integer"));
return 0;
FMT_RETURNAFTERTHROW(0);
}
template <typename T>
@ -273,7 +275,7 @@ class PrecisionHandler :
public:
unsigned visit_unhandled_arg() {
FMT_THROW(fmt::FormatError("precision is not integer"));
return 0;
FMT_RETURNAFTERTHROW(0);
}
template <typename T>
@ -625,7 +627,7 @@ void fmt::BasicWriter<Char>::write_str(
if (*str_value)
str_size = std::char_traits<StrChar>::length(str_value);
}
if (spec.precision_ >= 0 && spec.precision_ < str_size)
if (spec.precision_ >= 0 && static_cast<std::size_t>(spec.precision_) < str_size)
str_size = spec.precision_;
write_str(str_value, str_size, spec);
}

View File

@ -60,6 +60,16 @@
# define FMT_GCC_EXTENSION
#endif
#define FMT_CLANGFALLTHROUGH
#ifdef __clang__
#pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
#ifdef NDEBUG
#undef FMT_CLANGFALLTHROUGH
#define FMT_CLANGFALLTHROUGH [[clang::fallthrough]];
#endif
#endif
#ifdef __GNUC_LIBSTD__
# define FMT_GNUC_LIBSTD_VERSION (__GNUC_LIBSTD__ * 100 + __GNUC_LIBSTD_MINOR__)
#endif
@ -865,7 +875,8 @@ class ArgVisitor {
default:
assert(false);
// Fall through.
case Arg::INT:
FMT_CLANGFALLTHROUGH
case Arg::INT:
return FMT_DISPATCH(visit_int(arg.int_value));
case Arg::UINT:
return FMT_DISPATCH(visit_uint(arg.uint_value));
@ -2442,6 +2453,10 @@ FMT_VARIADIC(int, fprintf, std::FILE *, StringRef)
# pragma GCC diagnostic pop
#endif
#ifdef __clang__
# pragma clang diagnostic pop
#endif
#ifdef FMT_HEADER_ONLY
# include "format.cc"
#endif