]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.dg/pr56997-1.c
replace ISL with isl
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / pr56997-1.c
CommitLineData
f5d4f18c
SL
1/* Test volatile access to unaligned field. */
2/* { dg-do run } */
3/* { dg-options "-fstrict-volatile-bitfields" } */
4
5extern void abort (void);
6
7#define test_type unsigned short
8#define MAGIC (unsigned short)0x102u
9
10typedef struct s{
11 unsigned char Prefix;
12 test_type Type;
13}__attribute((__packed__)) ss;
14
15volatile ss v;
16ss g;
17
18void __attribute__((noinline))
19foo (test_type u)
20{
21 v.Type = u;
22}
23
24test_type __attribute__((noinline))
25bar (void)
26{
27 return v.Type;
28}
29
30int main()
31{
32 test_type temp;
33 foo(MAGIC);
34 __builtin_memcpy(&g, (void *)&v, sizeof(g));
35 if (g.Type != MAGIC)
36 abort ();
37
38 g.Type = MAGIC;
39 __builtin_memcpy((void *)&v, &g, sizeof(v));
40 temp = bar();
41 if (temp != MAGIC)
42 abort ();
43 return 0;
44}