On Tue, Apr 21, 2009 at 9:57 AM, Divya Krishnan
<divya1...@users.sourceforge.net> wrote:
> Hi,
> Although that works fine for basic types, there is a problem for arrays as
> it adds the word volatile after the type of the variable.
> Basically if my input is:
> int c[10];
> I want my output to be
> volatile int c[10];
> I added following code where elt.vtype is the type of exisiting variable
> let attr_list =ref [] in
>    attr_list := Attr("volatile",[]) :: !attr_list;
> let temp_type = elt.vtype in
> let new_type_var = typeAddAttributes !attr_list temp_type  in
> let temp = makeTempVar fd new_type_var
>
> However this gives output as
> int   ( volatile  c)[9] ;
>
> Also on examining the  TArray type I notice that the attr field is empty
> even for a volatile array. In that case where exactly is the volatile
> attribute stored for arrays?

>From a type perspective, C arrays don't have qualifiers, only their
base type does. E.g. you can have

  a is an array of 10 volatile ints: int volatile a[10]

put you can't have

  a is a volatile array of 10 ints: int (volatile a)[10] // as another
message notes, this would be illegal C syntax

What that means is that to add volatile to a CIL type t, you need to
check if t is TArray(t', ...), and if so add the attribute to t'...

Arguably, CIL shouldn't have allowed attributes on arrays, and done
that automatically in typeAddAttributes. But it didn't, so... (the
advantage is that your CIL input can have attributes on types for your
own purposes).

David Gay

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
CIL-users mailing list
CIL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cil-users

Reply via email to