Browse Source

Merge pull request #46522 from Ev1lbl0w/bugfix-shader_noret

Added missing returns on error scenarios
Rémi Verschelde 4 years ago
parent
commit
e9cb64a8b5
1 changed files with 7 additions and 6 deletions
  1. 7 6
      servers/rendering/shader_language.cpp

+ 7 - 6
servers/rendering/shader_language.cpp

@@ -5926,15 +5926,15 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
 			pos = _get_tkpos();
 			pos = _get_tkpos();
 			tk = _get_token();
 			tk = _get_token();
 			if (tk.type != TK_SEMICOLON) {
 			if (tk.type != TK_SEMICOLON) {
-				//all is good
 				_set_error("Expected ';' after discard");
 				_set_error("Expected ';' after discard");
+				return ERR_PARSE_ERROR;
 			}
 			}
 
 
 			p_block->statements.push_back(flow);
 			p_block->statements.push_back(flow);
 		} else if (tk.type == TK_CF_BREAK) {
 		} else if (tk.type == TK_CF_BREAK) {
 			if (!p_can_break) {
 			if (!p_can_break) {
-				//all is good
-				_set_error("Breaking is not allowed here");
+				_set_error("'break' is not allowed outside of a loop or 'switch' statement");
+				return ERR_PARSE_ERROR;
 			}
 			}
 
 
 			ControlFlowNode *flow = alloc_node<ControlFlowNode>();
 			ControlFlowNode *flow = alloc_node<ControlFlowNode>();
@@ -5943,8 +5943,8 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
 			pos = _get_tkpos();
 			pos = _get_tkpos();
 			tk = _get_token();
 			tk = _get_token();
 			if (tk.type != TK_SEMICOLON) {
 			if (tk.type != TK_SEMICOLON) {
-				//all is good
 				_set_error("Expected ';' after break");
 				_set_error("Expected ';' after break");
+				return ERR_PARSE_ERROR;
 			}
 			}
 
 
 			p_block->statements.push_back(flow);
 			p_block->statements.push_back(flow);
@@ -5959,8 +5959,8 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
 
 
 		} else if (tk.type == TK_CF_CONTINUE) {
 		} else if (tk.type == TK_CF_CONTINUE) {
 			if (!p_can_continue) {
 			if (!p_can_continue) {
-				//all is good
-				_set_error("Continuing is not allowed here");
+				_set_error("'continue' is not allowed outside of a loop");
+				return ERR_PARSE_ERROR;
 			}
 			}
 
 
 			ControlFlowNode *flow = alloc_node<ControlFlowNode>();
 			ControlFlowNode *flow = alloc_node<ControlFlowNode>();
@@ -5971,6 +5971,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
 			if (tk.type != TK_SEMICOLON) {
 			if (tk.type != TK_SEMICOLON) {
 				//all is good
 				//all is good
 				_set_error("Expected ';' after continue");
 				_set_error("Expected ';' after continue");
+				return ERR_PARSE_ERROR;
 			}
 			}
 
 
 			p_block->statements.push_back(flow);
 			p_block->statements.push_back(flow);