Skip to content

Commit

Permalink
Fix more bogus MSVC warnings about unreachable code (#748)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Jun 3, 2018
1 parent 68f0ac8 commit f8d5220
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
4 changes: 2 additions & 2 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 9 additions & 18 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -1322,8 +1322,7 @@ template <typename Char, typename ErrorHandler>
FMT_CONSTEXPR unsigned basic_parse_context<Char, ErrorHandler>::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 {};
Expand Down Expand Up @@ -1703,8 +1702,7 @@ class width_checker: public function<unsigned long long> {
template <typename T>
FMT_CONSTEXPR typename std::enable_if<
!is_integer<T>::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:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -2102,10 +2098,8 @@ FMT_CONSTEXPR Iterator parse_format_specs(Iterator it, SpecHandler &&handler) {
handler.on_width(parse_nonnegative_int(it, handler));
} else if (*it == '{') {
it = parse_arg_id(it + 1, width_adapter<SpecHandler, char_type>(handler));
if (*it++ != '}') {
handler.on_error("invalid format string");
return it;
}
if (*it++ != '}')
return handler.on_error("invalid format string"), it;
}

// Parse precision.
Expand All @@ -2116,13 +2110,10 @@ FMT_CONSTEXPR Iterator parse_format_specs(Iterator it, SpecHandler &&handler) {
} else if (*it == '{') {
it = parse_arg_id(
it + 1, precision_adapter<SpecHandler, char_type>(handler));
if (*it++ != '}') {
handler.on_error("invalid format string");
return it;
}
if (*it++ != '}')
return handler.on_error("invalid format string"), it;
} else {
handler.on_error("missing precision specifier");
return it;
return handler.on_error("missing precision specifier"), it;
}
handler.end_precision();
}
Expand Down

0 comments on commit f8d5220

Please sign in to comment.