summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/bf-ms-layout-4.c
blob: 821db075a9a8f8ad6ee941bb2b2716292cf5d7bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* PR target/52991 */
/* { dg-do compile { target i?86-*-* x86_64-*-* } } */

#define CHECK(expr) extern char c[(expr) ? 1 : -1]
#define offsetof(x, y) __builtin_offsetof (x, y)

struct test_sp1 {
    int a;
    short b;
    int c;
    char d;
} __attribute__((packed,ms_struct));

CHECK (sizeof (struct test_sp1) == 11);
CHECK (offsetof (struct test_sp1, a) == 0);
CHECK (offsetof (struct test_sp1, b) == 4);
CHECK (offsetof (struct test_sp1, c) == 6);
CHECK (offsetof (struct test_sp1, d) == 10);

struct test_sp3 {
    int a;
    short b __attribute__((aligned(8)));
    int c;
    char d;
} __attribute__((packed,ms_struct));

CHECK (sizeof (struct test_sp3) == 16);
CHECK (offsetof (struct test_sp3, a) == 0);
CHECK (offsetof (struct test_sp3, b) == 8);
CHECK (offsetof (struct test_sp3, c) == 10);
CHECK (offsetof (struct test_sp3, d) == 14);

struct test_s4 {
    int a;
    short b;
    int c:15;
    char d;
} __attribute__((ms_struct));

CHECK (sizeof (struct test_s4) == 16);
CHECK (offsetof (struct test_s4, a) == 0);
CHECK (offsetof (struct test_s4, b) == 4);
CHECK (offsetof (struct test_s4, d) == 12);