harec

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

commit 6ede8265f3bd9e9b87d569586bcfddce931886d5
parent 88420fa6655d4d5d31949dec435791fb51d94063
Author: Bor Grošelj Simić <bor.groseljsimic@telemach.net>
Date:   Mon, 27 Dec 2021 04:16:35 +0100

struct_insert_field: simplify explicit offset computation

Signed-off-by: Bor Grošelj Simić <bor.groseljsimic@telemach.net>

Diffstat:
Msrc/type_store.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/type_store.c b/src/type_store.c @@ -178,6 +178,7 @@ struct_insert_field(struct type_store *store, struct struct_field **fields, *ccompat = false; struct expression in, out; check_expression(store->check_context, atype->offset, &in, NULL); + field->offset = 0; enum eval_result r = eval_expr(store->check_context, &in, &out); if (r != EVAL_OK) { error(store->check_context, in.loc, @@ -189,8 +190,7 @@ struct_insert_field(struct type_store *store, struct struct_field **fields, error(store->check_context, in.loc, "Field offset must not be less than 0"); } else { - size_t offs = (size_t)out.constant.uval; - field->offset = offs; + field->offset = (size_t)out.constant.uval; } } else { size_t offs = *size;