Commit cb6a2254 authored by Alexandre Julliard's avatar Alexandre Julliard

widl: Add a type_memsize_and_alignment function to make it explicit where the…

widl: Add a type_memsize_and_alignment function to make it explicit where the alignment is truly needed.
parent a7d000e2
...@@ -206,9 +206,8 @@ expr_t *make_exprt(enum expr_type type, var_t *var, expr_t *expr) ...@@ -206,9 +206,8 @@ expr_t *make_exprt(enum expr_type type, var_t *var, expr_t *expr)
/* only do this for types that should be the same on all platforms */ /* only do this for types that should be the same on all platforms */
if (is_integer_type(tref) || is_float_type(tref)) if (is_integer_type(tref) || is_float_type(tref))
{ {
unsigned int align = 0;
e->is_const = TRUE; e->is_const = TRUE;
e->cval = type_memsize(tref, &align); e->cval = type_memsize(tref);
} }
} }
/* check for cast of constant expression */ /* check for cast of constant expression */
...@@ -216,8 +215,7 @@ expr_t *make_exprt(enum expr_type type, var_t *var, expr_t *expr) ...@@ -216,8 +215,7 @@ expr_t *make_exprt(enum expr_type type, var_t *var, expr_t *expr)
{ {
if (is_integer_type(tref)) if (is_integer_type(tref))
{ {
unsigned int align = 0; unsigned int cast_type_bits = type_memsize(tref) * 8;
unsigned int cast_type_bits = type_memsize(tref, &align) * 8;
unsigned int cast_mask; unsigned int cast_mask;
e->is_const = TRUE; e->is_const = TRUE;
......
...@@ -1485,8 +1485,7 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl ...@@ -1485,8 +1485,7 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl
/* FIXME: should use a type_memsize that allows us to pass in a pointer size */ /* FIXME: should use a type_memsize that allows us to pass in a pointer size */
if (0) if (0)
{ {
unsigned int align = 0; unsigned int size = type_memsize(v->type);
unsigned int size = type_memsize(v->type, &align);
if (0xffffffffu / size < dim->cval) if (0xffffffffu / size < dim->cval)
error_loc("%s: total array size is too large\n", v->name); error_loc("%s: total array size is too large\n", v->name);
...@@ -2263,14 +2262,12 @@ static int is_allowed_conf_type(const type_t *type) ...@@ -2263,14 +2262,12 @@ static int is_allowed_conf_type(const type_t *type)
static int is_ptr_guid_type(const type_t *type) static int is_ptr_guid_type(const type_t *type)
{ {
unsigned int align = 0;
/* first, make sure it is a pointer to something */ /* first, make sure it is a pointer to something */
if (!is_ptr(type)) return FALSE; if (!is_ptr(type)) return FALSE;
/* second, make sure it is a pointer to something of size sizeof(GUID), /* second, make sure it is a pointer to something of size sizeof(GUID),
* i.e. 16 bytes */ * i.e. 16 bytes */
return (type_memsize(type_pointer_get_ref(type), &align) == 16); return (type_memsize(type_pointer_get_ref(type)) == 16);
} }
static void check_conformance_expr_list(const char *attr_name, const var_t *arg, const type_t *container_type, expr_list_t *expr_list) static void check_conformance_expr_list(const char *attr_name, const var_t *arg, const type_t *container_type, expr_list_t *expr_list)
......
...@@ -80,7 +80,7 @@ void write_expr_eval_routine_list(FILE *file, const char *iface); ...@@ -80,7 +80,7 @@ void write_expr_eval_routine_list(FILE *file, const char *iface);
void write_user_quad_list(FILE *file); void write_user_quad_list(FILE *file);
void write_endpoints( FILE *f, const char *prefix, const str_list_t *list ); void write_endpoints( FILE *f, const char *prefix, const str_list_t *list );
void write_exceptions( FILE *file ); void write_exceptions( FILE *file );
unsigned int type_memsize(const type_t *t, unsigned int *align); unsigned int type_memsize(const type_t *t);
int decl_indirect(const type_t *t); int decl_indirect(const type_t *t);
void write_parameters_init(FILE *file, int indent, const var_t *func, const char *local_var_prefix); void write_parameters_init(FILE *file, int indent, const var_t *func, const char *local_var_prefix);
void print(FILE *file, int indent, const char *format, va_list ap); void print(FILE *file, int indent, const char *format, va_list ap);
......
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