Skip to content

Commit

Permalink
Used [[fallthrough]] directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Jan 23, 2021
1 parent 52db6a9 commit 5df29bf
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/ai/actions.cpp
Expand Up @@ -592,7 +592,7 @@ void recall_result::do_check_before()
set_error(E_BAD_RECALL_LOCATION);
return;
}
FALLTHROUGH; // If the location was not specified, this counts as "OK".
[[fallthrough]]; // If the location was not specified, this counts as "OK".
case ::actions::RECRUIT_OK:
location_checked_ = true;
}
Expand Down Expand Up @@ -742,7 +742,7 @@ void recruit_result::do_check_before()
set_error(E_BAD_RECRUIT_LOCATION);
return;
}
FALLTHROUGH; // If the location was not specified, this counts as "OK".
[[fallthrough]]; // If the location was not specified, this counts as "OK".
case ::actions::RECRUIT_OK:
location_checked_ = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/desktop/version.cpp
Expand Up @@ -295,7 +295,7 @@ std::string os_version()
}
break;
} // else fallback to default
FALLTHROUGH;
[[fallthrough]];
default:
if(v.wProductType != VER_NT_WORKSTATION) {
version = "Server";
Expand Down
4 changes: 2 additions & 2 deletions src/editor/controller/editor_controller.cpp
Expand Up @@ -848,7 +848,7 @@ bool editor_controller::do_execute_command(const hotkey::hotkey_command& cmd, in
context_manager_->perform_refresh(editor_action_select_all());
return true;
}
FALLTHROUGH;
[[fallthrough]];
case HOTKEY_EDITOR_SELECT_INVERSE:
context_manager_->perform_refresh(editor_action_select_inverse());
return true;
Expand Down Expand Up @@ -945,7 +945,7 @@ bool editor_controller::do_execute_command(const hotkey::hotkey_command& cmd, in
if(context_manager_->toggle_update_transitions()) {
return true;
}
FALLTHROUGH;
[[fallthrough]];
case HOTKEY_EDITOR_UPDATE_TRANSITIONS:
context_manager_->refresh_all();
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/game_initialization/multiplayer.cpp
Expand Up @@ -580,7 +580,7 @@ bool mp_manager::enter_lobby_mode()
enter_create_mode();
break;
case gui2::dialogs::mp_lobby::JOIN:
FALLTHROUGH;
[[fallthrough]];
case gui2::dialogs::mp_lobby::OBSERVE:
enter_wait_mode(dlg_joined_game_id, dlg_retval == gui2::dialogs::mp_lobby::OBSERVE);
break;
Expand Down
17 changes: 0 additions & 17 deletions src/global.hpp
Expand Up @@ -15,13 +15,6 @@
#pragma once

#ifdef _MSC_VER

#if _MSVC_LANG > 201402 // fallthrough only supported when MSVC targets later than C++14
#define FALLTHROUGH [[fallthrough]]
#else
#define FALLTHROUGH
#endif

#endif //_MSC_VER

#ifdef NDEBUG
Expand All @@ -42,17 +35,7 @@
#endif

#if defined(__clang__)

// All supported versions of clang have these
#define FALLTHROUGH [[clang::fallthrough]]

#endif

#if defined(__GNUC__) && !defined(__clang__)
// Fallthrough is supported from GCC 7 up
#if __GNUC__ >= 7
#define FALLTHROUGH [[fallthrough]]
#else
#define FALLTHROUGH
#endif
#endif
2 changes: 1 addition & 1 deletion src/gui/auxiliary/iterator/walker_grid.cpp
Expand Up @@ -43,7 +43,7 @@ walker_base::state_t grid::next(const level level)
widget_ = nullptr;
return invalid;
}
FALLTHROUGH;
[[fallthrough]];
case internal:
assert(false);
return fail;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/auxiliary/iterator/walker_tree_node.cpp
Expand Up @@ -43,7 +43,7 @@ walker_base::state_t tree_node::next(const level level)
widget_ = nullptr;
return invalid;
}
FALLTHROUGH;
[[fallthrough]];
case internal:
assert(false);
return fail;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/auxiliary/iterator/walker_widget.cpp
Expand Up @@ -46,7 +46,7 @@ walker_base::state_t widget::next(const level level)
widget_ = nullptr;
return invalid;
}
FALLTHROUGH;
[[fallthrough]];
case internal:
case child:
break;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/dialogs/file_dialog.cpp
Expand Up @@ -327,7 +327,7 @@ bool file_dialog::process_submit_common(const std::string& name)
show_transient_error_message(VGETTEXT("The file or folder $path cannot be created.", {{"path", name}}));
break;
}
FALLTHROUGH;
[[fallthrough]];
case SELECTION_NOT_FOUND:
// We only get here if we aren't in save mode.
show_transient_error_message(VGETTEXT("The file or folder $path does not exist.", {{"path", name}}));
Expand Down
2 changes: 1 addition & 1 deletion src/gui/dialogs/message.cpp
Expand Up @@ -186,7 +186,7 @@ int show_message(const std::string& title,
case message::ok_cancel_buttons:
dlg.set_button_visible(message::ok, widget::visibility::visible);
dlg.set_button_caption(message::ok, _("OK"));
FALLTHROUGH;
[[fallthrough]];
case message::cancel_button:
dlg.set_button_visible(message::cancel, widget::visibility::visible);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/play_controller.cpp
Expand Up @@ -683,7 +683,7 @@ void play_controller::tab()
case gui::TEXTBOX_COMMAND: {
std::vector<std::string> commands = menu_handler_.get_commands_list();
dictionary.insert(commands.begin(), commands.end());
FALLTHROUGH; // we also want player names from the next case
[[fallthrough]]; // we also want player names from the next case
}
case gui::TEXTBOX_MESSAGE: {
for(const team& t : get_teams()) {
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/lua_common.cpp
Expand Up @@ -951,7 +951,7 @@ bool luaW_checkvariable(lua_State *L, variable_access_create& v, int n)
if (luaW_toconfig(L, n, cfg)) {
return true;
}
FALLTHROUGH;
[[fallthrough]];
}
default:
default_explicit:
Expand Down
4 changes: 2 additions & 2 deletions src/serialization/parser.cpp
Expand Up @@ -389,7 +389,7 @@ void parser::parse_variable()
buffer += " ";
}

FALLTHROUGH;
[[fallthrough]];

default:
buffer += tok_.current_token().value;
Expand All @@ -408,7 +408,7 @@ void parser::parse_variable()
continue;
}

FALLTHROUGH;
[[fallthrough]];

case token::END:
goto finish;
Expand Down
2 changes: 1 addition & 1 deletion src/serialization/tokenizer.cpp
Expand Up @@ -132,7 +132,7 @@ const token &tokenizer::next_token()
token_.value = current_;
break;
}
FALLTHROUGH;
[[fallthrough]];

default:
if (is_alnum(current_) || current_ == '$') {
Expand Down

0 comments on commit 5df29bf

Please sign in to comment.