111
|
1 /* Test volatile access to unaligned field. */
|
|
2 /* { dg-do run } */
|
|
3 /* { dg-require-effective-target size32plus } */
|
|
4 /* { dg-options "-fstrict-volatile-bitfields" } */
|
|
5
|
|
6 extern void abort (void);
|
|
7
|
|
8 #define test_type unsigned int
|
|
9 #define MAGIC 0x1020304u
|
|
10
|
|
11 typedef struct s{
|
|
12 unsigned char Prefix;
|
|
13 test_type Type;
|
|
14 }__attribute((__packed__)) ss;
|
|
15
|
|
16 volatile ss v;
|
|
17 ss g;
|
|
18
|
|
19 void __attribute__((noinline))
|
|
20 foo (test_type u)
|
|
21 {
|
|
22 v.Type = u;
|
|
23 }
|
|
24
|
|
25 test_type __attribute__((noinline))
|
|
26 bar (void)
|
|
27 {
|
|
28 return v.Type;
|
|
29 }
|
|
30
|
|
31 int main()
|
|
32 {
|
|
33 test_type temp;
|
|
34 foo(MAGIC);
|
|
35 __builtin_memcpy(&g, (void *)&v, sizeof(g));
|
|
36 if (g.Type != MAGIC)
|
|
37 abort ();
|
|
38
|
|
39 g.Type = MAGIC;
|
|
40 __builtin_memcpy((void *)&v, &g, sizeof(v));
|
|
41 temp = bar();
|
|
42 if (temp != MAGIC)
|
|
43 abort ();
|
|
44 return 0;
|
|
45 }
|