mirror of
https://github.com/dlang/dmd.git
synced 2025-04-28 06:00:13 +03:00
ImportC: implement bitfields for StructLiteralExpression
This commit is contained in:
parent
1f4133bc62
commit
61103da39c
3 changed files with 85 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue