Handle peeling for alignment with masking
[official-gcc.git] / gcc / testsuite / gcc.dg / pr56997-3.c
blob3754b108ac660cd581c47756aa657fa5a84ec8d5
1 /* Test volatile access to unaligned field. */
2 /* { dg-do run } */
3 /* { dg-options "-fstrict-volatile-bitfields" } */
5 extern void abort (void);
7 #define test_type unsigned long long
8 #define MAGIC 0x102030405060708ull
10 typedef struct s{
11 unsigned char Prefix;
12 test_type Type;
13 }__attribute((__packed__)) ss;
15 volatile ss v;
16 ss g;
18 void __attribute__((noinline))
19 foo (test_type u)
21 v.Type = u;
24 test_type __attribute__((noinline))
25 bar (void)
27 return v.Type;
30 int main()
32 test_type temp;
33 foo(MAGIC);
34 __builtin_memcpy(&g, (void *)&v, sizeof(g));
35 if (g.Type != MAGIC)
36 abort ();
38 g.Type = MAGIC;
39 __builtin_memcpy((void *)&v, &g, sizeof(v));
40 temp = bar();
41 if (temp != MAGIC)
42 abort ();
43 return 0;