bugfix in add_entity_val
[libfirm] / ir / tr / entity.c
index ca7fff3..d67cc45 100644 (file)
@@ -364,13 +364,15 @@ set_array_entity_values(entity *ent, tarval **values, int num_vals) {
 
   assert(is_array_type(arrtp));
   assert(get_array_n_dimensions(arrtp) == 1);
-  assert(get_array_lower_bound (arrtp, 0) && get_array_upper_bound (arrtp, 0));
+  /* One bound is sufficient, the nunmber of constant fields makes the
+     size. */
+  assert(get_array_lower_bound (arrtp, 0) || get_array_upper_bound (arrtp, 0));
   assert(get_entity_variability(ent) != uninitialized);
   current_ir_graph = get_const_code_irg();
 
   for (i = 0; i < num_vals; i++) {
     val = new_Const(get_tv_mode (values[i]), values[i]);
-    set_compound_ent_value(ent, val, get_array_element_entity(arrtp), i);
+    add_compound_ent_value(ent, val, get_array_element_entity(arrtp));
   }
   current_ir_graph = rem;
 }