Skip to content

Commit

Permalink
Merge pull request #34983 from Chaosus/fix_shader_switch
Browse files Browse the repository at this point in the history
Fix nested break/return in shader switch statement
  • Loading branch information
akien-mga authored Jan 10, 2020
2 parents 59a2fed + 1e154e0 commit ff173ff
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions servers/visual/shader_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit ff173ff

Please sign in to comment.