mirror of
https://github.com/mirror/tinycc.git
synced 2025-02-28 08:10:25 +08:00
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.
This commit is contained in:
parent
e0012c2767
commit
9d44b02a49
6
tccgen.c
6
tccgen.c
@ -5627,6 +5627,12 @@ static void expr_cond(void)
|
||||
if(!compare_types(pointed_type(&type1), pointed_type(&type2),1/*unqualif*/))
|
||||
tcc_warning("pointer type mismatch in conditional expression\n");
|
||||
}
|
||||
{ /*copy the pointer target symbol*/
|
||||
Sym *s;
|
||||
s = sym_push(SYM_FIELD, pointed_type(&type), 0, -1);
|
||||
type.t = VT_PTR | (type.t & VT_STORAGE);
|
||||
type.ref = s;
|
||||
}
|
||||
/*qualifs combine*/
|
||||
pointed_type(&type)->t |= 0
|
||||
|(pointed_type(&type1)->t&(VT_CONSTANT|VT_VOLATILE))
|
||||
|
@ -95,5 +95,12 @@ int main()
|
||||
(void)(sizeof(struct { int x:_Generic( 0?(int (*)[4])0 : (int (*)[])0, int (*)[4]:+1, int (*)[5]:(void)0); }));
|
||||
(void)(sizeof(struct { int x:_Generic( 0?(int (*)[])0 : (int (*)[4])0, int (*)[4]:+1, int (*)[5]:(void)0); }));
|
||||
|
||||
{
|
||||
char **argv;
|
||||
_Generic(argv, char**: (void)0);
|
||||
_Generic(0?(char const*)0:argv[0], char const*: (void)0);
|
||||
_Generic(argv, char**: (void)0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user