mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/hlsl: Forbid returning void expressions from void functions.
This commit is contained in:
committed by
Alexandre Julliard
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,6 +599,8 @@ 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_type *return_type = ctx->cur_function->return_type;
|
||||||
struct hlsl_ir_jump *jump;
|
struct hlsl_ir_jump *jump;
|
||||||
|
|
||||||
|
if (ctx->cur_function->return_var)
|
||||||
|
{
|
||||||
if (return_value)
|
if (return_value)
|
||||||
{
|
{
|
||||||
struct hlsl_ir_store *store;
|
struct hlsl_ir_store *store;
|
||||||
@@ -610,11 +612,17 @@ static struct hlsl_ir_jump *add_return(struct hlsl_ctx *ctx, struct list *instrs
|
|||||||
return NULL;
|
return NULL;
|
||||||
list_add_after(&return_value->entry, &store->node.entry);
|
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.");
|
hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RETURN, "Non-void functions must return a value.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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)))
|
if (!(jump = hlsl_new_jump(ctx, HLSL_IR_JUMP_RETURN, loc)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ float4 main() : sv_target
|
|||||||
return func();
|
return func();
|
||||||
}
|
}
|
||||||
|
|
||||||
[pixel shader fail todo]
|
[pixel shader fail]
|
||||||
|
|
||||||
void foo()
|
void foo()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user