diff mbox

[2/2] fix expression type for floating point !

Message ID 1369402236-16871-2-git-send-email-xi.wang@gmail.com (mailing list archive)
State Mainlined, archived
Headers show

Commit Message

Xi Wang May 24, 2013, 1:30 p.m. UTC
Run test-linearize against this program.

	static int foo(float x) { return !x; }

The output is:

	set.32      %r2 <- 0.000000
	bad_op.32
	ret.32      %r3

The expression type of zero testing should be EXPR_COMPARE, rather than
EXPR_BINOP, which causes bad_op.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
---
 evaluate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christopher Li May 27, 2013, 8:09 a.m. UTC | #1
On Fri, May 24, 2013 at 09:30:36AM -0400, Xi Wang wrote:
> 
> The expression type of zero testing should be EXPR_COMPARE, rather than
> EXPR_BINOP, which causes bad_op.
> 
> Signed-off-by: Xi Wang <xi.wang@gmail.com>

Acked-By: Christopher Li <sparse@chrisli.org>

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pekka Enberg May 27, 2013, 11:13 a.m. UTC | #2
On Fri, May 24, 2013 at 09:30:36AM -0400, Xi Wang wrote:
>>
>> The expression type of zero testing should be EXPR_COMPARE, rather than
>> EXPR_BINOP, which causes bad_op.
>>
>> Signed-off-by: Xi Wang <xi.wang@gmail.com>

On Mon, May 27, 2013 at 11:09 AM, Christopher Li <sparse@chrisli.org> wrote:
> Acked-By: Christopher Li <sparse@chrisli.org>

I'll pick this up as well.
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/evaluate.c b/evaluate.c
index 5d87444..19be637 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -1797,7 +1797,7 @@  static struct symbol *evaluate_preop(struct expression *expr)
 			warning(expr->pos, "testing a 'safe expression'");
 		if (is_float_type(ctype)) {
 			struct expression *arg = expr->unop;
-			expr->type = EXPR_BINOP;
+			expr->type = EXPR_COMPARE;
 			expr->op = SPECIAL_EQUAL;
 			expr->left = arg;
 			expr->right = alloc_expression(expr->pos, EXPR_FVALUE);