{
const declaration_t *declaration = get_irg_loc_description(irg, pos);
- warningf(&declaration->source_position,
- "variable '%#T' might be used uninitialized",
- declaration->type, declaration->symbol);
+ if (declaration != NULL) {
+ warningf(&declaration->source_position,
+ "variable '%#T' might be used uninitialized",
+ declaration->type, declaration->symbol);
+ }
return new_r_Unknown(irg, mode);
}
set_method_variadicity(irtype, variadicity_variadic);
}
+ 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 */
+ case CC_CDECL:
+is_cdecl:
+ set_method_calling_convention(irtype, SET_CDECL(cc));
+ break;
+
+ case CC_STDCALL:
+ if (function_type->variadic || function_type->unspecified_parameters)
+ goto is_cdecl;
+
+ /* only non-variadic function can use stdcall, else use cdecl */
+ set_method_calling_convention(irtype, SET_STDCALL(cc));
+ break;
+
+ case CC_FASTCALL:
+ if (function_type->variadic || function_type->unspecified_parameters)
+ goto is_cdecl;
+ /* only non-variadic function can use fastcall, else use cdecl */
+ set_method_calling_convention(irtype, SET_FASTCALL(cc));
+ break;
+
+ case CC_THISCALL:
+ /* Hmm, leave default, not accepted by the parser yet. */
+ warningf(&function_type->base.source_position, "THISCALL calling convention not supported yet");
+ break;
+ }
return irtype;
}
declaration_t *declaration);
create_ld_ident_func create_ld_ident = create_ld_ident_linux_elf;
+/**
+ * Handle GNU attributes for entities
+ *
+ * @param ent the entity
+ * @param decl the routine declaration
+ */
+static void handle_gnu_attributes_ent(ir_entity *ent, declaration_t *decl)
+{
+ if (decl->modifiers & DM_PURE) {
+ /* TRUE if the declaration includes the GNU
+ __attribute__((pure)) specifier. */
+ set_entity_additional_property(ent, mtp_property_pure);
+ }
+ if (decl->modifiers & DM_USED) {
+ /* TRUE if the declaration includes the GNU
+ __attribute__((used)) specifier. */
+ set_entity_stickyness(ent, stickyness_sticky);
+ }
+}
+
/**
* Creates an entity representing a function.
*
entity = new_d_entity(global_type, id, ir_type_method, dbgi);
set_entity_ld_ident(entity, create_ld_ident(entity, declaration));
+ handle_gnu_attributes_ent(entity, declaration);
+
/* static inline => local
* extern inline => local
* inline without definition => local
bool const has_body = declaration->init.statement != NULL;
if (is_inline && storage_class == STORAGE_CLASS_NONE && has_body) {
set_entity_visibility(entity, visibility_external_visible);
- } else if (storage_class == STORAGE_CLASS_STATIC || is_inline) {
+ } else if (storage_class == STORAGE_CLASS_STATIC ||
+ (is_inline && has_body)) {
if (!has_body) {
/* this entity was declared, but is defined nowhere */
set_entity_peculiarity(entity, peculiarity_description);
}
/* create output projs & connect them */
+ if (needs_memory) {
+ ir_node *projm = new_Proj(node, mode_M, out_size+1);
+ set_store(projm);
+ }
+
size_t i;
for (i = 0; i < out_size; ++i) {
const expression_t *out_expr = out_exprs[i];
set_value_for_expression_addr(out_expr, proj, addr);
}
- if (needs_memory) {
- ir_node *projm = new_Proj(node, mode_M, i);
- set_store(projm);
- }
}
static void ms_try_statement_to_firm(ms_try_statement_t *statement) {
obstack_free(&asm_obst, NULL);
}
+static void global_asm_to_firm(statement_t *s)
+{
+ for (; s != NULL; s = s->base.next) {
+ assert(s->kind == STATEMENT_ASM);
+
+ char const *const text = s->asms.asm_text.begin;
+ size_t size = s->asms.asm_text.size;
+
+ /* skip the last \0 */
+ if (text[size - 1] == '\0')
+ --size;
+
+ ident *const id = new_id_from_chars(text, size);
+ add_irp_asm(id);
+ }
+}
+
void translation_unit_to_firm(translation_unit_t *unit)
{
/* just to be sure */
init_ir_types();
scope_to_firm(&unit->scope);
+ global_asm_to_firm(unit->global_asm);
}