linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Roskin <proski@gnu.org>
To: Thomas Schmid <Thomas.Schmid@br-automation.com>
Cc: linux-sparse@vger.kernel.org
Subject: Re: Messing typedefs?
Date: Wed, 13 Jun 2007 01:22:02 -0400	[thread overview]
Message-ID: <1181712122.22924.15.camel@dv> (raw)
In-Reply-To: <OF97379DC1.5009215C-ONC12572F7.0034F56B-C12572F7.0041E12D@br-automation.com>

Hello Thomas,

On Mon, 2007-06-11 at 13:59 +0200, Thomas Schmid wrote:
> Following code
> 
>         typedef unsigned char  plcbit;
>         typedef unsigned char  USINT;
> 
>         USINT usVar1;
> 
> leads to a symbol "usVar1" with base_type->ident named "plcbit".
> Is this behaviour expected?

This looks like a serious bug to me, although I'm surprised that it
doesn't seem to affect the sparse functionality (at least on the
surface).

What happens is the base types like uchar_ctype, which are supposed to
be initialized once and never changed again, are actually initialized by
the first typedef, so they are sort of "imprinted" with the new name.

This sparse was compiled without optimization to avoid any additional
weirdness.

(gdb) set args usvar.c
(gdb) tb main
Breakpoint 1 at 0x4017bc: file sparse.c, line 278.
(gdb) r
Starting program: /home/proski/src/sparse/sparse usvar.c
main (argc=2, argv=0x7fff6616d7e8) at sparse.c:278
278             struct string_list *filelist = NULL;
(gdb) watch uchar_ctype->ident
Hardware watchpoint 2: uchar_ctype->ident
(gdb) c
Continuing.
Hardware watchpoint 2: uchar_ctype->ident

Old value = (struct ident *) 0x0
New value = (struct ident *) 0x2b3e44959008
0x00000000004257bd in external_declaration (token=0x2b3e44988088, list=0x65ad70)
    at parse.c:2108
2108                            base_type->ident = ident;
(gdb) p *ident
$1 = {next = 0x0, symbols = 0x2b3e4497d548, len = 6 '\006', tainted = 0 '\0', 
  reserved = 0 '\0', keyword = 0 '\0', name = 0x2b3e4495901a "plcbit"}
(gdb)

And the code is:

        if (is_typedef) {
                if (base_type && !base_type->ident)
                        base_type->ident = ident;
        } else if (base_type && base_type->type == SYM_FN) {

I don't know what base_type->ident needs to be updated at all.  At least
SYM_BASETYPE should be exempt from this retroactive update.

-- 
Regards,
Pavel Roskin

  reply	other threads:[~2007-06-13  5:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-11 11:59 Messing typedefs? Thomas Schmid
2007-06-13  5:22 ` Pavel Roskin [this message]
2007-06-26  8:23   ` Antwort: " Thomas Schmid
2007-06-27  5:01     ` Pavel Roskin
2007-06-27  6:51       ` Antwort: " Thomas Schmid
2007-06-29 23:31         ` Pavel Roskin

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=1181712122.22924.15.camel@dv \
    --to=proski@gnu.org \
    --cc=Thomas.Schmid@br-automation.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).