tccgen.c: - gen_cast: add check for char to ushort cast tests/bug.c: - remove tst1 tests/tests2/117_gcc_test.c: - add tst_cast
Unified · Split
| @@ -3573,6 +3573,11 @@ again: · 3572 unmodified lines | |||
| 3573 | /* ss <= 4 here */ | 3573 | /* ss <= 4 here */ |
| 3574 | if (ds <= 4) { | 3574 | if (ds <= 4) { |
| 3575 | gv(RC_INT); | 3575 | gv(RC_INT); |
| 3576 | if (ds == 2 && (dbt & VT_UNSIGNED) && | ||
| 3577 | ss == 1 && (sbt & VT_UNSIGNED) == 0) { | ||
| 3578 | vpushi(0xffff); | ||
| 3579 | gen_op('&'); | ||
| 3580 | } | ||
| 3576 | goto done; /* no 64bit envolved */ | 3581 | goto done; /* no 64bit envolved */ |
| 3577 | } | 3582 | } |
| 3578 | } | 3583 | } |
| @@ -1,14 +1,6 @@ | |||
| 1 | #include <stdio.h> | 1 | #include <stdio.h> |
| 2 | #include <stdarg.h> | 2 | #include <stdarg.h> |
| 3 | 3 | ||
| 4 | void tst1(void) | ||
| 5 | { | ||
| 6 | /* problem in gen_cast. Should mask unsigned types */ | ||
| 7 | signed char c = (signed char) 0xffffffff; | ||
| 8 | int r = (unsigned short) c ^ (signed char) 0x99999999; | ||
| 9 | if (r != 0xffff0066) printf ("%x\n", r); | ||
| 10 | } | ||
| 11 | |||
| 12 | typedef struct{double x,y;}p; | 4 | typedef struct{double x,y;}p; |
| 13 | 5 | ||
| 14 | void tst2(int n,...) | 6 | void tst2(int n,...) |
| @@ -69,7 +61,6 @@ int · 54 unmodified lines | |||
| 69 | main(void) | 61 | main(void) |
| 70 | { | 62 | { |
| 71 | p v = { 1, 2}; | 63 | p v = { 1, 2}; |
| 72 | tst1(); | ||
| 73 | tst2(1, v); | 64 | tst2(1, v); |
| 74 | tst3(); | 65 | tst3(); |
| 75 | } | 66 | } |
| @@ -139,6 +139,13 @@ void tst_pack (void) · 138 unmodified lines | |||
| 139 | if (j.f != i.f) printf("error\n"); | 139 | if (j.f != i.f) printf("error\n"); |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | void tst_cast(void) | ||
| 143 | { | ||
| 144 | signed char c = (signed char) 0xaaaaaaaa; | ||
| 145 | int r = (unsigned short) c ^ (signed char) 0x99999999; | ||
| 146 | if (r != 0xffff0033) printf ("%x\n", r); | ||
| 147 | } | ||
| 148 | |||
| 142 | int | 149 | int |
| 143 | main (void) | 150 | main (void) |
| 144 | { | 151 | { |
| @@ -155,4 +162,5 @@ main (void) · 10 unmodified lines | |||
| 155 | tst_builtin(); | 162 | tst_builtin(); |
| 156 | tst_compare(); | 163 | tst_compare(); |
| 157 | tst_pack(); | 164 | tst_pack(); |
| 165 | tst_cast(); | ||
| 158 | } | 166 | } |