summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-01-10 10:47:38 +0100
committerGitHub <noreply@github.com>2020-01-10 10:47:38 +0100
commitff173ff770c4498f4527676838ef8097917d0dda (patch)
treeac002de3dc89a14c08a2c6961cbf6aae3702682b
parent59a2fed1e62c6cee6433054956a15a2506552829 (diff)
parent1e154e0947e46fb700dc56d00e5d6ef4e5241021 (diff)
Merge pull request #34983 from Chaosus/fix_shader_switch
Fix nested break/return in shader switch statement
-rw-r--r--servers/visual/shader_language.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp
index 9505c0af39..225b382524 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/visual/shader_language.cpp
@@ -4542,8 +4542,13 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
}
p_block->statements.push_back(flow);
- if (p_block->block_type == BlockNode::BLOCK_TYPE_CASE || p_block->block_type == BlockNode::BLOCK_TYPE_DEFAULT) {
- return OK;
+
+ BlockNode *block = p_block;
+ while (block) {
+ if (block->block_type == BlockNode::BLOCK_TYPE_CASE || block->block_type == BlockNode::BLOCK_TYPE_DEFAULT) {
+ return OK;
+ }
+ block = block->parent_block;
}
} else if (tk.type == TK_CF_DISCARD) {
@@ -4591,8 +4596,13 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
}
p_block->statements.push_back(flow);
- if (p_block->block_type == BlockNode::BLOCK_TYPE_CASE || p_block->block_type == BlockNode::BLOCK_TYPE_DEFAULT) {
- return OK;
+
+ BlockNode *block = p_block;
+ while (block) {
+ if (block->block_type == BlockNode::BLOCK_TYPE_CASE || block->block_type == BlockNode::BLOCK_TYPE_DEFAULT) {
+ return OK;
+ }
+ block = block->parent_block;
}
} else if (tk.type == TK_CF_CONTINUE) {