boot2

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

352-aggregate-compound-call.c (796B)


      1 /* A two-word compound literal passed directly by value must populate both
      2  * ABI argument words.  Kit uses this shape for KIT_SLICE_LIT in parser setup. */
      3 struct Slice {
      4     const char *text;
      5     unsigned long len;
      6 };
      7 
      8 static unsigned long inspect(struct Slice slice)
      9 {
     10     if (!slice.text) return 1;
     11     if (slice.text[0] != 'a') return 2;
     12     if (slice.text[1] != 'b') return 3;
     13     if (slice.text[2] != 'c') return 4;
     14     if (slice.len != 3) return 5;
     15     return 0;
     16 }
     17 
     18 int main(void)
     19 {
     20     struct Slice slice = (struct Slice){
     21         .text = "abc",
     22         .len = sizeof("abc") - 1,
     23     };
     24     if (slice.len != 3) return (int)(10 + slice.len);
     25     if (inspect(slice) != 0) return 7;
     26     return (int)inspect((struct Slice){
     27         .text = "abc",
     28         .len = sizeof("abc") - 1,
     29     });
     30 }