linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dissect: fix multidimensional array initializer
@ 2006-12-14 21:35 Oleg Nesterov
  2006-12-18 21:50 ` Christopher Li
  2007-02-23  5:27 ` Josh Triplett
  0 siblings, 2 replies; 4+ messages in thread
From: Oleg Nesterov @ 2006-12-14 21:35 UTC (permalink / raw)
  To: Josh Triplett; +Cc: Christopher Li, linux-sparse

dissect can't parse initializers like

	struct T { int i; } a[2][3] = { [0][0] = {123} };

, output is:

	   1:8   s def  T
	   1:21  g def  a                                struct T [3][2]
	   1:21  g -w-  a                                struct T [3][2]
	T.c:1:37: warning: bad expr->type: 25

with this patch applied:

	   1:8   s def  T
	   1:21  g def  a                                struct T [3][2]
	   1:21  g -w-  a                                struct T [3][2]
	   1:43  s -w-  T.i                              int

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- DS/dissect.c~	2006-04-20 03:03:33.000000000 +0400
+++ DS/dissect.c	2006-04-20 03:03:42.000000000 +0400
@@ -507,10 +507,13 @@ static struct symbol *do_initializer(str
 	default:
 		do_expression(u_lval(type), expr);
 
+	break; case EXPR_INDEX:
+		do_initializer(base_type(type), expr->idx_expression);
+
 	break; case EXPR_INITIALIZER:
 		m_addr = 0;
 		FOR_EACH_PTR(expr->expr_list, m_expr)
-			if(type->type == SYM_ARRAY) {
+			if (type->type == SYM_ARRAY) {
 				m_type = base_type(type);
 				if (m_expr->type == EXPR_INDEX)
 					m_expr = m_expr->idx_expression;

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

* Re: [PATCH] dissect: fix multidimensional array initializer
  2006-12-14 21:35 [PATCH] dissect: fix multidimensional array initializer Oleg Nesterov
@ 2006-12-18 21:50 ` Christopher Li
  2006-12-18 22:54   ` Oleg Nesterov
  2007-02-23  5:27 ` Josh Triplett
  1 sibling, 1 reply; 4+ messages in thread
From: Christopher Li @ 2006-12-18 21:50 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Josh Triplett, linux-sparse

I did not test it myself, but it looks seasonable to me.

BTW, did you look at the show-parse series of function?
It is a good example of how to traverse the symbol tree.
I would love to see dissect using similar structure. 
 
Chris

On Fri, Dec 15, 2006 at 12:35:47AM +0300, Oleg Nesterov wrote:
> dissect can't parse initializers like
> 
> 	struct T { int i; } a[2][3] = { [0][0] = {123} };
> 
> , output is:
> 
> 	   1:8   s def  T
> 	   1:21  g def  a                                struct T [3][2]
> 	   1:21  g -w-  a                                struct T [3][2]
> 	T.c:1:37: warning: bad expr->type: 25
> 
> with this patch applied:
> 
> 	   1:8   s def  T
> 	   1:21  g def  a                                struct T [3][2]
> 	   1:21  g -w-  a                                struct T [3][2]
> 	   1:43  s -w-  T.i                              int
> 
> Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
> 
> --- DS/dissect.c~	2006-04-20 03:03:33.000000000 +0400
> +++ DS/dissect.c	2006-04-20 03:03:42.000000000 +0400
> @@ -507,10 +507,13 @@ static struct symbol *do_initializer(str
>  	default:
>  		do_expression(u_lval(type), expr);
>  
> +	break; case EXPR_INDEX:
> +		do_initializer(base_type(type), expr->idx_expression);
> +
>  	break; case EXPR_INITIALIZER:
>  		m_addr = 0;
>  		FOR_EACH_PTR(expr->expr_list, m_expr)
> -			if(type->type == SYM_ARRAY) {
> +			if (type->type == SYM_ARRAY) {
>  				m_type = base_type(type);
>  				if (m_expr->type == EXPR_INDEX)
>  					m_expr = m_expr->idx_expression;

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

* Re: [PATCH] dissect: fix multidimensional array initializer
  2006-12-18 21:50 ` Christopher Li
@ 2006-12-18 22:54   ` Oleg Nesterov
  0 siblings, 0 replies; 4+ messages in thread
From: Oleg Nesterov @ 2006-12-18 22:54 UTC (permalink / raw)
  To: Christopher Li; +Cc: Josh Triplett, linux-sparse

On 12/18, Christopher Li wrote:
>
> I did not test it myself, but it looks seasonable to me.

Thanks.

> BTW, did you look at the show-parse series of function?
> It is a good example of how to traverse the symbol tree.
> I would love to see dissect using similar structure. 

dissect is quite different, please look at
	http://marc.theaimsgroup.com/?l=linux-sparse&m=112585110531119

And it is (I hope) complete. Note also it doesn't use evaluate.c,
it calls __sparse(). I am still waiting somebody will implement
sparse based cscope using dissect :)

What exactly you don't like in how it traverses the tree?
Actually, the structure is similar, but diisect has to track
"usage_t mode".

Oleg.

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

* Re: [PATCH] dissect: fix multidimensional array initializer
  2006-12-14 21:35 [PATCH] dissect: fix multidimensional array initializer Oleg Nesterov
  2006-12-18 21:50 ` Christopher Li
@ 2007-02-23  5:27 ` Josh Triplett
  1 sibling, 0 replies; 4+ messages in thread
From: Josh Triplett @ 2007-02-23  5:27 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Christopher Li, linux-sparse

[-- Attachment #1: Type: text/plain, Size: 689 bytes --]

Oleg Nesterov wrote:
> dissect can't parse initializers like
> 
> 	struct T { int i; } a[2][3] = { [0][0] = {123} };
> 
> , output is:
> 
> 	   1:8   s def  T
> 	   1:21  g def  a                                struct T [3][2]
> 	   1:21  g -w-  a                                struct T [3][2]
> 	T.c:1:37: warning: bad expr->type: 25
> 
> with this patch applied:
> 
> 	   1:8   s def  T
> 	   1:21  g def  a                                struct T [3][2]
> 	   1:21  g -w-  a                                struct T [3][2]
> 	   1:43  s -w-  T.i                              int
> 
> Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

Applied.

- Josh Triplett



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

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

end of thread, other threads:[~2007-02-23  5:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-14 21:35 [PATCH] dissect: fix multidimensional array initializer Oleg Nesterov
2006-12-18 21:50 ` Christopher Li
2006-12-18 22:54   ` Oleg Nesterov
2007-02-23  5:27 ` Josh Triplett

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