mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Forbid returning void expressions from void functions.
This commit is contained in:
parent
b29d3489de
commit
9cc7aaf5a1
Notes:
Alexandre Julliard
2023-01-13 22:23:38 +01:00
Approved-by: Francisco Casas (@fcasas) Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/47
@ -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()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user