diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-06-17 17:31:50 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-06-17 17:31:50 -0400 |
| commit | 1621968fc82f17708c1d5b6f5bd65ba2244269a3 (patch) | |
| tree | b8bb5aec14747e9f24a3c62c25a6a54addc2eb77 /structs.c | |
| parent | eb2a9027b0eb0ebb8e94e9ce3ed8571881bfdac6 (diff) | |
Fix issue with bitfields
Diffstat (limited to 'structs.c')
| -rw-r--r-- | structs.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -102,7 +102,10 @@ static CORD compile_hash_method(env_t *env, ast_t *ast) "uint32_t field_hashes[] = {"); for (arg_ast_t *field = def->fields; field; field = field->next) { type_t *field_type = get_arg_ast_type(env, field); - hash_func = CORD_all(hash_func, "\ngeneric_hash(&obj->", field->name, ", ", compile_type_info(env, field_type), "),"); + if (field_type->tag == BoolType) // Bools can be bit fields, so you can't use *obj->field there: + hash_func = CORD_all(hash_func, "\n(uint32_t)(obj->", field->name, "),"); + else + hash_func = CORD_all(hash_func, "\ngeneric_hash(&obj->", field->name, ", ", compile_type_info(env, field_type), "),"); } hash_func = CORD_all(hash_func, "};\n" "uint32_t hash;\n" |
