Replace FALLTHROUGH macro by C++17 [[fallthrough]]

This attribute is now part of the standard we target so we no longer
need compiler-specific hacks.

Also enables -Wimplicit-fallthrough for Clang now that we can properly
support it. It's already on by default for GCC's -Wextra.

Fixes new warnings raised by Clang's -Wimplicit-fallthrough.
This commit is contained in:
Rémi Verschelde 2020-02-22 20:47:50 +01:00
parent a7891b9d12
commit 2cf6ac6c50
25 changed files with 75 additions and 88 deletions

View file

@ -2565,7 +2565,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path
} break;
case GDScriptParser::COMPLETION_FUNCTION: {
is_function = true;
FALLTHROUGH;
[[fallthrough]];
}
case GDScriptParser::COMPLETION_IDENTIFIER: {
_find_identifiers(context, is_function, options);
@ -2608,7 +2608,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path
} break;
case GDScriptParser::COMPLETION_METHOD: {
is_function = true;
FALLTHROUGH;
[[fallthrough]];
}
case GDScriptParser::COMPLETION_INDEX: {
const GDScriptParser::Node *node = parser.get_completion_node();
@ -3330,7 +3330,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
case GDScriptParser::COMPLETION_PARENT_FUNCTION:
case GDScriptParser::COMPLETION_FUNCTION: {
is_function = true;
FALLTHROUGH;
[[fallthrough]];
}
case GDScriptParser::COMPLETION_IDENTIFIER: {
@ -3462,7 +3462,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
} break;
case GDScriptParser::COMPLETION_METHOD: {
is_function = true;
FALLTHROUGH;
[[fallthrough]];
}
case GDScriptParser::COMPLETION_INDEX: {
const GDScriptParser::Node *node = parser.get_completion_node();

View file

@ -793,7 +793,7 @@ 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;
@ -2766,13 +2766,12 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
}
#endif // DEBUG_ENABLED
switch (token) {
case GDScriptTokenizer::TK_EOF:
case GDScriptTokenizer::TK_EOF: {
p_block->end_line = tokenizer->get_token_line();
return; // End of file!
} break;
case GDScriptTokenizer::TK_ERROR: {
return; //go back
//end of file!
return;
} break;
case GDScriptTokenizer::TK_NEWLINE: {
@ -3525,11 +3524,12 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
case GDScriptTokenizer::TK_CURSOR: {
tokenizer->advance();
} break;
case GDScriptTokenizer::TK_EOF:
case GDScriptTokenizer::TK_EOF: {
p_class->end_line = tokenizer->get_token_line();
return; // End of file!
} break;
case GDScriptTokenizer::TK_ERROR: {
return; //go back
//end of file!
return; // Go back.
} break;
case GDScriptTokenizer::TK_NEWLINE: {
if (!_parse_newline()) {
@ -3719,7 +3719,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
return;
}
FALLTHROUGH;
[[fallthrough]];
}
case GDScriptTokenizer::TK_PR_FUNCTION: {
@ -4220,7 +4220,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
break;
}
FALLTHROUGH;
[[fallthrough]];
}
case Variant::REAL: {
@ -5489,7 +5489,7 @@ String GDScriptParser::DataType::to_string() const {
if (!gds_class.empty()) {
return gds_class;
}
FALLTHROUGH;
[[fallthrough]];
}
case SCRIPT: {
if (is_meta_type) {
@ -8345,7 +8345,7 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
if (cn->value.get_type() == Variant::STRING) {
break;
}
FALLTHROUGH;
[[fallthrough]];
}
default: {
_mark_line_as_safe(statement->line);

View file

@ -340,7 +340,7 @@ StringName GDScriptTokenizer::get_token_literal(int p_offset) const {
default: {
}
}
}
} break;
case TK_OP_AND:
case TK_OP_OR:
break; // Don't get into default, since they can be non-literal
@ -536,7 +536,7 @@ void GDScriptTokenizerText::_advance() {
ignore_warnings = true;
}
#endif // DEBUG_ENABLED
FALLTHROUGH;
[[fallthrough]];
}
case '\n': {
line++;
@ -753,7 +753,7 @@ void GDScriptTokenizerText::_advance() {
}
INCPOS(1);
is_string_name = true;
FALLTHROUGH;
[[fallthrough]];
case '\'':
case '"': {

View file

@ -3906,7 +3906,7 @@ void VisualScriptEditor::_notification(int p_what) {
case NOTIFICATION_READY: {
variable_editor->connect_compat("changed", this, "_update_members");
signal_editor->connect_compat("changed", this, "_update_members");
FALLTHROUGH;
[[fallthrough]];
}
case NOTIFICATION_THEME_CHANGED: {
if (p_what != NOTIFICATION_READY && !is_visible_in_tree()) {