Quoting Tom Tromey <[EMAIL PROTECTED]>:

"Antoine" == Antoine Eiche <[EMAIL PROTECTED]> writes:

Without more information I don't know how to answer your question.
But I do have a question for you...

Antoine> I must calculate the address of an element's array.
Antoine> If the size of an element is one integer it's good.
Antoine> I do like that:
Antoine> new_rhs=fold_build2(PLUS_EXPR,TREE_TYPE(TREE_OPERAND(rhs,1)),
Antoine> build1(ADDR_EXPR, build_pointer_type (TREE_TYPE
Antoine> (array)),array),
Antoine>                        index);

Why not use ARRAY_REF here?  Then you don't have to worry about the
size of an element of the array.

Tom


I tested whit ARRAY_REF but I did not succeed to build the address (error when I test my pass). Then, I try to calculate the address whit the index and the size of an element.
I specify that I just have the problem whit a static array.

This code is the code which is in the source file of a test program:

int main()
{
int a[10];
int i;
for(i=0;i<10;i++){
    a[i]=1;
}
}

I have succeed to transform the code like that:

int main(){
int a[10];
int i;
for(i=0;i<10;i++){
   foo(a + i);
   a[i]=1;
}
}

But I want to transform like that:

int main(){
int a[10];
int i;
for(i=0;i<10;i++){
   foo(a + i * sizeof(*a));
   a[i]=1;
}
}

I specify that I have not succeed to transform like that!:

int main(){
int a[10];
int i;
for(i=0;i<10;i++){
   foo(& a[i]);
   a[i]=1;
}
}

Why can I not do "foo(a + i * x)" then I can do "foo(i * x)" ou "foo(a + i)" ?*
How can I do that ?

Thanks in advance.




Reply via email to