Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- libs/vkd3d-shader/hlsl.y | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 9b738312..f1c302be 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1022,6 +1022,24 @@ static struct hlsl_ir_expr *add_unary_arithmetic_expr(struct hlsl_ctx *ctx, stru return add_expr(ctx, instrs, op, args, arg->data_type, loc); }
+static struct hlsl_ir_expr *add_unary_bitwise_expr(struct hlsl_ctx *ctx, struct list *instrs, + enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, struct vkd3d_shader_location *loc) +{ + if (arg->data_type->base_type != HLSL_TYPE_INT && arg->data_type->base_type != HLSL_TYPE_UINT + && arg->data_type->base_type != HLSL_TYPE_BOOL) + { + struct vkd3d_string_buffer *type_str = hlsl_type_to_string(ctx, arg->data_type); + + if (type_str) + hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + "The argument has type '%s', which is not integer.", type_str->buffer); + hlsl_release_string_buffer(ctx, type_str); + return NULL; + } + + return add_unary_arithmetic_expr(ctx, instrs, op, arg, loc); +} + static struct hlsl_ir_expr *add_binary_arithmetic_expr(struct hlsl_ctx *ctx, struct list *instrs, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2, const struct vkd3d_shader_location *loc) @@ -3616,7 +3634,7 @@ unary_expr: } | '~' unary_expr { - add_unary_arithmetic_expr(ctx, $2, HLSL_OP1_BIT_NOT, node_from_list($2), &@1); + add_unary_bitwise_expr(ctx, $2, HLSL_OP1_BIT_NOT, node_from_list($2), &@1); $$ = $2; } | '!' unary_expr