mirror of
https://github.com/godotengine/godot.git
synced 2025-10-21 00:43:46 +00:00
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:
parent
3b703d6707
commit
fc18d637a8
18 changed files with 82 additions and 67 deletions
|
@ -777,7 +777,8 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
|
|||
}
|
||||
_add_warning(GDScriptWarning::UNASSIGNED_VARIABLE_OP_ASSIGN, -1, identifier.operator String());
|
||||
}
|
||||
} // fallthrough
|
||||
FALLTHROUGH;
|
||||
}
|
||||
case GDScriptTokenizer::TK_OP_ASSIGN: {
|
||||
lv->assignments += 1;
|
||||
lv->usages--; // Assignment is not really usage
|
||||
|
@ -3636,7 +3637,8 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
|
|||
return;
|
||||
}
|
||||
|
||||
}; //fallthrough to function
|
||||
FALLTHROUGH;
|
||||
}
|
||||
case GDScriptTokenizer::TK_PR_FUNCTION: {
|
||||
|
||||
bool _static = false;
|
||||
|
@ -4091,7 +4093,8 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
|
|||
break;
|
||||
}
|
||||
|
||||
}; //fallthrough to use the same
|
||||
FALLTHROUGH;
|
||||
}
|
||||
case Variant::REAL: {
|
||||
|
||||
if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "EASE") {
|
||||
|
@ -4516,6 +4519,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
|
|||
#ifdef DEBUG_ENABLED
|
||||
_add_warning(GDScriptWarning::DEPRECATED_KEYWORD, tokenizer->get_token_line(), "slave", "puppet");
|
||||
#endif
|
||||
FALLTHROUGH;
|
||||
case GDScriptTokenizer::TK_PR_PUPPET: {
|
||||
|
||||
//may be fallthrough from export, ignore if so
|
||||
|
@ -4583,7 +4587,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
|
|||
continue;
|
||||
} break;
|
||||
case GDScriptTokenizer::TK_PR_VAR: {
|
||||
//variale declaration and (eventual) initialization
|
||||
// variable declaration and (eventual) initialization
|
||||
|
||||
ClassNode::Member member;
|
||||
|
||||
|
@ -5323,7 +5327,8 @@ String GDScriptParser::DataType::to_string() const {
|
|||
if (!gds_class.empty()) {
|
||||
return gds_class;
|
||||
}
|
||||
} // fallthrough
|
||||
FALLTHROUGH;
|
||||
}
|
||||
case SCRIPT: {
|
||||
if (is_meta_type) {
|
||||
return script_type->get_class_name().operator String();
|
||||
|
@ -8079,7 +8084,8 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
|
|||
if (cn->value.get_type() == Variant::STRING) {
|
||||
break;
|
||||
}
|
||||
} // falthrough
|
||||
FALLTHROUGH;
|
||||
}
|
||||
default: {
|
||||
_mark_line_as_safe(statement->line);
|
||||
_reduce_node_type(statement); // Test for safety anyway
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue