diff --git a/src/ai/actions.cpp b/src/ai/actions.cpp index 58dae6496e35..db6d12f69363 100644 --- a/src/ai/actions.cpp +++ b/src/ai/actions.cpp @@ -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; } @@ -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; } diff --git a/src/desktop/version.cpp b/src/desktop/version.cpp index d0e974dc308c..ba5c17f14797 100644 --- a/src/desktop/version.cpp +++ b/src/desktop/version.cpp @@ -295,7 +295,7 @@ std::string os_version() } break; } // else fallback to default - FALLTHROUGH; + [[fallthrough]]; default: if(v.wProductType != VER_NT_WORKSTATION) { version = "Server"; diff --git a/src/editor/controller/editor_controller.cpp b/src/editor/controller/editor_controller.cpp index 0bb843ebee3c..b6956c2f92e8 100644 --- a/src/editor/controller/editor_controller.cpp +++ b/src/editor/controller/editor_controller.cpp @@ -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; @@ -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; diff --git a/src/game_initialization/multiplayer.cpp b/src/game_initialization/multiplayer.cpp index 1f7c6b37dc67..561ff2d03617 100644 --- a/src/game_initialization/multiplayer.cpp +++ b/src/game_initialization/multiplayer.cpp @@ -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; diff --git a/src/global.hpp b/src/global.hpp index a73272ecb0c5..8cf21e121ae2 100644 --- a/src/global.hpp +++ b/src/global.hpp @@ -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 @@ -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 diff --git a/src/gui/auxiliary/iterator/walker_grid.cpp b/src/gui/auxiliary/iterator/walker_grid.cpp index 4cfc77461714..c2873c6ffac0 100644 --- a/src/gui/auxiliary/iterator/walker_grid.cpp +++ b/src/gui/auxiliary/iterator/walker_grid.cpp @@ -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; diff --git a/src/gui/auxiliary/iterator/walker_tree_node.cpp b/src/gui/auxiliary/iterator/walker_tree_node.cpp index df9eb283414d..8b1882b95410 100644 --- a/src/gui/auxiliary/iterator/walker_tree_node.cpp +++ b/src/gui/auxiliary/iterator/walker_tree_node.cpp @@ -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; diff --git a/src/gui/auxiliary/iterator/walker_widget.cpp b/src/gui/auxiliary/iterator/walker_widget.cpp index 858f40f29352..0ddbd7e8e886 100644 --- a/src/gui/auxiliary/iterator/walker_widget.cpp +++ b/src/gui/auxiliary/iterator/walker_widget.cpp @@ -46,7 +46,7 @@ walker_base::state_t widget::next(const level level) widget_ = nullptr; return invalid; } - FALLTHROUGH; + [[fallthrough]]; case internal: case child: break; diff --git a/src/gui/dialogs/file_dialog.cpp b/src/gui/dialogs/file_dialog.cpp index 6211308eebd7..d558d3360d08 100644 --- a/src/gui/dialogs/file_dialog.cpp +++ b/src/gui/dialogs/file_dialog.cpp @@ -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}})); diff --git a/src/gui/dialogs/message.cpp b/src/gui/dialogs/message.cpp index d7a4c5d839b6..59cc6622220f 100644 --- a/src/gui/dialogs/message.cpp +++ b/src/gui/dialogs/message.cpp @@ -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; diff --git a/src/play_controller.cpp b/src/play_controller.cpp index 67e675524297..93b313e02442 100644 --- a/src/play_controller.cpp +++ b/src/play_controller.cpp @@ -683,7 +683,7 @@ void play_controller::tab() case gui::TEXTBOX_COMMAND: { std::vector 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()) { diff --git a/src/scripting/lua_common.cpp b/src/scripting/lua_common.cpp index 906c925c782a..8c5e7ffd6923 100644 --- a/src/scripting/lua_common.cpp +++ b/src/scripting/lua_common.cpp @@ -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: diff --git a/src/serialization/parser.cpp b/src/serialization/parser.cpp index ad1dab242987..7a1be40d7698 100644 --- a/src/serialization/parser.cpp +++ b/src/serialization/parser.cpp @@ -389,7 +389,7 @@ void parser::parse_variable() buffer += " "; } - FALLTHROUGH; + [[fallthrough]]; default: buffer += tok_.current_token().value; @@ -408,7 +408,7 @@ void parser::parse_variable() continue; } - FALLTHROUGH; + [[fallthrough]]; case token::END: goto finish; diff --git a/src/serialization/tokenizer.cpp b/src/serialization/tokenizer.cpp index 12c8556906f5..4b69c718bcde 100644 --- a/src/serialization/tokenizer.cpp +++ b/src/serialization/tokenizer.cpp @@ -132,7 +132,7 @@ const token &tokenizer::next_token() token_.value = current_; break; } - FALLTHROUGH; + [[fallthrough]]; default: if (is_alnum(current_) || current_ == '$') {