Skip to content
Snippets Groups Projects
Commit 9cc7aaf5 authored by Elizabeth Figura's avatar Elizabeth Figura Committed by Alexandre Julliard
Browse files

vkd3d-shader/hlsl: Forbid returning void expressions from void functions.

parent b29d3489
No related branches found
No related tags found
1 merge request!47hlsl: Function calls.
......@@ -599,21 +599,29 @@ static struct hlsl_ir_jump *add_return(struct hlsl_ctx *ctx, struct list *instrs
struct hlsl_type *return_type = ctx->cur_function->return_type;
struct hlsl_ir_jump *jump;
if (return_value)
if (ctx->cur_function->return_var)
{
struct hlsl_ir_store *store;
if (return_value)
{
struct hlsl_ir_store *store;
if (!(return_value = add_implicit_conversion(ctx, instrs, return_value, return_type, &loc)))
return NULL;
if (!(return_value = add_implicit_conversion(ctx, instrs, return_value, return_type, &loc)))
return NULL;
if (!(store = hlsl_new_simple_store(ctx, ctx->cur_function->return_var, return_value)))
if (!(store = hlsl_new_simple_store(ctx, ctx->cur_function->return_var, return_value)))
return NULL;
list_add_after(&return_value->entry, &store->node.entry);
}
else
{
hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RETURN, "Non-void functions must return a value.");
return NULL;
list_add_after(&return_value->entry, &store->node.entry);
}
}
else if (ctx->cur_function->return_var)
else
{
hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RETURN, "Non-void function must return a value.");
return NULL;
if (return_value)
hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RETURN, "Void functions cannot return a value.");
}
if (!(jump = hlsl_new_jump(ctx, HLSL_IR_JUMP_RETURN, loc)))
......
......@@ -89,7 +89,7 @@ float4 main() : sv_target
return func();
}
[pixel shader fail todo]
[pixel shader fail]
void foo()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment