aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linearize.c
diff options
authorXi Wang <xi.wang@gmail.com>2013-05-24 09:30:35 -0400
committerPekka Enberg <penberg@kernel.org>2013-05-27 14:15:24 +0300
commit99bdda1a38a6e3622cb72f422b2fb05045c29df7 (patch)
tree681909c499341fc77af7ed3d11c7dabfdb57a171 /linearize.c
parent469e5d6ea3353fb3039747f52fb506c9ba983d8b (diff)
downloadsparse-dev-99bdda1a38a6e3622cb72f422b2fb05045c29df7.tar.gz
Fix result type of relational and logical operators
The result type of relational operators (e.g., x < y) and logical operators (e.g., x && y) in C should be int, rather than bool. For example, sparse incorrectly evaluates sizeof(x < y) to 1 (i.e., sizeof(int)), which should have been sizeof(int). This patch fixes the result type of these operators in evaluation, linearization, and the LLVM backend. Acked-by: Christopher Li <sparse@chrisli.org> Signed-off-by: Xi Wang <xi.wang@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'linearize.c')
-rw-r--r--linearize.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/linearize.c b/linearize.c
index 1d15cfde..c6ada1e8 100644
--- a/linearize.c
+++ b/linearize.c
@@ -1064,7 +1064,7 @@ static pseudo_t linearize_regular_preop(struct entrypoint *ep, struct expression
return pre;
case '!': {
pseudo_t zero = value_pseudo(0);
- return add_binary_op(ep, expr->unop->ctype, OP_SET_EQ, pre, zero);
+ return add_binary_op(ep, expr->ctype, OP_SET_EQ, pre, zero);
}
case '~':
return add_uniop(ep, expr, OP_NOT, pre);
@@ -1418,7 +1418,7 @@ static pseudo_t linearize_compare(struct entrypoint *ep, struct expression *expr
pseudo_t src1 = linearize_expression(ep, expr->left);
pseudo_t src2 = linearize_expression(ep, expr->right);
- pseudo_t dst = add_binary_op(ep, expr->left->ctype, cmpop[expr->op], src1, src2);
+ pseudo_t dst = add_binary_op(ep, expr->ctype, cmpop[expr->op], src1, src2);
return dst;
}