Fix -Wimplicit-fallthrough warnings from GCC 8
Adds `FALLTHROUGH` macro to specify when a fallthrough is intentional.
Can be replaced by `[[fallthrough]]` if/when we switch to C++17.
The warning is now enabled by default for GCC on `extra` warnings level
(part of GCC's `-Wextra`). It's not enabled in Clang's `-Wextra` yet,
but we could enable it manually once we switch to C++11. There's no
equivalent feature in MSVC for now.
Fixes #26135.
(cherry picked from commit fc370b3feb)
This commit is contained in:
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "collision_object_2d.h"
|
||||
|
||||
#include "scene/scene_string_names.h"
|
||||
#include "servers/physics_2d_server.h"
|
||||
|
||||
@ -56,7 +57,7 @@ void CollisionObject2D::_notification(int p_what) {
|
||||
_update_pickable();
|
||||
|
||||
//get space
|
||||
}
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_ENTER_CANVAS: {
|
||||
|
||||
@ -64,7 +65,7 @@ void CollisionObject2D::_notification(int p_what) {
|
||||
Physics2DServer::get_singleton()->area_attach_canvas_instance_id(rid, get_canvas_layer_instance_id());
|
||||
else
|
||||
Physics2DServer::get_singleton()->body_attach_canvas_instance_id(rid, get_canvas_layer_instance_id());
|
||||
}
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_VISIBILITY_CHANGED: {
|
||||
|
||||
@ -101,7 +102,7 @@ void CollisionObject2D::_notification(int p_what) {
|
||||
Physics2DServer::get_singleton()->area_attach_canvas_instance_id(rid, 0);
|
||||
else
|
||||
Physics2DServer::get_singleton()->body_attach_canvas_instance_id(rid, 0);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ void CollisionObject::_notification(int p_what) {
|
||||
|
||||
_update_pickable();
|
||||
//get space
|
||||
};
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_TRANSFORM_CHANGED: {
|
||||
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "button.h"
|
||||
|
||||
#include "core/translation.h"
|
||||
#include "servers/visual_server.h"
|
||||
|
||||
@ -102,6 +103,7 @@ void Button::_notification(int p_what) {
|
||||
|
||||
break;
|
||||
}
|
||||
FALLTHROUGH;
|
||||
}
|
||||
case DRAW_PRESSED: {
|
||||
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "line_edit.h"
|
||||
|
||||
#include "core/message_queue.h"
|
||||
#include "core/os/keyboard.h"
|
||||
#include "core/os/os.h"
|
||||
@ -320,7 +321,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
|
||||
handled = false;
|
||||
break;
|
||||
}
|
||||
// numlock disabled. fallthrough to key_left
|
||||
FALLTHROUGH;
|
||||
}
|
||||
case KEY_LEFT: {
|
||||
|
||||
@ -367,7 +368,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
|
||||
handled = false;
|
||||
break;
|
||||
}
|
||||
// numlock disabled. fallthrough to key_right
|
||||
FALLTHROUGH;
|
||||
}
|
||||
case KEY_RIGHT: {
|
||||
|
||||
@ -474,7 +475,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
|
||||
handled = false;
|
||||
break;
|
||||
}
|
||||
// numlock disabled. fallthrough to key_home
|
||||
FALLTHROUGH;
|
||||
}
|
||||
case KEY_HOME: {
|
||||
|
||||
@ -487,7 +488,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
|
||||
handled = false;
|
||||
break;
|
||||
}
|
||||
// numlock disabled. fallthrough to key_end
|
||||
FALLTHROUGH;
|
||||
}
|
||||
case KEY_END: {
|
||||
|
||||
|
||||
@ -2517,7 +2517,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
|
||||
scancode_handled = false;
|
||||
break;
|
||||
}
|
||||
// numlock disabled. fallthrough to key_left
|
||||
FALLTHROUGH;
|
||||
}
|
||||
case KEY_LEFT: {
|
||||
|
||||
@ -2580,7 +2580,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
|
||||
scancode_handled = false;
|
||||
break;
|
||||
}
|
||||
// numlock disabled. fallthrough to key_right
|
||||
FALLTHROUGH;
|
||||
}
|
||||
case KEY_RIGHT: {
|
||||
|
||||
@ -2641,7 +2641,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
|
||||
scancode_handled = false;
|
||||
break;
|
||||
}
|
||||
// numlock disabled. fallthrough to key_up
|
||||
FALLTHROUGH;
|
||||
}
|
||||
case KEY_UP: {
|
||||
|
||||
@ -2694,7 +2694,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
|
||||
scancode_handled = false;
|
||||
break;
|
||||
}
|
||||
// numlock disabled. fallthrough to key_down
|
||||
FALLTHROUGH;
|
||||
}
|
||||
case KEY_DOWN: {
|
||||
|
||||
@ -2817,11 +2817,10 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
|
||||
scancode_handled = false;
|
||||
break;
|
||||
}
|
||||
// numlock disabled. fallthrough to key_home
|
||||
FALLTHROUGH;
|
||||
}
|
||||
#ifdef APPLE_STYLE_KEYS
|
||||
case KEY_HOME: {
|
||||
|
||||
#ifdef APPLE_STYLE_KEYS
|
||||
if (k->get_shift())
|
||||
_pre_shift_selection();
|
||||
|
||||
@ -2831,11 +2830,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
|
||||
_post_shift_selection();
|
||||
else if (k->get_command() || k->get_control())
|
||||
deselect();
|
||||
|
||||
} break;
|
||||
#else
|
||||
case KEY_HOME: {
|
||||
|
||||
if (k->get_shift())
|
||||
_pre_shift_selection();
|
||||
|
||||
@ -2876,19 +2871,17 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
|
||||
deselect();
|
||||
_cancel_completion();
|
||||
completion_hint = "";
|
||||
|
||||
} break;
|
||||
#endif
|
||||
} break;
|
||||
case KEY_KP_1: {
|
||||
if (k->get_unicode() != 0) {
|
||||
scancode_handled = false;
|
||||
break;
|
||||
}
|
||||
// numlock disabled. fallthrough to key_end
|
||||
FALLTHROUGH;
|
||||
}
|
||||
#ifdef APPLE_STYLE_KEYS
|
||||
case KEY_END: {
|
||||
|
||||
#ifdef APPLE_STYLE_KEYS
|
||||
if (k->get_shift())
|
||||
_pre_shift_selection();
|
||||
|
||||
@ -2898,11 +2891,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
|
||||
_post_shift_selection();
|
||||
else if (k->get_command() || k->get_control())
|
||||
deselect();
|
||||
|
||||
} break;
|
||||
#else
|
||||
case KEY_END: {
|
||||
|
||||
if (k->get_shift())
|
||||
_pre_shift_selection();
|
||||
|
||||
@ -2929,15 +2918,14 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
|
||||
|
||||
_cancel_completion();
|
||||
completion_hint = "";
|
||||
|
||||
} break;
|
||||
#endif
|
||||
} break;
|
||||
case KEY_KP_9: {
|
||||
if (k->get_unicode() != 0) {
|
||||
scancode_handled = false;
|
||||
break;
|
||||
}
|
||||
// numlock disabled. fallthrough to key_pageup
|
||||
FALLTHROUGH;
|
||||
}
|
||||
case KEY_PAGEUP: {
|
||||
|
||||
@ -2960,7 +2948,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
|
||||
scancode_handled = false;
|
||||
break;
|
||||
}
|
||||
// numlock disabled. fallthrough to key_pagedown
|
||||
FALLTHROUGH;
|
||||
}
|
||||
case KEY_PAGEDOWN: {
|
||||
|
||||
@ -3139,21 +3127,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
|
||||
|
||||
if (scancode_handled)
|
||||
accept_event();
|
||||
/*
|
||||
if (!scancode_handled && !k->get_command() && !k->get_alt()) {
|
||||
|
||||
if (k->get_unicode()>=32) {
|
||||
|
||||
if (readonly)
|
||||
break;
|
||||
|
||||
accept_event();
|
||||
} else {
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
if (k->get_scancode() == KEY_INSERT) {
|
||||
set_insert_mode(!insert_mode);
|
||||
accept_event();
|
||||
@ -3196,7 +3170,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
|
||||
end_complex_operation();
|
||||
}
|
||||
accept_event();
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "tree.h"
|
||||
#include <limits.h>
|
||||
|
||||
#include "core/math/math_funcs.h"
|
||||
#include "core/os/input.h"
|
||||
@ -43,6 +42,8 @@
|
||||
#include "editor/editor_node.h"
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
void TreeItem::move_to_top() {
|
||||
|
||||
if (!parent || parent->children == this)
|
||||
@ -940,6 +941,7 @@ int Tree::compute_item_height(TreeItem *p_item) const {
|
||||
int check_icon_h = cache.checked->get_height();
|
||||
if (height < check_icon_h)
|
||||
height = check_icon_h;
|
||||
FALLTHROUGH;
|
||||
}
|
||||
case TreeItem::CELL_MODE_STRING:
|
||||
case TreeItem::CELL_MODE_CUSTOM:
|
||||
|
||||
Reference in New Issue
Block a user