Add type promotion in comma expression and update testcase 94
This commit is contained in:
parent
6379f2ee76
commit
c13bbb5cb5
3 changed files with 16 additions and 3 deletions
9
tccgen.c
9
tccgen.c
|
@ -5876,9 +5876,7 @@ ST_FUNC void unary(void)
|
|||
next();
|
||||
skip('(');
|
||||
expr_type(&controlling_type, expr_eq);
|
||||
controlling_type.t &= ~(VT_CONSTANT | VT_VOLATILE | VT_ARRAY);
|
||||
if ((controlling_type.t & VT_BTYPE) == VT_FUNC)
|
||||
mk_pointer(&controlling_type);
|
||||
convert_parameter_type (&controlling_type);
|
||||
|
||||
nocode_wanted = saved_nocode_wanted;
|
||||
|
||||
|
@ -6547,12 +6545,17 @@ static void expr_eq(void)
|
|||
|
||||
ST_FUNC void gexpr(void)
|
||||
{
|
||||
int comma_found = 0;
|
||||
|
||||
while (1) {
|
||||
expr_eq();
|
||||
if (comma_found)
|
||||
convert_parameter_type (&vtop->type);
|
||||
if (tok != ',')
|
||||
break;
|
||||
constant_p &= (vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST &&
|
||||
!((vtop->r & VT_SYM) && vtop->sym->a.addrtaken);
|
||||
comma_found = 1;
|
||||
vpop();
|
||||
next();
|
||||
}
|
||||
|
|
|
@ -30,6 +30,12 @@ void void_foo(int i) {}
|
|||
|
||||
typedef int int_type1;
|
||||
|
||||
typedef int T[4];
|
||||
int f(T t)
|
||||
{
|
||||
return _Generic(t, __typeof__( ((void)0, (T){0}) ) : 1 );
|
||||
}
|
||||
|
||||
#define gen_sw(a) _Generic(a, const char *: 1, default: 8, int: 123);
|
||||
|
||||
int main()
|
||||
|
@ -40,6 +46,7 @@ int main()
|
|||
const int * const ptr;
|
||||
const char *ti;
|
||||
int_type1 i2;
|
||||
T t;
|
||||
|
||||
i = _Generic(a, int: a_f, const int: b_f)();
|
||||
printf("%d\n", i);
|
||||
|
@ -118,5 +125,7 @@ int main()
|
|||
(void)(sizeof(struct { int x:_Generic( 0?(int (*)[5])0 : ar, int (*)[5]:+1, int (*)[4]:(void)0); }));
|
||||
}
|
||||
|
||||
printf ("%d\n", f(t));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -13,3 +13,4 @@ long
|
|||
1
|
||||
3
|
||||
5
|
||||
1
|
||||
|
|
Loading…
Reference in a new issue