Commit 064775c9 authored by Alexandre Julliard's avatar Alexandre Julliard

widl: Struct alignment should be the largest alignment of all the struct members.

parent fc7681a8
...@@ -1083,7 +1083,6 @@ static unsigned int write_conf_or_var_desc(FILE *file, const type_t *structure, ...@@ -1083,7 +1083,6 @@ static unsigned int write_conf_or_var_desc(FILE *file, const type_t *structure,
static unsigned int fields_memsize(const var_list_t *fields, unsigned int *align) static unsigned int fields_memsize(const var_list_t *fields, unsigned int *align)
{ {
int have_align = FALSE;
unsigned int size = 0; unsigned int size = 0;
const var_t *v; const var_t *v;
...@@ -1092,11 +1091,7 @@ static unsigned int fields_memsize(const var_list_t *fields, unsigned int *align ...@@ -1092,11 +1091,7 @@ static unsigned int fields_memsize(const var_list_t *fields, unsigned int *align
{ {
unsigned int falign = 0; unsigned int falign = 0;
unsigned int fsize = type_memsize(v->type, &falign); unsigned int fsize = type_memsize(v->type, &falign);
if (!have_align) if (*align < falign) *align = falign;
{
*align = falign;
have_align = TRUE;
}
size = ROUND_SIZE(size, falign); size = ROUND_SIZE(size, falign);
size += fsize; size += fsize;
} }
...@@ -1128,7 +1123,7 @@ static unsigned int union_memsize(const var_list_t *fields, unsigned int *pmaxa) ...@@ -1128,7 +1123,7 @@ static unsigned int union_memsize(const var_list_t *fields, unsigned int *pmaxa)
int get_padding(const var_list_t *fields) int get_padding(const var_list_t *fields)
{ {
unsigned short offset = 0; unsigned short offset = 0;
int salign = -1; unsigned int salign = 1;
const var_t *f; const var_t *f;
if (!fields) if (!fields)
...@@ -1139,8 +1134,7 @@ int get_padding(const var_list_t *fields) ...@@ -1139,8 +1134,7 @@ int get_padding(const var_list_t *fields)
type_t *ft = f->type; type_t *ft = f->type;
unsigned int align = 0; unsigned int align = 0;
unsigned int size = type_memsize(ft, &align); unsigned int size = type_memsize(ft, &align);
if (salign == -1) if (align > salign) salign = align;
salign = align;
offset = ROUND_SIZE(offset, align); offset = ROUND_SIZE(offset, align);
offset += size; offset += size;
} }
...@@ -2202,7 +2196,7 @@ static void write_struct_members(FILE *file, const type_t *type, ...@@ -2202,7 +2196,7 @@ static void write_struct_members(FILE *file, const type_t *type,
{ {
const var_t *field; const var_t *field;
unsigned short offset = 0; unsigned short offset = 0;
int salign = -1; unsigned int salign = 1;
int padding; int padding;
var_list_t *fields = type_struct_get_fields(type); var_list_t *fields = type_struct_get_fields(type);
...@@ -2213,8 +2207,7 @@ static void write_struct_members(FILE *file, const type_t *type, ...@@ -2213,8 +2207,7 @@ static void write_struct_members(FILE *file, const type_t *type,
{ {
unsigned int align = 0; unsigned int align = 0;
unsigned int size = type_memsize(ft, &align); unsigned int size = type_memsize(ft, &align);
if (salign == -1) if (salign < align) salign = align;
salign = align;
if ((align - 1) & offset) if ((align - 1) & offset)
{ {
unsigned char fc = 0; unsigned char fc = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment