History

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.

Michael Matz committed 10 years ago

Commit 372f4b61 parent d7208652 files · +6 −0Browse files

Unified · Split

2 files
  1. tccgen.c +1 −0
  2. tests/tcctest.c +5 −0
tccgen.c+1−0
@@ -4058,6 +4058,7 @@ static void gfunc_param_typed(Sym *func, Sym *arg) · 4057 unmodified lines
4058 gen_cast(&type);4058 gen_cast(&type);
4059 } else if (vtop->type.t & VT_BITFIELD) {4059 } else if (vtop->type.t & VT_BITFIELD) {
4060 type.t = vtop->type.t & (VT_BTYPE | VT_UNSIGNED);4060 type.t = vtop->type.t & (VT_BTYPE | VT_UNSIGNED);
4061 type.ref = vtop->type.ref;
4061 gen_cast(&type);4062 gen_cast(&type);
4062 }4063 }
4063 } else if (arg == NULL) {4064 } else if (arg == NULL) {
tests/tcctest.c+5−0
@@ -602,11 +602,16 @@ enum test { · 601 unmodified lines
602 E5 = 1000,602 E5 = 1000,
603};603};
604 604
605struct S_enum {
606 enum {E6 = 42, E7, E8} e:8;
607};
605void enum_test()608void enum_test()
606{609{
607 enum test b1;610 enum test b1;
608 /* The following should give no warning */611 /* The following should give no warning */
609 unsigned *p = &b1;612 unsigned *p = &b1;
613 struct S_enum s = {E7};
614 printf("enum: %d\n", s.e);
610 printf("enum:\n%d %d %d %d %d %d\n",615 printf("enum:\n%d %d %d %d %d %d\n",
611 E0, E1, E2, E3, E4, E5);616 E0, E1, E2, E3, E4, E5);
612 b1 = 1;617 b1 = 1;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t