X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ast2firm.c;h=2e85c8aa512fbdfeb19339fd5471bb321fdc02fe;hb=8845feb009950d2c76a394660a5bd81a0be0f2a6;hp=d9a0df53ed9964d07885d093723a2ec4c6c94b9d;hpb=69d9db34e3690997dfe2ca92f1ebf9018571fbef;p=cparser diff --git a/ast2firm.c b/ast2firm.c index d9a0df5..2e85c8a 100644 --- a/ast2firm.c +++ b/ast2firm.c @@ -2207,10 +2207,13 @@ static ir_node *create_cast(unary_expression_t const *const expr) if (is_type_void(type)) return NULL; - ir_node *value = expression_to_value(expr->value); - dbg_info *const dbgi = get_dbg_info(&expr->base.pos); - type_t *const from_type = skip_typeref(expr->value->base.type); - ir_mode *const mode = get_ir_mode_storage(type); + type_t *const from_type = skip_typeref(expr->value->base.type); + ir_node *value = is_type_complex(from_type) + ? expression_to_complex(expr->value).real + : expression_to_value(expr->value); + + dbg_info *const dbgi = get_dbg_info(&expr->base.pos); + ir_mode *const mode = get_ir_mode_storage(type); /* check for conversion from / to __based types */ if (is_type_pointer(type) && is_type_pointer(from_type)) { const variable_t *from_var = from_type->pointer.base_variable;