From: "Christopher Li" <sparse@chrisli.org>
To: Alexey Zaytsev <alexey.zaytsev@gmail.com>
Cc: Josh Triplett <josht@linux.vnet.ibm.com>,
David Given <dg@cowlark.com>,
linux-sparse@vger.kernel.org
Subject: Re: Odd sparse behaviour
Date: Mon, 7 Jul 2008 12:42:17 -0700 [thread overview]
Message-ID: <70318cbf0807071242k445297d0s79d3481eaa5a8899@mail.gmail.com> (raw)
In-Reply-To: <f19298770807071109s529f2215sc4b7d7f1f7011208@mail.gmail.com>
On Mon, Jul 7, 2008 at 11:09 AM, Alexey Zaytsev
<alexey.zaytsev@gmail.com> wrote:
>
> /* Parse declaration-specifiers, if any */
> token = declaration_specifiers(token, &ctype, 0);
> decl = alloc_symbol(token->pos, SYM_NODE);
> decl->ctype = ctype;
> token = declarator(token, decl, &ident);
> apply_modifiers(token->pos, &decl->ctype);
>
> I think that after calling declaration_specifiers(), we should
> check if token_type(token) == TOKEN_IDENT and lookup
> the symbol in the relevant namespaces. If it is found, we shoud
> check if the types and produce soe warnings. And reuse the
> symbol, if the types match.
This is a old bug of sparse and unfortunately very nasty to fix.
I have considered some thing similar to your approach before.
Yours is too simple, it can't handle node is a pointer for example.
But even if we change direct_declarator, there is other problem
with this approach. The type evaluate happens _after_ the
parsing stage. So at the parsing state it is very hard to answer
the question "if the types match". No to mention "reuse the symbol"
does break a lot of the assumption of the parsing code which
assume symbol node is new. It just blindly assign ctype members
rather than merging it.
On the other hand, breaking that assumption might be a good thing
for other reasons. One of the thing I really want to do is make the
ctype have some optional attribute fields. e.g. no return functions.
We are running out of bits in the ctype attribute. Keep on adding
member to ctype does not scale because it is used every where.
Another approach to this problem is let parsing code create a new node.
Let check_duplicates merge the symbol if the type matches.
Then evaluate_symbol needs to return the merged result symbol
as well. The caller need to either place the current one with
the new symbol or delete the original one from the list.
Replacing the original symbol part seems ugly. On the bright side
there is not too many place needs it. It will have a smaller patch
than the first approach.
I like to heard if any one else have better suggestion as well.
Chris
prev parent reply other threads:[~2008-07-07 19:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-06 21:33 Odd sparse behaviour David Given
2008-07-07 17:48 ` Josh Triplett
2008-07-07 18:09 ` Alexey Zaytsev
2008-07-07 19:42 ` Christopher Li [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=70318cbf0807071242k445297d0s79d3481eaa5a8899@mail.gmail.com \
--to=sparse@chrisli.org \
--cc=alexey.zaytsev@gmail.com \
--cc=dg@cowlark.com \
--cc=josht@linux.vnet.ibm.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).