This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ARRAY_REF patch


> After the code I wrote, add:
> 
>    expr = build2 (ARRAY_REF, elt_type, p, build_int_cst (5));
> 
> I don't promise to have all of this *exactly* right, but close enough...
> 
> The key point is to treat "p" as a pointer not a single element, but 
> rather as a pointer to an array of elements.
> 

So it's supposed to look like:


;; Function main (main)

main ()
{
  intD.0 * pD.1239;
  intD.0[<unknown>] * p.0D.1240;

  # BLOCK 0
  # PRED: ENTRY (fallthru)
  p.0D.1240 = (intD.0[<unknown>] *) pD.1239;
  (*p.0D.1240)[5] = 0;
  return;
  # SUCC: EXIT


for 

int main(void)
{
  int *p;
  p[5] = 0;
}
or am i off by a level of indirection?
I ask because it looks wrong, since it looks like a pointer to an array
instead of the pointer *being* an array, but could very well be right.


--Dan



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]