Skip to contentSkip to conversation

fix logical operand type

PATCH New Xi Wang 1 participant 1 message May 16, 2013 Sparse checker

lore
Share & tools
lore

Xi Wang

author
#0 lore raw

PATCH 1/1 fix logical operand type

The type of logical operands should be bool.

---
simplify.c seems to assume so.

	case OP_AND_BOOL:
		if (value == 1)
			return replace_with_pseudo(insn, insn->src1);
---
 evaluate.c | 2 ++
 1 file changed, 2 insertions(+)
evaluate.c +2 -0
index c345a50..8954ff2 100644
@@ -873,6 +873,8 @@ static struct symbol *evaluate_logical(struct expression *expr)
 		return NULL;
 
 	expr->ctype = &bool_ctype;
+	expr->left = cast_to(expr->left, &bool_ctype);
+	expr->right = cast_to(expr->right, &bool_ctype);
 	if (expr->flags) {
 		if (!(expr->left->flags & expr->right->flags & Int_const_expr))
 			expr->flags = 0;
Signature · 1 line
1.8.1.2