linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dissect: teach do_expression() to handle EXPR_OFFSETOF
@ 2016-02-08 13:26 Oleg Nesterov
  2016-09-26 17:52 ` Lance Richardson
  2016-11-02 14:21 ` [PATCH] " Luc Van Oostenryck
  0 siblings, 2 replies; 3+ messages in thread
From: Oleg Nesterov @ 2016-02-08 13:26 UTC (permalink / raw)
  To: Christopher Li, Josh Triplett; +Cc: linux-sparse

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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: dissect: teach do_expression() to handle EXPR_OFFSETOF
  2016-02-08 13:26 [PATCH] dissect: teach do_expression() to handle EXPR_OFFSETOF Oleg Nesterov
@ 2016-09-26 17:52 ` Lance Richardson
  2016-11-02 14:21 ` [PATCH] " Luc Van Oostenryck
  1 sibling, 0 replies; 3+ messages in thread
From: Lance Richardson @ 2016-09-26 17:52 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Christopher Li, Josh Triplett, linux-sparse

+++ Oleg Nesterov [08/02/16 14:26 +0100]:
>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>

LGTM, builds and test case works as expected.
Acked-by: Lance Richardson <lrichard@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dissect: teach do_expression() to handle EXPR_OFFSETOF
  2016-02-08 13:26 [PATCH] dissect: teach do_expression() to handle EXPR_OFFSETOF Oleg Nesterov
  2016-09-26 17:52 ` Lance Richardson
@ 2016-11-02 14:21 ` Luc Van Oostenryck
  1 sibling, 0 replies; 3+ messages in thread
From: Luc Van Oostenryck @ 2016-11-02 14:21 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Christopher Li, Josh Triplett, linux-sparse

On Mon, Feb 08, 2016 at 02:26:57PM +0100, Oleg Nesterov wrote:
> Starting from a194f3e0 "implement __builtin_offsetof()" sparse handles
> offsetof() internally but dissect.c wasn't updated.
> 

LGTM

Reviewed-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-02 14:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-08 13:26 [PATCH] dissect: teach do_expression() to handle EXPR_OFFSETOF Oleg Nesterov
2016-09-26 17:52 ` Lance Richardson
2016-11-02 14:21 ` [PATCH] " Luc Van Oostenryck

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).