Use the def type rather than expression type to select the init method.

Local defs may be initialized with non-constant expressions, which
includes function calls. Both function calls and aggregate initializers
use block expressions.
This commit is contained in:
Bill Currie 2011-02-15 09:38:44 +09:00
parent 19f6faf0ad
commit 4e86b28b59

View file

@ -339,7 +339,7 @@ initialize_def (symbol_t *sym, type_t *type, expr_t *init, defspace_t *space,
return; return;
if (init->type == ex_nil) if (init->type == ex_nil)
convert_nil (init, type); convert_nil (init, type);
if (init->type == ex_block) { if (is_array (type) || is_struct (type)) {
init_elements (sym->s.def, init); init_elements (sym->s.def, init);
} else { } else {
if (!type_assignable (type, get_type (init))) { if (!type_assignable (type, get_type (init))) {