ImportC: implement bitfields for StructLiteralExpression

This commit is contained in:
Walter Bright 2021-08-20 02:27:04 -07:00 committed by The Dlang Bot
parent 1f4133bc62
commit 61103da39c
3 changed files with 85 additions and 5 deletions

View file

@ -8,7 +8,7 @@ struct S
_Static_assert(sizeof(struct S) == 4, "in");
int main()
void test1()
{
struct S s;
s.a = 3;
@ -24,6 +24,44 @@ int main()
printf("error %d\n", s.b);
exit(1);
}
}
/******************************************/
struct S2
{
unsigned a:2, b:4;
};
struct S2 foo()
{
struct S2 s = { 7, 8 }; // test struct literal expressions
return s;
}
void test2()
{
struct S2 s = foo();
if (s.a != 3)
{
printf("error %d\n", s.a);
exit(1);
}
if (s.b != 8)
{
printf("error %d\n", s.b);
exit(1);
}
}
/******************************************/
int main()
{
test1();
test2();
return 0;
}