From 81d56638259792812e14dce01f9e3f74174c3cae Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 3 Jun 2018 20:10:17 +0200 Subject: [PATCH] Fix more bogus MSVC warnings about unreachable code (#748) --- include/fmt/core.h | 4 ++-- include/fmt/format.h | 12 ++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 96bbf27c..612aa195 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -740,8 +740,8 @@ class basic_parse_context : private ErrorHandler { FMT_CONSTEXPR bool check_arg_id(unsigned) { if (next_arg_id_ > 0) { - on_error("cannot switch from automatic to manual argument indexing"); - return false; + return on_error( + "cannot switch from automatic to manual argument indexing"), false; } next_arg_id_ = -1; return true; diff --git a/include/fmt/format.h b/include/fmt/format.h index c4c9fea8..bf125845 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1322,8 +1322,7 @@ template FMT_CONSTEXPR unsigned basic_parse_context::next_arg_id() { if (next_arg_id_ >= 0) return internal::to_unsigned(next_arg_id_++); - on_error("cannot switch from manual to automatic argument indexing"); - return 0; + return on_error("cannot switch from manual to automatic argument indexing"), 0; } struct format_string {}; @@ -1703,8 +1702,7 @@ class width_checker: public function { template FMT_CONSTEXPR typename std::enable_if< !is_integer::value, unsigned long long>::type operator()(T) { - handler_.on_error("width is not integer"); - return 0; + return handler_.on_error("width is not integer"), 0; } private: @@ -2058,10 +2056,8 @@ FMT_CONSTEXPR Iterator parse_format_specs(Iterator it, SpecHandler &&handler) { } if (align != ALIGN_DEFAULT) { if (p != it) { - if (c == '{') { - handler.on_error("invalid fill character '{'"); - return it; - } + if (c == '{') + return handler.on_error("invalid fill character '{'"), it; it += 2; handler.on_fill(c); } else ++it;