- fixed r22803
[libfirm] / ir / be / begnuas.c
index 370c757..0679d60 100644 (file)
@@ -24,9 +24,7 @@
  * @date        04.11.2005
  * @version     $Id$
  */
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
 
 #include "begnuas.h"
 
@@ -634,19 +632,21 @@ static int ent_is_string_const(ir_entity *ent)
 static void dump_string_cst(ir_entity *ent)
 {
        int      i, len;
+       int      output_len;
        ir_type *type;
        int      type_size;
        int      remaining_space;
 
-       len = get_compound_ent_n_values(ent);
+       len        = get_compound_ent_n_values(ent);
+       output_len = len;
        if (be_gas_flavour == GAS_FLAVOUR_MACH_O) {
                be_emit_cstring("\t.ascii \"");
        } else {
                be_emit_cstring("\t.string \"");
-               len -= 1;
+               output_len -= 1;
        }
 
-       for (i = 0; i < len; ++i) {
+       for (i = 0; i < output_len; ++i) {
                ir_node *irn;
                int c;
 
@@ -814,6 +814,7 @@ static void dump_bitfield(normal_or_bitfield *vals, size_t offset_bits,
        if (tv == NULL) {
                panic("Couldn't get numeric value for bitfield initializer");
        }
+       tv = tarval_convert_to(tv, get_type_mode(type));
 
        /* normalize offset */
        vals        += offset_bits >> 3;
@@ -951,7 +952,7 @@ static void dump_initializer(be_gas_decl_env_t *env, ir_entity *entity)
         * In the worst case, every initializer allocates one byte.
         * Moreover, initializer might be big, do not allocate on stack.
         */
-       vals = xcalloc(size, sizeof(vals[0]));
+       vals = XMALLOCNZ(normal_or_bitfield, size);
 
 #ifndef NDEBUG
        glob_vals = vals;
@@ -1040,7 +1041,7 @@ static void dump_compound_init(be_gas_decl_env_t *env, ir_entity *ent)
         * In the worst case, every initializer allocates one byte.
         * Moreover, initializer might be big, do not allocate on stack.
         */
-       vals = xcalloc(last_ofs, sizeof(vals[0]));
+       vals = XMALLOCNZ(normal_or_bitfield, last_ofs);
 
        /* collect the values and store them at the offsets */
        for (i = 0; i < n; ++i) {