mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-21 09:51:41 +00:00
Fix field def allocation for non-function fields.
This commit is contained in:
parent
ecbb904d6b
commit
7d1f2c4ef3
1 changed files with 22 additions and 3 deletions
|
@ -280,6 +280,16 @@ init_elements (struct def_s *def, expr_t *eles)
|
|||
free (elements);
|
||||
}
|
||||
|
||||
static void
|
||||
init_field_def (def_t *def)
|
||||
{
|
||||
type_t *type = def->type->t.fldptr.type;
|
||||
D_INT (def) = defspace_new_loc (pr.entity_data, type_size (type));
|
||||
reloc_def_field (def, def);
|
||||
def->constant = 1;
|
||||
def->nosave = 1;
|
||||
}
|
||||
|
||||
void
|
||||
initialize_def (symbol_t *sym, type_t *type, expr_t *init, defspace_t *space,
|
||||
storage_class_t storage)
|
||||
|
@ -333,8 +343,11 @@ initialize_def (symbol_t *sym, type_t *type, expr_t *init, defspace_t *space,
|
|||
warning (0, "initializing external variable");
|
||||
return;
|
||||
}
|
||||
if (!init)
|
||||
if (!init) {
|
||||
if (type->type == ev_field)
|
||||
init_field_def (sym->s.def);
|
||||
return;
|
||||
}
|
||||
convert_name (init);
|
||||
if (init->type == ex_error)
|
||||
return;
|
||||
|
@ -355,8 +368,14 @@ initialize_def (symbol_t *sym, type_t *type, expr_t *init, defspace_t *space,
|
|||
error (0, "non-constant initializier");
|
||||
return;
|
||||
}
|
||||
memcpy (D_POINTER (void, sym->s.def), &init->e.value,
|
||||
type_size (type) * sizeof (pr_type_t));
|
||||
if (init->e.value.type == ev_pointer
|
||||
|| init->e.value.type == ev_field) {
|
||||
// FIXME offset pointers
|
||||
D_INT (sym->s.def) = init->e.value.v.pointer.val;
|
||||
} else {
|
||||
memcpy (D_POINTER (void, sym->s.def), &init->e.value,
|
||||
type_size (type) * sizeof (pr_type_t));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue