dmd/compiler/test/compilable/imports/imp18127b.c
drpriver 8a8746f318
Fix 18127 - ImportC: redeclaration of struct in different translation unit doesn’t check compatibility (#21224)
Fixes: https://github.com/dlang/dmd/issues/18127

When merging struct definitions from different C imports, check that the
structs are actually compatible according to the C rules. If they are
not, issue an error.
2025-04-14 14:35:20 +08:00

74 lines
951 B
C

// https://github.com/dlang/dmd/issues/18127
union struct_or_union {
int x;
};
struct S_n_fields {
int x, y;
};
struct S_types {
float x;
};
struct S_names {
float x;
};
struct B {
int x;
};
struct S_b {
struct B b;
};
struct S_contains_anon_named {
struct {
int x;
} a;
};
struct S_contains_anon_unnamed {
struct {
int x;
};
};
struct S_bitfields_mismatch1 {
unsigned x: 3;
unsigned y: 1;
};
struct S_bitfields_mismatch2 {
unsigned x;
unsigned y: 1;
};
struct S_bitfields_widths {
unsigned x: 3;
unsigned y: 1;
};
struct S_bitfields_anon {
unsigned x: 3;
unsigned : 1;
};
struct S_alignas {
_Alignas(8) float x;
};
struct S_aligned {
float x;
}__attribute__((aligned(8)));
struct __attribute__((packed)) S_pack_1 {
float x;
char c;
};
#pragma pack(push)
#pragma pack(1)
struct S_pack_2 {
float x;
char c;
};
#pragma pack(pop)