re PR testsuite/48676 ([sh] Unaligned userspace access in gcc.dg/torture/pr37868.c)
[gcc.git] / gcc / testsuite / gcc.dg / torture / pr37868.c
1 /* { dg-do run } */
2 /* { dg-options "-fno-strict-aliasing" } */
3 /* { dg-skip-if "unaligned access" { sparc*-*-* sh*-*-* } "*" "" } */
4
5 extern void abort (void);
6 #if (__SIZEOF_INT__ <= 2)
7 struct X {
8 unsigned char pad : 4;
9 unsigned int a : 16;
10 unsigned int b : 8;
11 unsigned int c : 6;
12 } __attribute__((packed));
13 #else
14 struct X {
15 unsigned char pad : 4;
16 unsigned int a : 32;
17 unsigned int b : 24;
18 unsigned int c : 6;
19 } __attribute__((packed));
20
21 #endif
22
23
24 int main (void)
25 {
26 struct X x;
27 unsigned int bad_bits;
28
29 x.pad = -1;
30 x.a = -1;
31 x.b = -1;
32 x.c = -1;
33
34 bad_bits = ((unsigned int)-1) ^ *(1+(unsigned int *) &x);
35 if (bad_bits != 0)
36 abort ();
37 return 0;
38 }
39