From: Oleg Nesterov <oleg@redhat.com>
To: Christopher Li <sparse@chrisli.org>, Josh Triplett <josh@kernel.org>
Cc: linux-sparse@vger.kernel.org
Subject: [PATCH] dissect: teach do_expression() to handle EXPR_OFFSETOF
Date: Mon, 8 Feb 2016 14:26:57 +0100 [thread overview]
Message-ID: <20160208132657.GA19007@redhat.com> (raw)
Starting from a194f3e0 "implement __builtin_offsetof()" sparse handles
offsetof() internally but dissect.c wasn't updated.
Test case:
struct S { int m; };
void func(void)
{
__builtin_offsetof(struct S, m);
}
before this patch:
3:6 g def func void ( ... )
T.c:5:38: warning: bad expr->type: 30
after:
3:6 g def func void ( ... )
1:8 s def S
5:38 s --- S.m int
While at it, update my email.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
dissect.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/dissect.c b/dissect.c
index d211bca..19f3276 100644
--- a/dissect.c
+++ b/dissect.c
@@ -1,7 +1,7 @@
/*
* sparse/dissect.c
*
- * Started by Oleg Nesterov <oleg@tv-sign.ru>
+ * Started by Oleg Nesterov <oleg@redhat.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -429,6 +429,20 @@ again:
lookup_member(p_type, expr->member, NULL));
}
+ break; case EXPR_OFFSETOF: {
+ struct symbol *in = base_type(expr->in);
+
+ do {
+ if (expr->op == '.') {
+ in = report_member(U_VOID, &expr->pos, in,
+ lookup_member(in, expr->ident, NULL));
+ } else {
+ do_expression(U_R_VAL, expr->index);
+ in = in->ctype.base_type;
+ }
+ } while ((expr = expr->down));
+ }
+
break; case EXPR_SYMBOL:
ret = report_symbol(mode, expr);
}
--
2.5.0
next reply other threads:[~2016-02-08 13:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-08 13:26 Oleg Nesterov [this message]
2016-09-26 17:52 ` dissect: teach do_expression() to handle EXPR_OFFSETOF Lance Richardson
2016-11-02 14:21 ` [PATCH] " 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=20160208132657.GA19007@redhat.com \
--to=oleg@redhat.com \
--cc=josh@kernel.org \
--cc=linux-sparse@vger.kernel.org \
--cc=sparse@chrisli.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.