111
|
1 /* Test for MS bitfield layout */
|
|
2 /* { dg-do run { target *-*-mingw* *-*-cygwin* i?86-*-* x86_64-*-* } } */
|
|
3
|
|
4 extern void abort();
|
|
5
|
|
6 struct s1_t {
|
|
7 char a;
|
|
8 char b __attribute__ ((aligned (16)));
|
|
9 } __attribute__ ((ms_struct));
|
|
10 struct s1_t s1;
|
|
11
|
|
12 struct s2_t {
|
|
13 char a;
|
|
14 char b;
|
|
15 } __attribute__ ((ms_struct));
|
|
16 struct s2_t s2;
|
|
17
|
|
18 struct s3_t {
|
|
19 __extension__ char a : 6;
|
|
20 char b __attribute__ ((aligned (16)));
|
|
21 } __attribute__ ((ms_struct));
|
|
22 struct s3_t s3;
|
|
23
|
|
24 struct s4_t {
|
|
25 __extension__ char a : 6;
|
|
26 char b __attribute__ ((aligned (2)));
|
|
27 } __attribute__ ((ms_struct));
|
|
28 struct s4_t s4;
|
|
29
|
|
30 struct s5_t {
|
|
31 __extension__ char a : 6;
|
|
32 char b __attribute__ ((aligned (1)));
|
|
33 } __attribute__ ((ms_struct));
|
|
34 struct s5_t s5;
|
|
35
|
|
36 __extension__
|
|
37 static __PTRDIFF_TYPE__ offs (const void *a, const void *b)
|
|
38 {
|
|
39 return (__PTRDIFF_TYPE__) ((const char*)a - (const char*)b);
|
|
40 }
|
|
41
|
|
42 int main()
|
|
43 {
|
|
44 if (offs (&s1.b, &s1) != 16
|
|
45 || offs (&s2.b, &s2) != 1
|
|
46 || offs (&s3.b, &s3) != 16
|
|
47 || offs (&s4.b, &s4) != 2
|
|
48 || offs (&s5.b, &s5) != 1)
|
|
49 abort ();
|
|
50 return 0;
|
|
51 }
|
|
52
|