view gcc/testsuite/gcc.dg/bf-ms-layout-4.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children
line wrap: on
line source

/* 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);