boot2

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

349-aggregate-indirect-lvalue-arg.c (638B)


      1 /* A small aggregate passed from an indirect lvalue must contribute its
      2  * contents to the ABI argument slot, not the address of the lvalue.  This is
      3  * the shape produced by `p->loc` throughout Kit's preprocessor. */
      4 struct LocRef {
      5     unsigned file_id;
      6     unsigned off;
      7 };
      8 
      9 struct Token {
     10     unsigned kind;
     11     struct LocRef loc;
     12 };
     13 
     14 static int check(struct LocRef loc)
     15 {
     16     if (loc.file_id != 17) return 1;
     17     if (loc.off != 29) return 2;
     18     return 0;
     19 }
     20 
     21 static int check_token(struct Token *token)
     22 {
     23     return check(token->loc);
     24 }
     25 
     26 int main(void)
     27 {
     28     struct Token token = { 3, { 17, 29 } };
     29     return check_token(&token);
     30 }