fix Issue 24026 - ImportC: ICE on nested C initializer 2 (#15375)

This commit is contained in:
Walter Bright 2023-07-05 12:19:09 -07:00 committed by GitHub
parent 11d8f17c0f
commit 78dc82bca2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 9 deletions

View file

@ -0,0 +1,66 @@
// https://issues.dlang.org/show_bug.cgi?id=23768
typedef struct {
union {
struct {
int o;
} f;
};
} T;
void f(void) {
T data = (T) {
{.f = {.o = 0}}
};
}
/***************/
typedef struct {
union {
struct {
struct { double o; } f;
};
};
} S;
_Static_assert(sizeof(S) == 8, "1");
void test23768()
{
S data = (S) {
{{.f = {.o = 3}}}
};
__check(data.f.o == 3);
S s;
s.f.o = 4;
__check(s.f.o == 4);
}
/**************************/
// https://issues.dlang.org/show_bug.cgi?id=24026
struct A
{
int type;
};
struct E
{
struct A action;
};
void test24026()
{
struct E entry = {{ .type = 1 }};
__check(entry.action.type == 1);
}
/**************************/
int main()
{
test23768();
test24026();
return 0;
}