smatch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Murray <andrew.murray@arm.com>
To: smatch@vger.kernel.org
Subject: Address space of struct member
Date: Mon, 8 Jul 2019 14:11:31 +0100	[thread overview]
Message-ID: <20190708131130.GL7227@e119886-lin.cambridge.arm.com> (raw)

Hello,

I'm trying to obtain the address space of a member struct variable, e.g.
Given the following test code:

struct astruct {
        int __attribute__((address_space(5))) member1;
};

int main(void)
{
        struct astruct thestruct;
        int __attribute__((address_space(5))) local;

        if (local > 1)
                ;

        if (thestruct.member1 > 1)
                ;

        return 0;
}


And the following smatch check:

static void check(struct expression *expr)
{
        struct symbol *sym;
        expr_to_var_sym(expr, &sym);
        if (sym)
                sm_warning("Address space %d\n", sym->ctype.as);
}

void check_as(int id)
{
        add_hook(&check, SYM_HOOK);
}

When I run this check, it correctly picks up that 'local' has address
space 5 - however it incorrectly indicates that 'member1' has address
space 0.

Is there something that I am doing wrong? Or is this something I need
to fix?

Thanks,

Andrew Murray

             reply	other threads:[~2019-07-08 13:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-08 13:11 Andrew Murray [this message]
2019-07-10 11:16 ` Address space of struct member Dan Carpenter

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=20190708131130.GL7227@e119886-lin.cambridge.arm.com \
    --to=andrew.murray@arm.com \
    --cc=smatch@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 read-only IMAP folder(s) and NNTP newsgroup(s).