py/emitnative: Explicitly compare comparison ops in binary_op emitter.
Without this it's possible to get a compiler error about the comparison always being true, because MP_BINARY_OP_LESS is 0. And it seems that gcc optimises these 6 equality comparisons into the same size machine code as before.
This commit is contained in:
committed by
Damien George
parent
2e4dda3c20
commit
72e9318325
@@ -2365,14 +2365,13 @@ STATIC void emit_native_binary_op(emit_t *emit, mp_binary_op_t op) {
|
|||||||
} else if (op == MP_BINARY_OP_MULTIPLY) {
|
} else if (op == MP_BINARY_OP_MULTIPLY) {
|
||||||
ASM_MUL_REG_REG(emit->as, REG_ARG_2, reg_rhs);
|
ASM_MUL_REG_REG(emit->as, REG_ARG_2, reg_rhs);
|
||||||
emit_post_push_reg(emit, vtype_lhs, REG_ARG_2);
|
emit_post_push_reg(emit, vtype_lhs, REG_ARG_2);
|
||||||
} else if (MP_BINARY_OP_LESS <= op && op <= MP_BINARY_OP_NOT_EQUAL) {
|
} else if (op == MP_BINARY_OP_LESS
|
||||||
// comparison ops are (in enum order):
|
|| op == MP_BINARY_OP_MORE
|
||||||
// MP_BINARY_OP_LESS
|
|| op == MP_BINARY_OP_EQUAL
|
||||||
// MP_BINARY_OP_MORE
|
|| op == MP_BINARY_OP_LESS_EQUAL
|
||||||
// MP_BINARY_OP_EQUAL
|
|| op == MP_BINARY_OP_MORE_EQUAL
|
||||||
// MP_BINARY_OP_LESS_EQUAL
|
|| op == MP_BINARY_OP_NOT_EQUAL) {
|
||||||
// MP_BINARY_OP_MORE_EQUAL
|
// comparison ops
|
||||||
// MP_BINARY_OP_NOT_EQUAL
|
|
||||||
|
|
||||||
if (vtype_lhs != vtype_rhs) {
|
if (vtype_lhs != vtype_rhs) {
|
||||||
EMIT_NATIVE_VIPER_TYPE_ERROR(emit, MP_ERROR_TEXT("comparison of int and uint"));
|
EMIT_NATIVE_VIPER_TYPE_ERROR(emit, MP_ERROR_TEXT("comparison of int and uint"));
|
||||||
|
|||||||
Reference in New Issue
Block a user