[qfcc] Preserve requested alignment if larger

build_struct was unconditionally setting the type's alignment. This was
not a problem before because no types were requesting alignments larger
than those requested by their members (for structs). However, with the
upcoming new instruction set, quaternions need to be 4-word aligned.
This commit is contained in:
Bill Currie 2022-01-02 11:42:27 +09:00
parent 5fb28d7c38
commit f56fd6ffb6
2 changed files with 4 additions and 2 deletions

View file

@ -171,7 +171,9 @@ build_struct (int su, symbol_t *tag, symtab_t *symtab, type_t *type)
if (!type)
sym->type = find_type (sym->type); // checks the tag, not the symtab
sym->type->t.symtab = symtab;
sym->type->alignment = alignment;
if (alignment > sym->type->alignment) {
sym->type->alignment = alignment;
}
if (!type && sym->type->type_def->external) //FIXME should not be necessary
sym->type->type_def = qfo_encode_type (sym->type, pr.type_data);
return sym;

View file

@ -74,7 +74,7 @@ type_t type_function = { ev_func, "function", 1, ty_basic,
{{&type_void}} };
type_t type_pointer = { ev_pointer, "pointer", 1, ty_basic,
{{&type_void}} };
type_t type_quaternion = { ev_quat, "quaternion", 1 };
type_t type_quaternion = { ev_quat, "quaternion", 4 };
type_t type_integer = { ev_integer, "int", 1 };
type_t type_uinteger = { ev_uinteger, "uint", 1 };
type_t type_short = { ev_short, "short", 1 };