All of lore.kernel.org
 help / color / mirror / Atom feed
* attributes are not stored at right location for array variables
@ 2007-01-31 16:57 Mitesh Shah
  2007-01-31 19:53 ` Chris Li
  0 siblings, 1 reply; 3+ messages in thread
From: Mitesh Shah @ 2007-01-31 16:57 UTC (permalink / raw)
  To: Linux-Sparse


It seems that the attributes are not stored with the variable ctype when the variable is an array. For declaration such as,

char c[100] __attribute__((aligned(64)));

The attribute is stored with the array ctype instead of the variable C ctype.

In function direct_declarator in parse.c at line 920 the ctype gets replaced with the array ctype and in the next iteration it is
passed to handle_attributes. handle_attributes should be passed the original ctype so here is the patch.

Thanks,

-Mitesh

-------------------------------------------------------

index 5077ee6..306b144 100644
--- a/parse.c
+++ b/parse.c
@@ -881,7 +881,7 @@ static struct token *direct_declarator(struct token *token, struct symbol *decl,
        }

        for (;;) {
-               token = handle_attributes(token, ctype);
+               token = handle_attributes(token, &decl->ctype);

                if (token_type(token) != TOKEN_SPECIAL)
                        return token;

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

* Re: attributes are not stored at right location for array variables
  2007-01-31 16:57 attributes are not stored at right location for array variables Mitesh Shah
@ 2007-01-31 19:53 ` Chris Li
  2007-01-31 22:33   ` Mitesh Shah
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Li @ 2007-01-31 19:53 UTC (permalink / raw)
  To: Mitesh Shah; +Cc: Linux-Sparse

Your patch assumes every attribute apply to node instead of type.
Is there any attribute need to apply to type instead?

For your change, apply_modifiers() need to change where it take the
__mode__ attribute as well.

Chris


On 1/31/07, Mitesh Shah <mshah@teja.com> wrote:
>
> It seems that the attributes are not stored with the variable ctype when the variable is an array. For declaration such as,
>
> char c[100] __attribute__((aligned(64)));
>
> The attribute is stored with the array ctype instead of the variable C ctype.
>
> In function direct_declarator in parse.c at line 920 the ctype gets replaced with the array ctype and in the next iteration it is
> passed to handle_attributes. handle_attributes should be passed the original ctype so here is the patch.
>
> Thanks,
>
> -Mitesh
>
> -------------------------------------------------------
>
> index 5077ee6..306b144 100644
> --- a/parse.c
> +++ b/parse.c
> @@ -881,7 +881,7 @@ static struct token *direct_declarator(struct token *token, struct symbol *decl,
>         }
>
>         for (;;) {
> -               token = handle_attributes(token, ctype);
> +               token = handle_attributes(token, &decl->ctype);
>
>                 if (token_type(token) != TOKEN_SPECIAL)
>                         return token;
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* RE: attributes are not stored at right location for array variables
  2007-01-31 19:53 ` Chris Li
@ 2007-01-31 22:33   ` Mitesh Shah
  0 siblings, 0 replies; 3+ messages in thread
From: Mitesh Shah @ 2007-01-31 22:33 UTC (permalink / raw)
  To: Chris Li; +Cc: Linux-Sparse


Yes, there are attributes that can be applied to types so I do not want to change that.

The problem I am seeing is only with array variables and if you see the function direct_delcalartor, when it starts processing array
variables, the ctye gets reassigned with the type of the variables instead of the ctype of the variable itself and in the next
iteration the attribute will be applied to the ctype of the type of the variable.

May be a patch specific to array variable will solve the problem.

Thanks,

-Mitesh



> -----Original Message-----
> From: Chris Li [mailto:christ.li@gmail.com]
> Sent: Wednesday, January 31, 2007 11:54 AM
> To: Mitesh Shah
> Cc: Linux-Sparse
> Subject: Re: attributes are not stored at right location for array
> variables
>
>
> Your patch assumes every attribute apply to node instead of type.
> Is there any attribute need to apply to type instead?
>
> For your change, apply_modifiers() need to change where it take the
> __mode__ attribute as well.
>
> Chris
>
>
> On 1/31/07, Mitesh Shah <mshah@teja.com> wrote:
> >
> > It seems that the attributes are not stored with the variable ctype when the variable is an array. For declaration such as,
> >
> > char c[100] __attribute__((aligned(64)));
> >
> > The attribute is stored with the array ctype instead of the variable C ctype.
> >
> > In function direct_declarator in parse.c at line 920 the ctype gets replaced with the array ctype and in the next
> iteration it is
> > passed to handle_attributes. handle_attributes should be passed the original ctype so here is the patch.
> >
> > Thanks,
> >
> > -Mitesh
> >
> > -------------------------------------------------------
> >
> > index 5077ee6..306b144 100644
> > --- a/parse.c
> > +++ b/parse.c
> > @@ -881,7 +881,7 @@ static struct token *direct_declarator(struct token *token, struct symbol *decl,
> >         }
> >
> >         for (;;) {
> > -               token = handle_attributes(token, ctype);
> > +               token = handle_attributes(token, &decl->ctype);
> >
> >                 if (token_type(token) != TOKEN_SPECIAL)
> >                         return token;
> >
> >
> > -
> > To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
>

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

end of thread, other threads:[~2007-01-31 22:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-31 16:57 attributes are not stored at right location for array variables Mitesh Shah
2007-01-31 19:53 ` Chris Li
2007-01-31 22:33   ` Mitesh Shah

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.