aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel De Graaf <danieldegraaf@gmail.com>2009-10-27 23:02:30 +0000
committerChristopher <sparse@chrisli.org>2010-03-28 17:51:36 -0700
commitc93fb998917a3ebce5ec39213a279743f8b2d747 (patch)
tree12ddceaa9a1130a6cf0ffe2b295b70014dd36eae
parentMakefile: fix permissions mixup on install (diff)
downloadsparse-c93fb998917a3ebce5ec39213a279743f8b2d747.tar.gz
sparse-c93fb998917a3ebce5ec39213a279743f8b2d747.tar.bz2
sparse-c93fb998917a3ebce5ec39213a279743f8b2d747.zip
Fix incorrect linearization of "x && y && z"
This fixes an incorrect assumption that results in && using shortcut logic on the true branch instead of the false branch. Signed-off-by: Daniel De Graaf <danieldegraaf@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
-rw-r--r--linearize.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/linearize.c b/linearize.c
index 238ee5d..f2034ce 100644
--- a/linearize.c
+++ b/linearize.c
@@ -1389,7 +1389,9 @@ static pseudo_t linearize_logical(struct entrypoint *ep, struct expression *expr
shortcut = alloc_const_expression(expr->pos, expr->op == SPECIAL_LOGICAL_OR);
shortcut->ctype = expr->ctype;
- return linearize_conditional(ep, expr, expr->left, shortcut, expr->right);
+ if (expr->op == SPECIAL_LOGICAL_OR)
+ return linearize_conditional(ep, expr, expr->left, shortcut, expr->right);
+ return linearize_conditional(ep, expr, expr->left, expr->right, shortcut);
}
static pseudo_t linearize_compare(struct entrypoint *ep, struct expression *expr)