fix implicit struct casts
[cparser] / ast2firm.c
index fb3d734..63bd350 100644 (file)
@@ -1045,7 +1045,9 @@ static ir_node *wide_string_literal_to_firm(
 static ir_node *deref_address(ir_type *const irtype, ir_node *const addr,
                               dbg_info *const dbgi)
 {
-       if(is_compound_type(irtype) || is_Array_type(irtype)) {
+       if (is_compound_type(irtype) ||
+                       is_Method_type(irtype)   ||
+                       is_Array_type(irtype)) {
                return addr;
        }
 
@@ -1732,8 +1734,12 @@ static ir_node *unary_expression_to_firm(const unary_expression_t *expression)
        }
        case EXPR_UNARY_CAST_IMPLICIT: {
                ir_node *value_node = expression_to_firm(value);
-               ir_mode *mode = get_ir_mode(type);
-               return create_conv(dbgi, value_node, mode);
+               if(is_type_scalar(type)) {
+                       ir_mode *mode = get_ir_mode(type);
+                       return create_conv(dbgi, value_node, mode);
+               } else {
+                       return value_node;
+               }
        }
        case EXPR_UNARY_ASSUME:
                if(firm_opt.confirm)
@@ -3135,7 +3141,7 @@ static void declaration_statement_to_firm(declaration_statement_t *statement)
        for( ; declaration != end; declaration = declaration->next) {
                if(declaration->namespc != NAMESPACE_NORMAL)
                        continue;
-               create_local_variable(declaration);
+               create_local_declaration(declaration);
        }
 }