see the testcase. For the signed case this problably does the wrong thing, and it should break other archs. Rework once there are testcases for this.
Unified · Split
| @@ -2867,12 +2867,15 @@ static void gen_cast(CType *type) · 2866 unmodified lines | |||
| 2867 | lexpand(); | 2867 | lexpand(); |
| 2868 | vpop(); | 2868 | vpop(); |
| 2869 | #else | 2869 | #else |
| 2870 | /* XXX some architectures (e.g. risc-v) would like it | 2870 | if (dbt & VT_UNSIGNED) { |
| 2871 | better for this merely being a 32-to-64 sign or zero- | 2871 | /* XXX some architectures (e.g. risc-v) would like it |
| 2872 | extension. */ | 2872 | better for this merely being a 32-to-64 sign or zero- |
| 2873 | vpushi(0xffffffff); | 2873 | extension. */ |
| 2874 | vtop->type.t |= VT_UNSIGNED; | 2874 | vpushi(0xffffffff); |
| 2875 | gen_op('&'); | 2875 | vtop->type.t |= VT_UNSIGNED; |
| 2876 | gen_op('&'); | ||
| 2877 | } else { | ||
| 2878 | } | ||
| 2876 | #endif | 2879 | #endif |
| 2877 | } | 2880 | } |
| 2878 | /* if lvalue and single word type, nothing to do because | 2881 | /* if lvalue and single word type, nothing to do because |
| @@ -5253,7 +5256,7 @@ ST_FUNC void unary(void) · 2374 unmodified lines | |||
| 5253 | vtop->c.f = -1.0 * 0.0; | 5256 | vtop->c.f = -1.0 * 0.0; |
| 5254 | else if (t == VT_DOUBLE) | 5257 | else if (t == VT_DOUBLE) |
| 5255 | vtop->c.d = -1.0 * 0.0; | 5258 | vtop->c.d = -1.0 * 0.0; |
| 5256 | else | 5259 | else |
| 5257 | vtop->c.ld = -1.0 * 0.0; | 5260 | vtop->c.ld = -1.0 * 0.0; |
| 5258 | } else | 5261 | } else |
| 5259 | vpushi(0); | 5262 | vpushi(0); |
| @@ -1633,6 +1633,7 @@ void cast_test() · 1632 unmodified lines | |||
| 1633 | unsigned b,d; | 1633 | unsigned b,d; |
| 1634 | short s; | 1634 | short s; |
| 1635 | char *p = NULL; | 1635 | char *p = NULL; |
| 1636 | unsigned long ul = 0x80000000UL; | ||
| 1636 | p -= 0x700000000042; | 1637 | p -= 0x700000000042; |
| 1637 | 1638 | ||
| 1638 | printf("cast_test:\n"); | 1639 | printf("cast_test:\n"); |
| @@ -1685,6 +1686,9 @@ void cast_test() · 46 unmodified lines | |||
| 1685 | /* from integers to pointers */ | 1686 | /* from integers to pointers */ |
| 1686 | printf("%p %p %p %p\n", | 1687 | printf("%p %p %p %p\n", |
| 1687 | (void *)a, (void *)b, (void *)c, (void *)d); | 1688 | (void *)a, (void *)b, (void *)c, (void *)d); |
| 1689 | |||
| 1690 | /* int to int with sign set */ | ||
| 1691 | printf("0x%lx\n", (unsigned long)(int)ul); | ||
| 1688 | } | 1692 | } |
| 1689 | 1693 | ||
| 1690 | /* initializers tests */ | 1694 | /* initializers tests */ |