From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 3/3] fix: add missing degenerate() for logical not
Date: Thu, 7 Dec 2017 18:16:13 +0100 [thread overview]
Message-ID: <20171207171613.34989-4-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20171207171613.34989-1-luc.vanoostenryck@gmail.com>
Expressions involving the logical-not '!' does not
call degenerate().
Since the result type is always 'int' and thus independent
of the expression being negated, this has no effect on the
type-checking but the linearization is wrong.
For example, code like:
int foo(void)
{
if (!arr) return 1;
return 0;
}
generates:
foo:
load %r6 <- 0[arr]
seteq.32 %r7 <- VOID, $0
ret.32 %r7
The 'load' being, obviously wrong.
Fix this by adding the missing degenerate().
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
evaluate.c | 1 +
validation/linear/degen-log-not.c | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/evaluate.c b/evaluate.c
index 4bca13542..6b3e2c257 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -1914,6 +1914,7 @@ static struct symbol *evaluate_preop(struct expression *expr)
return evaluate_postop(expr);
case '!':
+ ctype = degenerate(expr->unop);
expr->flags = expr->unop->flags & ~CEF_CONST_MASK;
/*
* A logical negation never yields an address constant
diff --git a/validation/linear/degen-log-not.c b/validation/linear/degen-log-not.c
index baa7d5366..a982e34b2 100644
--- a/validation/linear/degen-log-not.c
+++ b/validation/linear/degen-log-not.c
@@ -33,7 +33,6 @@ int test_fun_degen(int i)
/*
* check-name: degenerate logical-not
* check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
*
* check-output-ignore
* check-output-excludes: load
--
2.15.0
next prev parent reply other threads:[~2017-12-07 17:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-07 17:16 [PATCH 0/3] add missing degenerate() for logical-not Luc Van Oostenryck
2017-12-07 17:16 ` [PATCH 1/3] add more testcases for using addresses in conditionals Luc Van Oostenryck
2017-12-07 17:16 ` [PATCH 2/3] add testcases linearization of degenerated arrays/functions Luc Van Oostenryck
2017-12-07 17:16 ` Luc Van Oostenryck [this message]
2017-12-08 1:49 ` [PATCH 3/3] fix: add missing degenerate() for logical not Christopher Li
2017-12-10 17:23 ` Luc Van Oostenryck
2017-12-10 17:24 ` [PATCH 0/3] add missing degenerate() for logical-not Luc Van Oostenryck
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=20171207171613.34989-4-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.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).