- 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.
Unified · Split
| @@ -6219,6 +6219,11 @@ static void gen_cast(CType *type) · 6218 unmodified lines | ||
| 6219 | 6219 | vpushi(0); |
| 6220 | 6220 | gv(RC_INT); |
| 6221 | 6221 | } else { |
| 6222 | + if (sbt == VT_PTR) { | |
| 6223 | + /* cast from pointer to int before we apply | |
| 6224 | + shift operation, which pointers don't support*/ | |
| 6225 | + gen_cast(&int_type); | |
| 6226 | + } | |
| 6222 | 6227 | gv_dup(); |
| 6223 | 6228 | vpushi(31); |
| 6224 | 6229 | gen_op(TOK_SAR); |
| @@ -1154,9 +1154,7 @@ void cast_test() · 1153 unmodified lines | ||
| 1154 | 1154 | printf("sizeof(~(char)'a') = %d\n", sizeof(-(char)'a')); |
| 1155 | 1155 | |
| 1156 | 1156 | /* from pointer to integer types */ |
| 1157 | − printf("%d %d %d %d %d %d %ld %ld %lld %lld\n", | |
| 1158 | − (char)p, (unsigned char)p, | |
| 1159 | − (short)p, (unsigned short)p, | |
| 1157 | + printf("%d %d %ld %ld %lld %lld\n", | |
| 1160 | 1158 | (int)p, (unsigned int)p, |
| 1161 | 1159 | (long)p, (unsigned long)p, |
| 1162 | 1160 | (long long)p, (unsigned long long)p); |