kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

call_indirect_ret_into_indirect.c (483B)


      1 /* The destination of a call's return value is an OPK_INDIRECT lvalue:
      2  * `row[i].v = make_int()`. The call's return-receive must store the
      3  * return register through the indirect destination. */
      4 typedef struct {
      5   int v;
      6   int x;
      7 } Row;
      8 
      9 int make_int(void) { return 42; }
     10 
     11 void store_ret(Row* row, int i) { row[i].v = make_int(); }
     12 
     13 int test_main(void) {
     14   Row rows[2];
     15   rows[0].v = 0;
     16   rows[0].x = 0;
     17   rows[1].v = 0;
     18   rows[1].x = 0;
     19   store_ret(rows, 0);
     20   return rows[0].v;
     21 }