Initialize global string vars correctly.

Ouch, I'd fixed that for arrays, but not normal vars.
This commit is contained in:
Bill Currie 2012-11-03 18:11:45 +09:00
parent 9095e1eabc
commit cc24e2e67e

View file

@ -515,8 +515,13 @@ initialize_def (symbol_t *sym, type_t *type, expr_t *init, defspace_t *space,
ex_value_t v = init->e.value;
if (is_scalar (sym->type))
convert_value (&v, sym->type);
memcpy (D_POINTER (void, sym->s.def), &v.v,
type_size (type) * sizeof (pr_type_t));
if (v.type == ev_string) {
EMIT_STRING (sym->s.def->space, D_STRING (sym->s.def),
v.v.string_val);
} else {
memcpy (D_POINTER (void, sym->s.def), &v.v,
type_size (type) * sizeof (pr_type_t));
}
}
sym->s.def->initialized = sym->s.def->constant = 1;
sym->s.def->nosave = 1;