History

Fix the fix on type combining (e0012c2)

char **argv; _Generic(argv, char**: (void)0); _Generic(0?(char const*)0:argv[0], char const*: (void)0); _Generic(argv, char**: (void)0); would fail because the type of argv would get modified by the ternary. Now allocate a separate type on the value stack to prevent this error.

Petr Skocik committed 7 years ago

Commit 9d44b021 parent e0012c22 files · +13 −0Browse files

Unified · Split

2 files
  1. tccgen.c +6 −0
  2. tests/tests2/94_generic.c +7 −0
tccgen.c+6−0
@@ -5627,6 +5627,12 @@ static void expr_cond(void) · 5626 unmodified lines
56275627 if(!compare_types(pointed_type(&type1), pointed_type(&type2),1/*unqualif*/))
56285628 tcc_warning("pointer type mismatch in conditional expression\n");
56295629 }
5630+ { /*copy the pointer target symbol*/
5631+ Sym *s;
5632+ s = sym_push(SYM_FIELD, pointed_type(&type), 0, -1);
5633+ type.t = VT_PTR | (type.t & VT_STORAGE);
5634+ type.ref = s;
5635+ }
56305636 /*qualifs combine*/
56315637 pointed_type(&type)->t |= 0
56325638 |(pointed_type(&type1)->t&(VT_CONSTANT|VT_VOLATILE))
tests/tests2/94_generic.c+7−0
@@ -95,5 +95,12 @@ int main() · 94 unmodified lines
9595 (void)(sizeof(struct { int x:_Generic( 0?(int (*)[4])0 : (int (*)[])0, int (*)[4]:+1, int (*)[5]:(void)0); }));
9696 (void)(sizeof(struct { int x:_Generic( 0?(int (*)[])0 : (int (*)[4])0, int (*)[4]:+1, int (*)[5]:(void)0); }));
9797
98+ {
99+ char **argv;
100+ _Generic(argv, char**: (void)0);
101+ _Generic(0?(char const*)0:argv[0], char const*: (void)0);
102+ _Generic(argv, char**: (void)0);
103+ }
104+
98105 return 0;
99106 }

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