Fixes for issues I've just found/introduced to x86 TCC.
- Cast from pointer to long long makes TCC output an error. Use cast to int before we apply shift operation for a pointer value. - Removed test cases for casts from pointer to char/short because they produce warning.
This commit is contained in:
committed by
grischka
parent
be43c8e0ed
commit
83fd36333a
5
tcc.c
5
tcc.c
@ -6219,6 +6219,11 @@ static void gen_cast(CType *type)
|
|||||||
vpushi(0);
|
vpushi(0);
|
||||||
gv(RC_INT);
|
gv(RC_INT);
|
||||||
} else {
|
} else {
|
||||||
|
if (sbt == VT_PTR) {
|
||||||
|
/* cast from pointer to int before we apply
|
||||||
|
shift operation, which pointers don't support*/
|
||||||
|
gen_cast(&int_type);
|
||||||
|
}
|
||||||
gv_dup();
|
gv_dup();
|
||||||
vpushi(31);
|
vpushi(31);
|
||||||
gen_op(TOK_SAR);
|
gen_op(TOK_SAR);
|
||||||
|
|||||||
@ -1154,9 +1154,7 @@ void cast_test()
|
|||||||
printf("sizeof(~(char)'a') = %d\n", sizeof(-(char)'a'));
|
printf("sizeof(~(char)'a') = %d\n", sizeof(-(char)'a'));
|
||||||
|
|
||||||
/* from pointer to integer types */
|
/* from pointer to integer types */
|
||||||
printf("%d %d %d %d %d %d %ld %ld %lld %lld\n",
|
printf("%d %d %ld %ld %lld %lld\n",
|
||||||
(char)p, (unsigned char)p,
|
|
||||||
(short)p, (unsigned short)p,
|
|
||||||
(int)p, (unsigned int)p,
|
(int)p, (unsigned int)p,
|
||||||
(long)p, (unsigned long)p,
|
(long)p, (unsigned long)p,
|
||||||
(long long)p, (unsigned long long)p);
|
(long long)p, (unsigned long long)p);
|
||||||
|
|||||||
Reference in New Issue
Block a user