commit cf5dc8cb35ae0cd707568c21487729885ca6ec3a
parent c02f1b8828829ed87ac27570243fa287d4526bf4
Author: Armin Weigl <tb46305@gmail.com>
Date: Sat, 10 Apr 2021 13:23:15 +0000
gen_data_item: emit f32 as single
Diffstat:
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/gen.c b/src/gen.c
@@ -2702,9 +2702,12 @@ gen_data_item(struct gen_context *ctx, struct expression *expr,
constl(&item->value, (uint64_t)constant->uval);
break;
case STORAGE_F32:
+ item->type = QD_VALUE;
+ consts(&item->value, (float)constant->fval);
+ break;
case STORAGE_F64:
item->type = QD_VALUE;
- constd(&item->value, constant->fval);
+ constd(&item->value, (double)constant->fval);
break;
case STORAGE_UINTPTR:
case STORAGE_POINTER:
diff --git a/tests/11-globals.ha b/tests/11-globals.ha
@@ -24,6 +24,9 @@ type aenum = enum u64 {
};
const big_value: aenum = aenum::BIG_VALUE;
+const float: f32 = 1234.5678;
+const double: f64 = 1234.5678;
+
fn storage() void = {
assert(len(ar) == 3);
assert(ar[0] == 1 && ar[1] == 2 && ar[2] == 3);
@@ -34,6 +37,8 @@ fn storage() void = {
assert(au.x == 0 && au.y == 0);
assert(a3.coords.x == 0 && a3.coords.y == 0 && a3.z == 0);
assert(big_value == 0x1234567887654321);
+ assert(float == 1234.5678);
+ assert(double == 1234.5678);
};
fn invariants() void = {