aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLinus Torvalds <torvalds@ppc970.osdl.org>2004-09-17 09:50:39 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:03:13 -0700
commit384363a35e689af4948490f686634c5a79f453f8 (patch)
treed2b1e617992190626c01355dda39b06064b4cdb5
parent3894814ff6a2886c76d119216223e4193ecc4530 (diff)
downloadsparse-dev-384363a35e689af4948490f686634c5a79f453f8.tar.gz
Fix conditional expression evaluation buglets
- make sure we convert the true expression in the tree, not just in our local copy - fix restricted binop checks (too much cut-and-paste)
-rw-r--r--evaluate.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/evaluate.c b/evaluate.c
index 313e3c22..0b408373 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -858,7 +858,8 @@ static struct symbol *compatible_ptr_type(struct expression *left, struct expres
static struct symbol * evaluate_conditional_expression(struct expression *expr)
{
- struct expression *cond, *true, *false;
+ struct expression *cond, *false;
+ struct expression **true_p;
struct symbol *ctype, *ltype, *rtype;
const char * typediff;
@@ -866,10 +867,10 @@ static struct symbol * evaluate_conditional_expression(struct expression *expr)
cond = expr->conditional;
ltype = ctype;
- true = cond;
+ true_p = &expr->conditional;
if (expr->cond_true) {
ltype = degenerate(expr->cond_true);
- true = expr->cond_true;
+ true_p = &expr->cond_true;
}
rtype = degenerate(expr->cond_false);
@@ -880,16 +881,16 @@ static struct symbol * evaluate_conditional_expression(struct expression *expr)
if (!typediff)
goto out;
- ctype = compatible_integer_binop(&true, &expr->cond_false);
+ ctype = compatible_integer_binop(true_p, &expr->cond_false);
if (ctype)
goto out;
- ctype = compatible_ptr_type(true, expr->cond_false);
+ ctype = compatible_ptr_type(*true_p, expr->cond_false);
if (ctype)
goto out;
- ctype = compatible_float_binop(&true, &expr->cond_false);
+ ctype = compatible_float_binop(true_p, &expr->cond_false);
if (ctype)
goto out;
- ctype = compatible_restricted_binop('?', &expr->left, &expr->right);
+ ctype = compatible_restricted_binop('?', true_p, &expr->cond_false);
if (ctype)
goto out;
warning(expr->pos, "incompatible types in conditional expression (%s)", typediff);