1  /* PR tree-optimization/108498 */
       2  
       3  struct U { char c[16]; };
       4  struct V { char c[16]; };
       5  struct S { unsigned int a : 3, b : 8, c : 21; struct U d; unsigned int e; struct V f; unsigned int g : 5, h : 27; };
       6  struct T { unsigned int a : 16, b : 8, c : 8; struct U d; unsigned int e; struct V f; unsigned int g : 5, h : 27; };
       7  
       8  __attribute__((noipa)) void
       9  foo (struct S *p)
      10  {
      11    p->b = 231;
      12    p->c = 42;
      13    p->d = (struct U) { "abcdefghijklmno" };
      14    p->e = 0xdeadbeef;
      15    p->f = (struct V) { "ABCDEFGHIJKLMNO" };
      16  }
      17  
      18  __attribute__((noipa)) void
      19  bar (struct S *p)
      20  {
      21    p->b = 231;
      22    p->c = 42;
      23    p->d = (struct U) { "abcdefghijklmno" };
      24    p->e = 0xdeadbeef;
      25    p->f = (struct V) { "ABCDEFGHIJKLMNO" };
      26    p->g = 12;
      27  }
      28  
      29  __attribute__((noipa)) void
      30  baz (struct T *p)
      31  {
      32    p->c = 42;
      33    p->d = (struct U) { "abcdefghijklmno" };
      34    p->e = 0xdeadbeef;
      35    p->f = (struct V) { "ABCDEFGHIJKLMNO" };
      36    p->g = 12;
      37  }
      38  
      39  int
      40  main ()
      41  {
      42    if (__CHAR_BIT__ != 8 || __SIZEOF_INT__ != 4)
      43      return 0;
      44    struct S s = {};
      45    struct T t = {};
      46    foo (&s);
      47    if (s.a != 0 || s.b != 231 || s.c != 42
      48        || __builtin_memcmp (&s.d.c, "abcdefghijklmno", 16) || s.e != 0xdeadbeef
      49        || __builtin_memcmp (&s.f.c, "ABCDEFGHIJKLMNO", 16) || s.g != 0 || s.h != 0)
      50      __builtin_abort ();
      51    __builtin_memset (&s, 0, sizeof (s));
      52    s.a = 7;
      53    s.g = 31;
      54    s.h = (1U << 27) - 1;
      55    foo (&s);
      56    if (s.a != 7 || s.b != 231 || s.c != 42
      57        || __builtin_memcmp (&s.d.c, "abcdefghijklmno", 16) || s.e != 0xdeadbeef
      58        || __builtin_memcmp (&s.f.c, "ABCDEFGHIJKLMNO", 16) || s.g != 31 || s.h != (1U << 27) - 1)
      59      __builtin_abort ();
      60    __builtin_memset (&s, 0, sizeof (s));
      61    bar (&s);
      62    if (s.a != 0 || s.b != 231 || s.c != 42
      63        || __builtin_memcmp (&s.d.c, "abcdefghijklmno", 16) || s.e != 0xdeadbeef
      64        || __builtin_memcmp (&s.f.c, "ABCDEFGHIJKLMNO", 16) || s.g != 12 || s.h != 0)
      65      __builtin_abort ();
      66    __builtin_memset (&s, 0, sizeof (s));
      67    s.a = 7;
      68    s.g = 31;
      69    s.h = (1U << 27) - 1;
      70    bar (&s);
      71    if (s.a != 7 || s.b != 231 || s.c != 42
      72        || __builtin_memcmp (&s.d.c, "abcdefghijklmno", 16) || s.e != 0xdeadbeef
      73        || __builtin_memcmp (&s.f.c, "ABCDEFGHIJKLMNO", 16) || s.g != 12 || s.h != (1U << 27) - 1)
      74      __builtin_abort ();
      75    baz (&t);
      76    if (t.a != 0 || t.b != 0 || t.c != 42
      77        || __builtin_memcmp (&t.d.c, "abcdefghijklmno", 16) || t.e != 0xdeadbeef
      78        || __builtin_memcmp (&t.f.c, "ABCDEFGHIJKLMNO", 16) || t.g != 12 || t.h != 0)
      79      __builtin_abort ();
      80    __builtin_memset (&s, 0, sizeof (s));
      81    t.a = 7;
      82    t.b = 255;
      83    t.g = 31;
      84    t.h = (1U << 27) - 1;
      85    baz (&t);
      86    if (t.a != 7 || t.b != 255 || t.c != 42
      87        || __builtin_memcmp (&t.d.c, "abcdefghijklmno", 16) || t.e != 0xdeadbeef
      88        || __builtin_memcmp (&t.f.c, "ABCDEFGHIJKLMNO", 16) || t.g != 12 || t.h != (1U << 27) - 1)
      89      __builtin_abort ();
      90    return 0;
      91  }