From: Dan Carpenter <dan.carpenter@oracle.com>
To: linux-sparse@vger.kernel.org
Subject: Re: variable size array declarations
Date: Thu, 17 Nov 2011 11:13:52 +0300 [thread overview]
Message-ID: <20111117081352.GF29436@mwanda> (raw)
In-Reply-To: <20111031140829.GD15494@mwanda>
[-- Attachment #1: Type: text/plain, Size: 1161 bytes --]
On Mon, Oct 31, 2011 at 05:08:29PM +0300, Dan Carpenter wrote:
> I am trying to check something in Smatch with variable size arrays
> and I'm running into problems. Here is the function I'm trying to
> parse.
>
> void func(int x)
> {
> char buf[x];
> }
>
> Array symbols have an ->array_size. It gets set correctly in parse.c
> to expression of type EXPR_SYMBOL. But by the time I parse it in
> Smatch the ->array_size is now an EXPR_PREOP (a dereference). In
> fact all the variables seem to get change to dereferences of the
> variables.
>
I tracked this down. In smatch, how I use sparse is that I call
sparse_keep_tokens() and then I parse the resulting symbol list
myself.
In examine_array_type() we call get_expression_value() which changes
the symbols from normal symbols to dereferences. The call tree is:
examine_array_type()
-> get_expression_value()
-> __get_expression_value()
-> evaluate_expression()
-> evaluate_symbol_expression() <- change happens here.
The problem for me is that not all expressions have been evualated
like this so it's not consistent.
regards,
dan carpenter
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
prev parent reply other threads:[~2011-11-17 8:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-31 14:08 variable size array declarations Dan Carpenter
2011-11-17 8:13 ` Dan Carpenter [this message]
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=20111117081352.GF29436@mwanda \
--to=dan.carpenter@oracle.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).