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
40584058 gen_cast(&type);
40594059 } else if (vtop->type.t & VT_BITFIELD) {
40604060 type.t = vtop->type.t & (VT_BTYPE | VT_UNSIGNED);
4061+ type.ref = vtop->type.ref;
40614062 gen_cast(&type);
40624063 }
40634064 } else if (arg == NULL) {
tests/tcctest.c+5−0
@@ -602,11 +602,16 @@ enum test { · 601 unmodified lines
602602 E5 = 1000,
603603 };
604604
605+struct S_enum {
606+ enum {E6 = 42, E7, E8} e:8;
607+};
605608 void enum_test()
606609 {
607610 enum test b1;
608611 /* The following should give no warning */
609612 unsigned *p = &b1;
613+ struct S_enum s = {E7};
614+ printf("enum: %d\n", s.e);
610615 printf("enum:\n%d %d %d %d %d %d\n",
611616 E0, E1, E2, E3, E4, E5);
612617 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