Merge pull request #37313 from Chaosus/shader_fix_for
Prevent shader crash if multiple variables has been declared in 'for'
This commit is contained in:
commit
fafb0ba06d
2 changed files with 6 additions and 0 deletions
|
@ -5070,6 +5070,10 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
|
||||||
p_block->variables[name] = var;
|
p_block->variables[name] = var;
|
||||||
|
|
||||||
if (tk.type == TK_COMMA) {
|
if (tk.type == TK_COMMA) {
|
||||||
|
if (p_block->block_type == BlockNode::BLOCK_TYPE_FOR) {
|
||||||
|
_set_error("Multiple declarations in 'for' loop are not implemented yet.");
|
||||||
|
return ERR_PARSE_ERROR;
|
||||||
|
}
|
||||||
tk = _get_token();
|
tk = _get_token();
|
||||||
//another variable
|
//another variable
|
||||||
} else if (tk.type == TK_SEMICOLON) {
|
} else if (tk.type == TK_SEMICOLON) {
|
||||||
|
@ -5394,6 +5398,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
|
||||||
cf->flow_op = FLOW_OP_FOR;
|
cf->flow_op = FLOW_OP_FOR;
|
||||||
|
|
||||||
BlockNode *init_block = alloc_node<BlockNode>();
|
BlockNode *init_block = alloc_node<BlockNode>();
|
||||||
|
init_block->block_type = BlockNode::BLOCK_TYPE_FOR;
|
||||||
init_block->parent_block = p_block;
|
init_block->parent_block = p_block;
|
||||||
init_block->single_statement = true;
|
init_block->single_statement = true;
|
||||||
cf->blocks.push_back(init_block);
|
cf->blocks.push_back(init_block);
|
||||||
|
|
|
@ -487,6 +487,7 @@ public:
|
||||||
|
|
||||||
enum BlockType {
|
enum BlockType {
|
||||||
BLOCK_TYPE_STANDART,
|
BLOCK_TYPE_STANDART,
|
||||||
|
BLOCK_TYPE_FOR,
|
||||||
BLOCK_TYPE_SWITCH,
|
BLOCK_TYPE_SWITCH,
|
||||||
BLOCK_TYPE_CASE,
|
BLOCK_TYPE_CASE,
|
||||||
BLOCK_TYPE_DEFAULT,
|
BLOCK_TYPE_DEFAULT,
|
||||||
|
|
Loading…
Reference in a new issue