Fix enum bitfields passed to stdarg functions
VT_ENUM types use the .ref member and can be VT_BITFIELD, so we need to copy it as well. Simply do it always.
This commit is contained in:
1
tccgen.c
1
tccgen.c
@ -4058,6 +4058,7 @@ static void gfunc_param_typed(Sym *func, Sym *arg)
|
|||||||
gen_cast(&type);
|
gen_cast(&type);
|
||||||
} else if (vtop->type.t & VT_BITFIELD) {
|
} else if (vtop->type.t & VT_BITFIELD) {
|
||||||
type.t = vtop->type.t & (VT_BTYPE | VT_UNSIGNED);
|
type.t = vtop->type.t & (VT_BTYPE | VT_UNSIGNED);
|
||||||
|
type.ref = vtop->type.ref;
|
||||||
gen_cast(&type);
|
gen_cast(&type);
|
||||||
}
|
}
|
||||||
} else if (arg == NULL) {
|
} else if (arg == NULL) {
|
||||||
|
|||||||
@ -602,11 +602,16 @@ enum test {
|
|||||||
E5 = 1000,
|
E5 = 1000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct S_enum {
|
||||||
|
enum {E6 = 42, E7, E8} e:8;
|
||||||
|
};
|
||||||
void enum_test()
|
void enum_test()
|
||||||
{
|
{
|
||||||
enum test b1;
|
enum test b1;
|
||||||
/* The following should give no warning */
|
/* The following should give no warning */
|
||||||
unsigned *p = &b1;
|
unsigned *p = &b1;
|
||||||
|
struct S_enum s = {E7};
|
||||||
|
printf("enum: %d\n", s.e);
|
||||||
printf("enum:\n%d %d %d %d %d %d\n",
|
printf("enum:\n%d %d %d %d %d %d\n",
|
||||||
E0, E1, E2, E3, E4, E5);
|
E0, E1, E2, E3, E4, E5);
|
||||||
b1 = 1;
|
b1 = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user