summaryrefslogtreecommitdiff
path: root/modules/gdscript
diff options
context:
space:
mode:
authormarxin <mliska@suse.cz>2019-02-12 21:10:08 +0100
committerRĂ©mi Verschelde <rverschelde@gmail.com>2019-02-20 19:44:12 +0100
commit8d51618949d5ea8a94e0f504401e8f852a393968 (patch)
tree6c0ab829b02aba47ff3dc27b9a14d3c3a0658a3b /modules/gdscript
parent132e2f458df7a3551a251d68afeccd0362ca6be2 (diff)
Add -Wshadow=local to warnings and fix reported issues.
Fixes #25316.
Diffstat (limited to 'modules/gdscript')
-rw-r--r--modules/gdscript/gdscript.cpp8
-rw-r--r--modules/gdscript/gdscript_compiler.cpp54
-rw-r--r--modules/gdscript/gdscript_editor.cpp28
-rw-r--r--modules/gdscript/gdscript_parser.cpp64
-rw-r--r--modules/gdscript/gdscript_tokenizer.cpp6
5 files changed, 80 insertions, 80 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index f29432666e..dd9b36fd8c 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -1108,12 +1108,12 @@ void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const
//instance a fake script for editing the values
Vector<_GDScriptMemberSort> msort;
- for (Map<StringName, PropertyInfo>::Element *E = sptr->member_info.front(); E; E = E->next()) {
+ for (Map<StringName, PropertyInfo>::Element *F = sptr->member_info.front(); F; F = F->next()) {
_GDScriptMemberSort ms;
- ERR_CONTINUE(!sptr->member_indices.has(E->key()));
- ms.index = sptr->member_indices[E->key()].index;
- ms.name = E->key();
+ ERR_CONTINUE(!sptr->member_indices.has(F->key()));
+ ms.index = sptr->member_indices[F->key()].index;
+ ms.name = F->key();
msort.push_back(ms);
}
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index d256918b22..b2b7b1c260 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -1360,15 +1360,15 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
// jump unconditionally
// continue address
// compile the condition
- int ret = _parse_expression(codegen, branch.compiled_pattern, p_stack_level);
- if (ret < 0) {
+ int ret2 = _parse_expression(codegen, branch.compiled_pattern, p_stack_level);
+ if (ret2 < 0) {
memdelete(id);
memdelete(op);
return ERR_PARSE_ERROR;
}
codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF);
- codegen.opcodes.push_back(ret);
+ codegen.opcodes.push_back(ret2);
codegen.opcodes.push_back(codegen.opcodes.size() + 3);
int continue_addr = codegen.opcodes.size();
codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
@@ -1401,12 +1401,12 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
codegen.opcodes.push_back(cf->line);
codegen.current_line = cf->line;
#endif
- int ret = _parse_expression(codegen, cf->arguments[0], p_stack_level, false);
- if (ret < 0)
+ int ret2 = _parse_expression(codegen, cf->arguments[0], p_stack_level, false);
+ if (ret2 < 0)
return ERR_PARSE_ERROR;
codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF_NOT);
- codegen.opcodes.push_back(ret);
+ codegen.opcodes.push_back(ret2);
int else_addr = codegen.opcodes.size();
codegen.opcodes.push_back(0); //temporary
@@ -1421,9 +1421,9 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
codegen.opcodes.push_back(0);
codegen.opcodes.write[else_addr] = codegen.opcodes.size();
- Error err = _parse_block(codegen, cf->body_else, p_stack_level, p_break_addr, p_continue_addr);
- if (err)
- return err;
+ Error err2 = _parse_block(codegen, cf->body_else, p_stack_level, p_break_addr, p_continue_addr);
+ if (err2)
+ return err2;
codegen.opcodes.write[end_addr] = codegen.opcodes.size();
} else {
@@ -1444,14 +1444,14 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
codegen.push_stack_identifiers();
codegen.add_stack_identifier(static_cast<const GDScriptParser::IdentifierNode *>(cf->arguments[0])->name, iter_stack_pos);
- int ret = _parse_expression(codegen, cf->arguments[1], slevel, false);
- if (ret < 0)
+ int ret2 = _parse_expression(codegen, cf->arguments[1], slevel, false);
+ if (ret2 < 0)
return ERR_COMPILATION_FAILED;
//assign container
codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN);
codegen.opcodes.push_back(container_pos);
- codegen.opcodes.push_back(ret);
+ codegen.opcodes.push_back(ret2);
//begin loop
codegen.opcodes.push_back(GDScriptFunction::OPCODE_ITERATE_BEGIN);
@@ -1493,11 +1493,11 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
codegen.opcodes.push_back(0);
int continue_addr = codegen.opcodes.size();
- int ret = _parse_expression(codegen, cf->arguments[0], p_stack_level, false);
- if (ret < 0)
+ int ret2 = _parse_expression(codegen, cf->arguments[0], p_stack_level, false);
+ if (ret2 < 0)
return ERR_PARSE_ERROR;
codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF_NOT);
- codegen.opcodes.push_back(ret);
+ codegen.opcodes.push_back(ret2);
codegen.opcodes.push_back(break_addr);
Error err = _parse_block(codegen, cf->body, p_stack_level, break_addr, continue_addr);
if (err)
@@ -1533,21 +1533,21 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
} break;
case GDScriptParser::ControlFlowNode::CF_RETURN: {
- int ret;
+ int ret2;
if (cf->arguments.size()) {
- ret = _parse_expression(codegen, cf->arguments[0], p_stack_level, false);
- if (ret < 0)
+ ret2 = _parse_expression(codegen, cf->arguments[0], p_stack_level, false);
+ if (ret2 < 0)
return ERR_PARSE_ERROR;
} else {
- ret = GDScriptFunction::ADDR_TYPE_NIL << GDScriptFunction::ADDR_BITS;
+ ret2 = GDScriptFunction::ADDR_TYPE_NIL << GDScriptFunction::ADDR_BITS;
}
codegen.opcodes.push_back(GDScriptFunction::OPCODE_RETURN);
- codegen.opcodes.push_back(ret);
+ codegen.opcodes.push_back(ret2);
} break;
}
@@ -1558,12 +1558,12 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
const GDScriptParser::AssertNode *as = static_cast<const GDScriptParser::AssertNode *>(s);
- int ret = _parse_expression(codegen, as->condition, p_stack_level, false);
- if (ret < 0)
+ int ret2 = _parse_expression(codegen, as->condition, p_stack_level, false);
+ if (ret2 < 0)
return ERR_PARSE_ERROR;
codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSERT);
- codegen.opcodes.push_back(ret);
+ codegen.opcodes.push_back(ret2);
#endif
} break;
case GDScriptParser::Node::TYPE_BREAKPOINT: {
@@ -1590,8 +1590,8 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
} break;
default: {
//expression
- int ret = _parse_expression(codegen, s, p_stack_level, true);
- if (ret < 0)
+ int ret2 = _parse_expression(codegen, s, p_stack_level, true);
+ if (ret2 < 0)
return ERR_PARSE_ERROR;
} break;
}
@@ -2116,8 +2116,8 @@ Error GDScriptCompiler::_parse_class_blocks(GDScript *p_script, const GDScriptPa
instance->owner = E->get();
//needed for hot reloading
- for (Map<StringName, GDScript::MemberInfo>::Element *E = p_script->member_indices.front(); E; E = E->next()) {
- instance->member_indices_cache[E->key()] = E->get().index;
+ for (Map<StringName, GDScript::MemberInfo>::Element *F = p_script->member_indices.front(); F; F = F->next()) {
+ instance->member_indices_cache[F->key()] = F->get().index;
}
instance->owner->set_script_instance(instance);
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index af770ac533..fafc73b7e6 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -785,12 +785,12 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G
if (mb && mb->is_const()) {
bool all_is_const = true;
Vector<Variant> args;
- GDScriptCompletionContext c = p_context;
- c.line = op->line;
+ GDScriptCompletionContext c2 = p_context;
+ c2.line = op->line;
for (int i = 2; all_is_const && i < op->arguments.size(); i++) {
GDScriptCompletionIdentifier arg;
- if (_guess_expression_type(c, op->arguments[i], arg)) {
+ if (_guess_expression_type(c2, op->arguments[i], arg)) {
if (arg.type.has_type && arg.type.is_constant && arg.value.get_type() != Variant::OBJECT) {
args.push_back(arg.value);
} else {
@@ -1282,9 +1282,9 @@ static bool _guess_identifier_type(GDScriptCompletionContext &p_context, const S
for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) {
if (E->get().name == p_context.function->name) {
MethodInfo &mi = E->get();
- for (List<PropertyInfo>::Element *E = mi.arguments.front(); E; E = E->next()) {
- if (E->get().name == p_identifier) {
- r_type = _type_from_property(E->get());
+ for (List<PropertyInfo>::Element *F = mi.arguments.front(); F; F = F->next()) {
+ if (F->get().name == p_identifier) {
+ r_type = _type_from_property(F->get());
return true;
}
}
@@ -2237,8 +2237,8 @@ static void _find_call_arguments(const GDScriptCompletionContext &p_context, con
if (obj) {
List<String> options;
obj->get_argument_options(p_method, p_argidx, &options);
- for (List<String>::Element *E = options.front(); E; E = E->next()) {
- r_result.insert(E->get());
+ for (List<String>::Element *F = options.front(); F; F = F->next()) {
+ r_result.insert(F->get());
}
}
}
@@ -2806,12 +2806,12 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
if (base_type.class_type) {
for (Map<StringName, GDScriptParser::ClassNode::Constant>::Element *E = base_type.class_type->constant_expressions.front(); E; E = E->next()) {
GDScriptCompletionIdentifier constant;
- GDScriptCompletionContext c = context;
- c._class = base_type.class_type;
- c.function = NULL;
- c.block = NULL;
- c.line = E->value().expression->line;
- if (_guess_expression_type(c, E->value().expression, constant)) {
+ GDScriptCompletionContext c2 = context;
+ c2._class = base_type.class_type;
+ c2.function = NULL;
+ c2.block = NULL;
+ c2.line = E->value().expression->line;
+ if (_guess_expression_type(c2, E->value().expression, constant)) {
if (constant.type.has_type && constant.type.is_meta_type) {
options.insert(E->key().operator String());
}
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index b53d37226c..a642abeb0a 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -2640,14 +2640,14 @@ void GDScriptParser::_transform_match_statment(MatchNode *p_match_statement) {
local_var->assign = e->value();
local_var->set_datatype(local_var->assign->get_datatype());
- IdentifierNode *id = alloc_node<IdentifierNode>();
- id->name = local_var->name;
- id->declared_block = branch->body;
- id->set_datatype(local_var->assign->get_datatype());
+ IdentifierNode *id2 = alloc_node<IdentifierNode>();
+ id2->name = local_var->name;
+ id2->declared_block = branch->body;
+ id2->set_datatype(local_var->assign->get_datatype());
OperatorNode *op = alloc_node<OperatorNode>();
op->op = OperatorNode::OP_ASSIGN;
- op->arguments.push_back(id);
+ op->arguments.push_back(id2);
op->arguments.push_back(local_var->assign);
branch->body->statements.push_front(op);
@@ -2694,9 +2694,9 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
if (pending_newline != -1) {
- NewLineNode *nl = alloc_node<NewLineNode>();
- nl->line = pending_newline;
- p_block->statements.push_back(nl);
+ NewLineNode *nl2 = alloc_node<NewLineNode>();
+ nl2->line = pending_newline;
+ p_block->statements.push_back(nl2);
pending_newline = -1;
}
@@ -2735,9 +2735,9 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
return;
}
- NewLineNode *nl = alloc_node<NewLineNode>();
- nl->line = tokenizer->get_token_line();
- p_block->statements.push_back(nl);
+ NewLineNode *nl2 = alloc_node<NewLineNode>();
+ nl2->line = tokenizer->get_token_line();
+ p_block->statements.push_back(nl2);
} break;
case GDScriptTokenizer::TK_CF_PASS: {
@@ -2922,14 +2922,14 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
cf_else->cf_type = ControlFlowNode::CF_IF;
//condition
- Node *condition = _parse_and_reduce_expression(p_block, p_static);
- if (!condition) {
+ Node *condition2 = _parse_and_reduce_expression(p_block, p_static);
+ if (!condition2) {
if (_recover_from_completion()) {
break;
}
return;
}
- cf_else->arguments.push_back(condition);
+ cf_else->arguments.push_back(condition2);
cf_else->cf_type = ControlFlowNode::CF_IF;
cf_if->body_else->statements.push_back(cf_else);
@@ -2992,8 +2992,8 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
case GDScriptTokenizer::TK_CF_WHILE: {
tokenizer->advance();
- Node *condition = _parse_and_reduce_expression(p_block, p_static);
- if (!condition) {
+ Node *condition2 = _parse_and_reduce_expression(p_block, p_static);
+ if (!condition2) {
if (_recover_from_completion()) {
break;
}
@@ -3003,7 +3003,7 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
ControlFlowNode *cf_while = alloc_node<ControlFlowNode>();
cf_while->cf_type = ControlFlowNode::CF_WHILE;
- cf_while->arguments.push_back(condition);
+ cf_while->arguments.push_back(condition2);
cf_while->body = alloc_node<BlockNode>();
cf_while->body->parent_block = p_block;
@@ -4705,12 +4705,12 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
op->arguments.push_back(subexpr);
#ifdef DEBUG_ENABLED
- NewLineNode *nl = alloc_node<NewLineNode>();
- nl->line = line;
+ NewLineNode *nl2 = alloc_node<NewLineNode>();
+ nl2->line = line;
if (onready)
- p_class->ready->statements.push_back(nl);
+ p_class->ready->statements.push_back(nl2);
else
- p_class->initializer->statements.push_back(nl);
+ p_class->initializer->statements.push_back(nl2);
#endif
if (onready)
p_class->ready->statements.push_back(op);
@@ -4732,8 +4732,8 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
ConstantNode *cn = alloc_node<ConstantNode>();
- Variant::CallError ce;
- cn->value = Variant::construct(member._export.type, NULL, 0, ce);
+ Variant::CallError ce2;
+ cn->value = Variant::construct(member._export.type, NULL, 0, ce2);
OperatorNode *op = alloc_node<OperatorNode>();
op->op = OperatorNode::OP_INIT_ASSIGN;
@@ -5523,10 +5523,10 @@ GDScriptParser::DataType GDScriptParser::_resolve_type(const DataType &p_source,
result.script_type = gds;
found = true;
} else {
- Ref<Script> scr = constants[id];
- if (scr.is_valid()) {
+ Ref<Script> scr2 = constants[id];
+ if (scr2.is_valid()) {
result.kind = DataType::SCRIPT;
- result.script_type = scr;
+ result.script_type = scr2;
found = true;
}
}
@@ -6646,7 +6646,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
bool match = false;
List<MethodInfo> constructors;
Variant::get_constructor_list(tn->vtype, &constructors);
- PropertyInfo return_type;
+ PropertyInfo return_type2;
for (List<MethodInfo>::Element *E = constructors.front(); E; E = E->next()) {
MethodInfo &mi = E->get();
@@ -6685,13 +6685,13 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
if (types_match) {
match = true;
- return_type = mi.return_val;
+ return_type2 = mi.return_val;
break;
}
}
if (match) {
- return _type_from_property(return_type, false);
+ return _type_from_property(return_type2, false);
} else if (check_types) {
String err = "No constructor of '";
err += Variant::get_type_name(tn->vtype);
@@ -7603,7 +7603,7 @@ void GDScriptParser::_check_function_types(FunctionNode *p_function) {
}
parent_signature += " " + p_function->name + "(";
if (arg_types.size()) {
- int i = 0;
+ int j = 0;
for (List<DataType>::Element *E = arg_types.front(); E; E = E->next()) {
if (E != arg_types.front()) {
parent_signature += ", ";
@@ -7613,11 +7613,11 @@ void GDScriptParser::_check_function_types(FunctionNode *p_function) {
arg = "Variant";
}
parent_signature += arg;
- if (i == arg_types.size() - default_arg_count) {
+ if (j == arg_types.size() - default_arg_count) {
parent_signature += "=default";
}
- i++;
+ j++;
}
}
parent_signature += ")";
diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp
index 0f2f0bbb26..dc9f2db331 100644
--- a/modules/gdscript/gdscript_tokenizer.cpp
+++ b/modules/gdscript/gdscript_tokenizer.cpp
@@ -989,11 +989,11 @@ void GDScriptTokenizerText::_advance() {
//built in func?
- for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) {
+ for (int j = 0; j < GDScriptFunctions::FUNC_MAX; j++) {
- if (str == GDScriptFunctions::get_func_name(GDScriptFunctions::Function(i))) {
+ if (str == GDScriptFunctions::get_func_name(GDScriptFunctions::Function(j))) {
- _make_built_in_func(GDScriptFunctions::Function(i));
+ _make_built_in_func(GDScriptFunctions::Function(j));
found = true;
break;
}