layout_struct_type(&type->compound);
return type->compound.compound->size;
case TYPE_FUNCTION:
- return 0; /* non-const (but "address-const") */
+ return 1; /* strange GNU extensions: sizeof(function) == 1 */
case TYPE_REFERENCE:
case TYPE_POINTER:
return pointer_properties.size;
return;
if (type->compound->layouted)
return;
+ compound->layouted = true;
il_size_t offset = 0;
il_alignment_t alignment = compound->alignment;
entity_t *entry = compound->members.entities;
while (entry != NULL) {
- if (entry->kind != ENTITY_COMPOUND_MEMBER) {
- entry = entry->base.next;
- continue;
- }
+ if (entry->kind != ENTITY_COMPOUND_MEMBER)
+ goto next;
- type_t *const m_type = skip_typeref(entry->declaration.type);
- if (!is_type_valid(m_type)) {
- entry = entry->base.next;
- continue;
- }
+ type_t *const m_type = skip_typeref(entry->declaration.type);
+ if (!is_type_valid(m_type))
+ goto next;
if (entry->compound_member.bitfield) {
entry = pack_bitfield_members(&offset, &alignment,
entry->compound_member.offset = offset;
offset += get_type_size(m_type);
+next:
entry = entry->base.next;
}
compound->size = offset;
compound->alignment = alignment;
- compound->layouted = true;
}
void layout_union_type(compound_type_t *type)
compound_t *compound = type->compound;
if (! compound->complete)
return;
+ if (compound->layouted)
+ return;
+ compound->layouted = true;
il_size_t size = 0;
il_alignment_t alignment = compound->alignment;