+ type_t *orig_type = expression->type;
+ long offset = 0;
+
+ designator_t *designator = expression->designator;
+ for( ; designator != NULL; designator = designator->next) {
+ type_t *type = skip_typeref(orig_type);
+ /* be sure the type is constructed */
+ (void) get_ir_type(type);
+
+ if(designator->symbol != NULL) {
+ assert(is_type_compound(type));
+ symbol_t *symbol = designator->symbol;
+
+ declaration_t *declaration = type->compound.declaration;
+ declaration_t *iter = declaration->scope.declarations;
+ for( ; iter != NULL; iter = iter->next) {
+ if(iter->symbol == symbol) {
+ break;
+ }
+ }
+ assert(iter != NULL);
+
+ assert(iter->declaration_kind == DECLARATION_KIND_COMPOUND_MEMBER);
+ offset += get_entity_offset(iter->v.entity);
+
+ orig_type = iter->type;
+ } else {
+ expression_t *array_index = designator->array_index;
+ assert(designator->array_index != NULL);
+ assert(is_type_array(type));
+ assert(is_type_valid(array_index->base.type));
+
+ long index = fold_constant(array_index);
+ ir_type *arr_type = get_ir_type(type);
+ ir_type *elem_type = get_array_element_type(arr_type);
+ long elem_size = get_type_size_bytes(elem_type);
+
+ offset += index * elem_size;
+
+ orig_type = type->array.element_type;
+ }
+ }
+
+ return offset;
+}
+
+static ir_node *offsetof_to_firm(const offsetof_expression_t *expression)
+{
+ ir_mode *mode = get_ir_mode(expression->base.type);
+ long offset = get_offsetof_offset(expression);
+ tarval *tv = new_tarval_from_long(offset, mode);
+ dbg_info *dbgi = get_dbg_info(&expression->base.source_position);
+
+ return new_d_Const(dbgi, mode, tv);
+}
+
+static void create_local_initializer(initializer_t *initializer, dbg_info *dbgi,
+ ir_entity *entity, type_t *type);
+
+static ir_node *compound_literal_to_firm(
+ const compound_literal_expression_t *expression)
+{
+ type_t *type = expression->type;
+
+ /* create an entity on the stack */
+ ir_type *frame_type = get_irg_frame_type(current_ir_graph);
+
+ ident *const id = id_unique("CompLit.%u");
+ ir_type *const irtype = get_ir_type(type);
+ dbg_info *const dbgi = get_dbg_info(&expression->base.source_position);
+ ir_entity *const entity = new_d_entity(frame_type, id, irtype, dbgi);
+ set_entity_ld_ident(entity, id);
+
+ set_entity_variability(entity, variability_uninitialized);
+
+ /* create initialisation code */
+ initializer_t *initializer = expression->initializer;
+ create_local_initializer(initializer, dbgi, entity, type);
+
+ /* create a sel for the compound literal address */
+ ir_node *frame = get_local_frame(entity);
+ ir_node *sel = new_d_simpleSel(dbgi, new_NoMem(), frame, entity);
+ return sel;