Revert DECL_USER_ALIGN part of r241959
[official-gcc.git] / gcc / testsuite / gcc.dg / pr56997-2.c
blob759a469bd9e26e57972edbeb291284c5b18b7b80
1 /* Test volatile access to unaligned field. */
2 /* { dg-do run } */
3 /* { dg-require-effective-target size32plus } */
4 /* { dg-options "-fstrict-volatile-bitfields" } */
6 extern void abort (void);
8 #define test_type unsigned int
9 #define MAGIC 0x1020304u
11 typedef struct s{
12 unsigned char Prefix;
13 test_type Type;
14 }__attribute((__packed__)) ss;
16 volatile ss v;
17 ss g;
19 void __attribute__((noinline))
20 foo (test_type u)
22 v.Type = u;
25 test_type __attribute__((noinline))
26 bar (void)
28 return v.Type;
31 int main()
33 test_type temp;
34 foo(MAGIC);
35 __builtin_memcpy(&g, (void *)&v, sizeof(g));
36 if (g.Type != MAGIC)
37 abort ();
39 g.Type = MAGIC;
40 __builtin_memcpy((void *)&v, &g, sizeof(v));
41 temp = bar();
42 if (temp != MAGIC)
43 abort ();
44 return 0;