linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 2/2] fix: evaluate_dereference() unexamined base type
Date: Sat, 25 Nov 2017 10:31:15 +0100	[thread overview]
Message-ID: <20171125093115.95791-3-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20171125093115.95791-1-luc.vanoostenryck@gmail.com>

Examination of a pointer type doesn't examine the corresponding base type
(this base type maybe not yet be complete).
The examination of thz base type must thus be done later.

However, in some cases (maybe only when typeof() is involved) it's
possible to call evaluate_dereference() while the base type is still
unexamined.

Fix this by adding the missing examine_symbol_type() on the base type.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 evaluate.c                                | 2 +-
 validation/bugs/unexamined-base-type-00.c | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/evaluate.c b/evaluate.c
index 4bca13542..bb128ecd8 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -1777,7 +1777,7 @@ static struct symbol *evaluate_dereference(struct expression *expr)
 		ctype = ctype->ctype.base_type;
 
 	node = alloc_symbol(expr->pos, SYM_NODE);
-	target = ctype->ctype.base_type;
+	target = examine_symbol_type(ctype->ctype.base_type);
 
 	switch (ctype->type) {
 	default:
diff --git a/validation/bugs/unexamined-base-type-00.c b/validation/bugs/unexamined-base-type-00.c
index 2032599b7..7749a9def 100644
--- a/validation/bugs/unexamined-base-type-00.c
+++ b/validation/bugs/unexamined-base-type-00.c
@@ -21,7 +21,6 @@ static int foo(struct s *s)
  *		cast.32     %r5 <- (0) %r4	; !! WRONG
  *		and.32      %r6 <- %r5, $1
  *		ret.32      %r6
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-excludes: load[^.]
-- 
2.15.0


  parent reply	other threads:[~2017-11-25  9:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-25  9:31 [PATCH 0/2] fix missing base type examination Luc Van Oostenryck
2017-11-25  9:31 ` [PATCH 1/2] add test case unexamined base type Luc Van Oostenryck
2017-11-25  9:31 ` Luc Van Oostenryck [this message]
2017-11-26 17:48   ` [PATCH 2/2] fix: evaluate_dereference() " Christopher Li
2017-11-26 19:18     ` Luc Van Oostenryck
  -- strict thread matches above, loose matches on Subject: below --
2017-12-21  0:30 [PATCH 0/2] fix examination of " Luc Van Oostenryck
2017-12-21  0:30 ` [PATCH 2/2] fix: evaluate_dereference() unexamined " 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=20171125093115.95791-3-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).