static entity_t **inner_functions;
static ir_node *ijmp_list;
static bool constant_folding;
-static symbol_t *sym_C;
extern bool have_const_functions;
set_method_variadicity(irtype, variadicity_variadic);
}
-#if 0
- /* TODO: revive this with linkage stuff */
unsigned cc = get_method_calling_convention(irtype);
switch (function_type->calling_convention) {
case CC_DEFAULT: /* unspecified calling convention, equal to one of the other, typically cdecl */
/* Hmm, leave default, not accepted by the parser yet. */
break;
}
-#endif
return irtype;
}
static ident *rts_idents[sizeof(rts_data) / sizeof(rts_data[0])];
-typedef ident* (*create_ld_ident_func)(entity_t *entity);
-create_ld_ident_func create_ld_ident = create_name_linux_elf;
+static ident* (*create_ld_ident)(entity_t*) = create_name_linux_elf;
/**
* Handle GNU attributes for entities
/* force main to C linkage */
type_t *type = entity->declaration.type;
assert(is_type_function(type));
- if (type->function.linkage != NULL && type->function.linkage != sym_C) {
- errorf(&entity->base.source_position,
- "main must have \"C\" linkage");
- }
-
- if (type->function.linkage == NULL || type->function.linkage != sym_C) {
+ if (type->function.linkage != LINKAGE_C) {
type_t *new_type = duplicate_type(type);
- new_type->function.linkage = sym_C;
+ new_type->function.linkage = LINKAGE_C;
type = typehash_insert(new_type);
if (type != new_type) {
return create_initializer_const(value);
}
+/** test wether type can be initialized by a string constant */
+static bool is_string_type(type_t *type)
+{
+ type_t *inner;
+ if (is_type_pointer(type)) {
+ inner = skip_typeref(type->pointer.points_to);
+ } else if(is_type_array(type)) {
+ inner = skip_typeref(type->array.element_type);
+ } else {
+ return false;
+ }
+
+ return is_type_integer(inner);
+}
+
static ir_initializer_t *create_ir_initializer_list(
const initializer_list_t *initializer, type_t *type)
{
break;
descend_into_subtype(&path);
}
+ } else if (sub_initializer->kind == INITIALIZER_STRING
+ || sub_initializer->kind == INITIALIZER_WIDE_STRING) {
+ /* we might have to descend into types until we're at a scalar
+ * type */
+ while (true) {
+ type_t *orig_top_type = path.top_type;
+ type_t *top_type = skip_typeref(orig_top_type);
+
+ if (is_string_type(top_type))
+ break;
+ descend_into_subtype(&path);
+ }
}
ir_initializer_t *sub_irinitializer
rts_idents[i] = new_id_from_str(rts_data[i].name);
}
- sym_C = symbol_table_insert("C");
-
entitymap_init(&entitymap);
}