From 7029d821bed23e71eafd54d9894ec03f59b606bd Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 22 Feb 2024 13:03:16 +0100 Subject: [PATCH] configure: Build with -Wtype-limits. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libs/vkd3d-shader/tpf.c: In function ‘write_sm4_unary_op_with_two_destinations’: libs/vkd3d-shader/tpf.c:4489:24: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] assert(1 - dst_idx >= 0); ^~ libs/vkd3d-shader/tpf.c: In function ‘write_sm4_binary_op_with_two_destinations’: libs/vkd3d-shader/tpf.c:4549:24: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] assert(1 - dst_idx >= 0); ^~ --- configure.ac | 1 + libs/vkd3d-shader/tpf.c | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 6d352895..e2376b0d 100644 --- a/configure.ac +++ b/configure.ac @@ -67,6 +67,7 @@ AS_IF([test "x${GCC}" = "xyes"], VKD3D_CHECK_CFLAGS([-Wpointer-arith]) VKD3D_CHECK_CFLAGS([-Wshadow]) VKD3D_CHECK_CFLAGS([-Wshift-overflow=2]) + VKD3D_CHECK_CFLAGS([-Wtype-limits]) VKD3D_CHECK_CFLAGS([-Wunused-but-set-parameter]) VKD3D_CHECK_CFLAGS([-Wvla]) VKD3D_CHECK_CFLAGS([-Wl,--no-undefined])]) diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index 10dde985..c6cf1c95 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -4477,7 +4477,7 @@ static void write_sm4_unary_op(const struct tpf_writer *tpf, enum vkd3d_sm4_opco } static void write_sm4_unary_op_with_two_destinations(const struct tpf_writer *tpf, enum vkd3d_sm4_opcode opcode, - const struct hlsl_ir_node *dst, unsigned dst_idx, const struct hlsl_ir_node *src) + const struct hlsl_ir_node *dst, unsigned int dst_idx, const struct hlsl_ir_node *src) { struct sm4_instruction instr; @@ -4486,7 +4486,6 @@ static void write_sm4_unary_op_with_two_destinations(const struct tpf_writer *tp assert(dst_idx < ARRAY_SIZE(instr.dsts)); sm4_dst_from_node(&instr.dsts[dst_idx], dst); - assert(1 - dst_idx >= 0); instr.dsts[1 - dst_idx].reg.type = VKD3DSPR_NULL; instr.dsts[1 - dst_idx].reg.dimension = VSIR_DIMENSION_NONE; instr.dsts[1 - dst_idx].reg.idx_count = 0; @@ -4536,7 +4535,7 @@ static void write_sm4_binary_op_dot(const struct tpf_writer *tpf, enum vkd3d_sm4 } static void write_sm4_binary_op_with_two_destinations(const struct tpf_writer *tpf, - enum vkd3d_sm4_opcode opcode, const struct hlsl_ir_node *dst, unsigned dst_idx, + enum vkd3d_sm4_opcode opcode, const struct hlsl_ir_node *dst, unsigned int dst_idx, const struct hlsl_ir_node *src1, const struct hlsl_ir_node *src2) { struct sm4_instruction instr; @@ -4546,7 +4545,6 @@ static void write_sm4_binary_op_with_two_destinations(const struct tpf_writer *t assert(dst_idx < ARRAY_SIZE(instr.dsts)); sm4_dst_from_node(&instr.dsts[dst_idx], dst); - assert(1 - dst_idx >= 0); instr.dsts[1 - dst_idx].reg.type = VKD3DSPR_NULL; instr.dsts[1 - dst_idx].reg.dimension = VSIR_DIMENSION_NONE; instr.dsts[1 - dst_idx].reg.idx_count = 0;