linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xi Wang <xi.wang@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: sparse@chrisli.org, Xi Wang <xi.wang@gmail.com>
Subject: [PATCH] fix logical operand type
Date: Thu, 16 May 2013 16:56:19 -0400	[thread overview]
Message-ID: <1368737779-6601-1-git-send-email-xi.wang@gmail.com> (raw)

The type of logical operands should be bool.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
---
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(+)

diff --git a/evaluate.c b/evaluate.c
index c345a50..8954ff2 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -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;
-- 
1.8.1.2


                 reply	other threads:[~2013-05-16 21:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1368737779-6601-1-git-send-email-xi.wang@gmail.com \
    --to=xi.wang@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).