diff options
author | Josh Triplett <josh@freedesktop.org> | 2008-12-18 01:33:19 +0300 |
---|---|---|
committer | Alexey Zaytsev <alexey.zaytsev@gmail.com> | 2008-12-18 21:11:00 +0300 |
commit | e34179b2e784ee6b4de195e69d5898127015545a (patch) | |
tree | d83ff141ebbb8de259f5afebca6c89193482ecf3 /evaluate.c | |
parent | Add enum member list to the parent (diff) | |
download | sparse-e34179b2e784ee6b4de195e69d5898127015545a.tar.gz sparse-e34179b2e784ee6b4de195e69d5898127015545a.tar.bz2 sparse-e34179b2e784ee6b4de195e69d5898127015545a.zip |
Expand "dubious !x & y" handling to other combinations of !, &, and |.
Signed-off-by: Josh Triplett <josh@freedesktop.org>
Diffstat (limited to 'evaluate.c')
-rw-r--r-- | evaluate.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -921,9 +921,16 @@ static struct symbol *evaluate_binop(struct expression *expr) rtype = integer_promotion(rtype); } else { // The rest do usual conversions - if (op == '&' && expr->left->type == EXPR_PREOP && - expr->left->op == '!') - warning(expr->pos, "dubious: !x & y"); + const unsigned left_not = expr->left->type == EXPR_PREOP + && expr->left->op == '!'; + const unsigned right_not = expr->right->type == EXPR_PREOP + && expr->right->op == '!'; + if ((op == '&' || op == '|') && (left_not || right_not)) + warning(expr->pos, "dubious: %sx %c %sy", + left_not ? "!" : "", + op, + right_not ? "!" : ""); + ltype = usual_conversions(op, expr->left, expr->right, lclass, rclass, ltype, rtype); ctype = rtype = ltype; |