This was causing assembler bugs in a tcc compiled by itself at i386-asm.c:352 when ExprValue.v was changed to uint64_t: if (op->e.v == (int8_t)op->e.v) op->type |= OP_IM8S; A general test case: #include <stdio.h> int main(int argc, char **argv) { long long ll = 4000; int i = (char)ll; printf("%d\n", i); return 0; } Output was "4000", now "-96".
Unified · Split
| @@ -1948,7 +1948,10 @@ static void force_charshort_cast(int t) · 1947 unmodified lines | ||
| 1948 | 1948 | vpushi((1 << bits) - 1); |
| 1949 | 1949 | gen_op('&'); |
| 1950 | 1950 | } else { |
| 1951 | − bits = 32 - bits; | |
| 1951 | + if ((vtop->type.t & VT_BTYPE) == VT_LLONG) | |
| 1952 | + bits = 64 - bits; | |
| 1953 | + else | |
| 1954 | + bits = 32 - bits; | |
| 1952 | 1955 | vpushi(bits); |
| 1953 | 1956 | gen_op(TOK_SHL); |
| 1954 | 1957 | /* result must be signed or the SAR is converted to an SHL |
| @@ -21,7 +21,7 @@ TESTS = \ · 20 unmodified lines | ||
| 21 | 21 | BTESTS = test1b test3b btest |
| 22 | 22 | |
| 23 | 23 | # test4 -- problem with -static |
| 24 | −# asmtest -- minor differences with gcc | |
| 24 | +# asmtest / asmtest2 -- minor differences with gcc | |
| 25 | 25 | # btest -- works on i386 (including win32) |
| 26 | 26 | |
| 27 | 27 | # bounds-checking is supported only on i386 |
| @@ -173,12 +173,15 @@ asmtest.ref: asmtest.S · 145 unmodified lines | ||
| 173 | 173 | $(CC) -Wa,-W -o asmtest.ref.o -c asmtest.S |
| 174 | 174 | objdump -D asmtest.ref.o > asmtest.ref |
| 175 | 175 | |
| 176 | −asmtest: asmtest.ref | |
| 176 | +asmtest asmtest2: asmtest.ref | |
| 177 | 177 | @echo ------------ $@ ------------ |
| 178 | − $(TCC) -c asmtest.S | |
| 178 | + $(TCC) $(MAYBE_RUN_TCC) -c asmtest.S | |
| 179 | 179 | objdump -D asmtest.o > asmtest.out |
| 180 | 180 | @if diff -u --ignore-matching-lines="file format" asmtest.ref asmtest.out ; then echo "ASM Auto Test OK"; fi |
| 181 | 181 | |
| 182 | +# test assembler with tcc compiled by itself | |
| 183 | +asmtest2: MAYBE_RUN_TCC = $(RUN_TCC) | |
| 184 | + | |
| 182 | 185 | # Check that code generated by libtcc is binary compatible with |
| 183 | 186 | # that generated by CC |
| 184 | 187 | abitest-cc$(EXESUF): abitest.c $(LIBTCC) |
| @@ -696,6 +696,7 @@ int $0x10 · 695 unmodified lines | ||
| 696 | 696 | inc %eax |
| 697 | 697 | #endif |
| 698 | 698 | |
| 699 | +#ifndef _WIN32 | |
| 699 | 700 | ft1: ft2: ft3: ft4: ft5: ft6: ft7: ft8: ft9: |
| 700 | 701 | xor %eax, %eax |
| 701 | 702 | ret |
| @@ -708,6 +709,7 @@ ft1: ft2: ft3: ft4: ft5: ft6: ft7: ft8: ft9: · 6 unmodified lines | ||
| 708 | 709 | .type ft6,@function |
| 709 | 710 | .type ft7,%function |
| 710 | 711 | .type ft8,"function" |
| 712 | +#endif | |
| 711 | 713 | |
| 712 | 714 | pause |
| 713 | 715 | .rept 6 |