harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit c6f5c36c86be02ae142ad0a26025e91c1894cd57
parent bcda13af5a8a3f4664d5a5ff8e49efaff949634f
Author: Armin Weigl <tb46305@gmail.com>
Date:   Fri,  9 Apr 2021 18:28:24 +0000

gen_data_item: do not truncate 64 bit enum members

Diffstat:
Msrc/gen.c | 2+-
Mtests/11-globals.ha | 6++++++
2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/gen.c b/src/gen.c @@ -2840,7 +2840,7 @@ gen_data_item(struct gen_context *ctx, struct expression *expr, case STORAGE_I64: case STORAGE_SIZE: item->type = QD_VALUE; - constl(&item->value, (uint32_t)constant->uval); + constl(&item->value, (uint64_t)constant->uval); break; default: assert(0); diff --git a/tests/11-globals.ha b/tests/11-globals.ha @@ -19,6 +19,11 @@ let au: coords = coords { ... }; type coords3 = struct { coords: coords, z: int }; let a3: coords3 = coords3 { ... }; +type aenum = enum u64 { + BIG_VALUE = 0x1234567887654321, +}; +const big_value: aenum = aenum::BIG_VALUE; + fn storage() void = { assert(len(ar) == 3); assert(ar[0] == 1 && ar[1] == 2 && ar[2] == 3); @@ -28,6 +33,7 @@ fn storage() void = { assert(su.x == 20 && su.y == 10); assert(au.x == 0 && au.y == 0); assert(a3.coords.x == 0 && a3.coords.y == 0 && a3.z == 0); + assert(big_value == 0x1234567887654321); }; fn invariants() void = {