From 3ca57e5157e0ae610ba3d464c5732f6232bd6f55 Mon Sep 17 00:00:00 2001 From: Yuri Roubinsky Date: Sun, 23 Jan 2022 20:22:31 +0300 Subject: [PATCH] Fix incorrect unused local var warning in shader blocks --- servers/rendering/shader_language.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 4e07582187a..cb1329d33c2 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -5208,9 +5208,15 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons #ifdef DEBUG_ENABLED if (check_warnings) { StringName func_name; + BlockNode *b = p_block; - if (p_block && p_block->parent_function) { - func_name = p_block->parent_function->name; + while (b) { + if (b->parent_function) { + func_name = b->parent_function->name; + break; + } else { + b = b->parent_block; + } } _parse_used_identifier(identifier, ident_type, func_name);