Skip to content

Commit

Permalink
fix or silence compiler warnings about unreachable code, narrowing, a…
Browse files Browse the repository at this point in the history
…nd unsafe functions

Signed-off-by: Daniela Engert <[email protected]>
  • Loading branch information
DanielaE committed May 1, 2018
1 parent ca31ca1 commit 22c0e4d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
#include <stdexcept>
#include <stdint.h>

#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4702 4244)
#endif

#include "core.h"

#ifdef _SECURE_SCL
Expand Down Expand Up @@ -3606,4 +3611,8 @@ operator"" _a(const wchar_t *s, std::size_t) { return {s}; }
# pragma clang diagnostic pop
#endif

#ifdef _MSC_VER
#pragma warning(pop)
#endif

#endif // FMT_FORMAT_H_
10 changes: 10 additions & 0 deletions include/fmt/printf.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

#include "ostream.h"

#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4702)
#endif

namespace fmt {
namespace internal {

Expand Down Expand Up @@ -657,4 +662,9 @@ inline int fprintf(std::ostream &os, string_view format_str,
}
} // namespace fmt


#ifdef _MSC_VER
#pragma warning(pop)
#endif

#endif // FMT_PRINTF_H_
13 changes: 13 additions & 0 deletions include/fmt/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
#include "format.h"
#include <ctime>

#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4702)
#endif

namespace fmt {

namespace internal{
Expand Down Expand Up @@ -42,12 +47,14 @@ inline std::tm localtime(std::time_t time) {

bool fallback(int res) { return res == 0; }

#ifndef _MSC_VER
bool fallback(internal::null<>) {
using namespace fmt::internal;
std::tm *tm = std::localtime(&time_);
if (tm) tm_ = *tm;
return tm != FMT_NULL;
}
#endif
};
LocalTime lt(time);
if (lt.run())
Expand Down Expand Up @@ -79,11 +86,13 @@ inline std::tm gmtime(std::time_t time) {

bool fallback(int res) { return res == 0; }

#ifndef _MSC_VER
bool fallback(internal::null<>) {
std::tm *tm = std::gmtime(&time_);
if (tm) tm_ = *tm;
return tm != FMT_NULL;
}
#endif
};
GMTime gt(time);
if (gt.run())
Expand Down Expand Up @@ -148,4 +157,8 @@ struct formatter<std::tm, Char> {
};
}

#ifdef _MSC_VER
#pragma warning(pop)
#endif

#endif // FMT_TIME_H_

0 comments on commit 22c0e4d

Please sign in to comment.