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