diff options
author | Yuri Roubinsky <chaosus89@gmail.com> | 2022-02-06 08:17:25 +0300 |
---|---|---|
committer | Yuri Roubinsky <chaosus89@gmail.com> | 2022-02-06 08:38:33 +0300 |
commit | a2484c329313d7b1ade0cb8f84c7dc4c57e37a4d (patch) | |
tree | 2ea9283f43f00db9b44a4acc4cfdb449a569882f | |
parent | 9d1626b4d7a867b4778845dd12519c603f0cf88f (diff) |
Fix unknown identifier error in for loop
-rw-r--r-- | servers/rendering/shader_language.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index b10022545c..ead196b7dd 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -6495,9 +6495,17 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun decl.name = name; #ifdef DEBUG_ENABLED - if (check_warnings && HAS_WARNING(ShaderWarning::UNUSED_LOCAL_VARIABLE_FLAG)) { - if (p_block && p_block->parent_function) { - StringName func_name = p_block->parent_function->name; + if (check_warnings && HAS_WARNING(ShaderWarning::UNUSED_LOCAL_VARIABLE_FLAG) && p_block) { + FunctionNode *parent_function = nullptr; + { + BlockNode *block = p_block; + while (block && !block->parent_function) { + block = block->parent_block; + } + parent_function = block->parent_function; + } + if (parent_function) { + StringName func_name = parent_function->name; if (!used_local_vars.has(func_name)) { used_local_vars.insert(func_name, Map<StringName, Usage>()); @@ -7141,14 +7149,6 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun init_block->block_type = BlockNode::BLOCK_TYPE_FOR_INIT; init_block->parent_block = p_block; init_block->single_statement = true; - // Need to find a parent function to correctly proceed unused variable warnings. - { - BlockNode *block = p_block; - while (block && !block->parent_function) { - block = block->parent_block; - } - init_block->parent_function = block->parent_function; - } cf->blocks.push_back(init_block); Error err = _parse_block(init_block, p_function_info, true, false, false); if (err != OK) { |