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
5627 if(!compare_types(pointed_type(&type1), pointed_type(&type2),1/*unqualif*/))5627 if(!compare_types(pointed_type(&type1), pointed_type(&type2),1/*unqualif*/))
5628 tcc_warning("pointer type mismatch in conditional expression\n");5628 tcc_warning("pointer type mismatch in conditional expression\n");
5629 }5629 }
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 }
5630 /*qualifs combine*/5636 /*qualifs combine*/
5631 pointed_type(&type)->t |= 05637 pointed_type(&type)->t |= 0
5632 |(pointed_type(&type1)->t&(VT_CONSTANT|VT_VOLATILE))5638 |(pointed_type(&type1)->t&(VT_CONSTANT|VT_VOLATILE))
tests/tests2/94_generic.c+7−0
@@ -95,5 +95,12 @@ int main() · 94 unmodified lines
95 (void)(sizeof(struct { int x:_Generic( 0?(int (*)[4])0 : (int (*)[])0, int (*)[4]:+1, int (*)[5]:(void)0); }));95 (void)(sizeof(struct { int x:_Generic( 0?(int (*)[4])0 : (int (*)[])0, int (*)[4]:+1, int (*)[5]:(void)0); }));
96 (void)(sizeof(struct { int x:_Generic( 0?(int (*)[])0 : (int (*)[4])0, int (*)[4]:+1, int (*)[5]:(void)0); }));96 (void)(sizeof(struct { int x:_Generic( 0?(int (*)[])0 : (int (*)[4])0, int (*)[4]:+1, int (*)[5]:(void)0); }));
97 97
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
98 return 0;105 return 0;
99}106}

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