X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=entity.c;h=3a2db26d6598aa6938c675d8e7bc5f50b03492ab;hb=778f63bfc216c257ae8194288f77a41f049a3638;hp=23fab8be4c3d57cfa787299c88c8b87e2329aa66;hpb=5767f9baa625accccefc9f403810cba51d6e943a;p=cparser diff --git a/entity.c b/entity.c index 23fab8b..3a2db26 100644 --- a/entity.c +++ b/entity.c @@ -57,7 +57,7 @@ static size_t get_entity_struct_size(entity_kind_t kind) { static const size_t sizes[] = { [ENTITY_VARIABLE] = sizeof(variable_t), - [ENTITY_PARAMETER] = sizeof(parameter_t), + [ENTITY_PARAMETER] = sizeof(variable_t), [ENTITY_COMPOUND_MEMBER] = sizeof(compound_member_t), [ENTITY_FUNCTION] = sizeof(function_t), [ENTITY_TYPEDEF] = sizeof(typedef_t), @@ -80,13 +80,14 @@ static size_t get_entity_struct_size(entity_kind_t kind) * * @param kind the kind of the entity to allocate */ -entity_t *allocate_entity_zero(entity_kind_t const kind, entity_namespace_t const namespc, symbol_t *const symbol) +entity_t *allocate_entity_zero(entity_kind_t const kind, entity_namespace_t const namespc, symbol_t *const symbol, source_position_t const *const pos) { - size_t size = get_entity_struct_size(kind); - entity_t *entity = allocate_ast_zero(size); - entity->kind = kind; - entity->base.namespc = namespc; - entity->base.symbol = symbol; + size_t const size = get_entity_struct_size(kind); + entity_t *const entity = allocate_ast_zero(size); + entity->kind = kind; + entity->base.namespc = namespc; + entity->base.symbol = symbol; + entity->base.source_position = *pos; return entity; } @@ -104,3 +105,13 @@ elf_visibility_tag_t get_elf_visibility_from_string(const char *string) return ELF_VISIBILITY_ERROR; } } + +entity_t *skip_unnamed_bitfields(entity_t *entry) +{ + for (; entry != NULL; entry = entry->base.next) { + assert(entry->kind == ENTITY_COMPOUND_MEMBER); + if (!entry->compound_member.bitfield || entry->base.symbol != NULL) + break; + } + return entry; +}