Merge pull request #39869 from Chaosus/shader_fix_return

Prevents usage of return in main shader functions
This commit is contained in:
Rémi Verschelde 2020-06-27 17:03:42 +02:00 committed by GitHub
commit ff0583770a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -5585,6 +5585,12 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
} else if (tk.type == TK_CF_RETURN) {
//check return type
BlockNode *b = p_block;
if (b && b->parent_function && (b->parent_function->name == "vertex" || b->parent_function->name == "fragment" || b->parent_function->name == "light")) {
_set_error(vformat("Using 'return' in '%s' processor function results in undefined behavior!", b->parent_function->name));
return ERR_PARSE_ERROR;
}
while (b && !b->parent_function) {
b = b->parent_block;
}