type_t *unqualified_type = duplicate_type(type);
unqualified_type->base.qualifiers = TYPE_QUALIFIER_NONE;
- type_t *result = typehash_insert(unqualified_type);
- if (result != unqualified_type) {
- obstack_free(type_obst, unqualified_type);
- }
-
- return result;
+ return identify_new_type(unqualified_type);
}
type_t *get_qualified_type(type_t *orig_type, type_qualifiers_t const qual)
return type;
}
- type = typehash_insert(copy);
- if (type != copy)
- obstack_free(type_obst, copy);
-
- return type;
+ return identify_new_type(copy);
}
/**
{
type_qualifiers_t qualifiers = TYPE_QUALIFIER_NONE;
type_modifiers_t modifiers = TYPE_MODIFIER_NONE;
- unsigned char alignment = 0;
+ il_alignment_t alignment = 0;
while (true) {
+ if (alignment < type->base.alignment)
+ alignment = type->base.alignment;
+
switch (type->kind) {
case TYPE_ERROR:
return type;
case TYPE_TYPEDEF: {
qualifiers |= type->base.qualifiers;
modifiers |= type->base.modifiers;
- if (type->base.alignment > alignment)
- alignment = type->base.alignment;
const typedef_type_t *typedef_type = &type->typedeft;
if (typedef_type->resolved_type != NULL) {
case TYPE_TYPEOF: {
qualifiers |= type->base.qualifiers;
modifiers |= type->base.modifiers;
- if (type->base.alignment > alignment)
- alignment = type->base.alignment;
const typeof_type_t *typeof_type = &type->typeoft;
if (typeof_type->typeof_type != NULL) {
break;
}
- if (qualifiers != TYPE_QUALIFIER_NONE || modifiers != TYPE_MODIFIER_NONE
- || (alignment != 0 && alignment > type->base.alignment)) {
+ if (qualifiers != TYPE_QUALIFIER_NONE ||
+ modifiers != TYPE_MODIFIER_NONE ||
+ alignment > type->base.alignment) {
type_t *const copy = duplicate_type(type);
/* for const with typedefed array type the element type has to be
copy->base.alignment = alignment;
}
- type = typehash_insert(copy);
- if (type != copy) {
- obstack_free(type_obst, copy);
- }
+ type = identify_new_type(copy);
}
return type;
* Hash the given type and return the "singleton" version
* of it.
*/
-static type_t *identify_new_type(type_t *type)
+type_t *identify_new_type(type_t *type)
{
type_t *result = typehash_insert(type);
if (result != type) {