boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

038-arrow.c (377B)


      1 // tests/cc-parse/38-arrow.c — pointer-to-struct field access via real C.
      2 // Validates the arrow arm: rval the pointer, deref to reach the struct,
      3 // push-field at the right offset.
      4 //
      5 // p->a=4; p->b=9; return p->b - p->a;  =>  exit 5.
      6 
      7 int main() {
      8     struct S { int a; int b; };
      9     struct S s;
     10     struct S *p = &s;
     11     p->a = 4;
     12     p->b = 9;
     13     return p->b - p->a;
     14 }