if((c_mode & _MS) == 0)
return;
- decl_modifiers_t modifiers = declaration->modifiers;
+ decl_modifiers_t modifiers = declaration->decl_modifiers;
/* DM_FORCEINLINE handled outside. */
if((modifiers & ~DM_FORCEINLINE) != 0 ||
{
print_storage_class((storage_class_tag_t) declaration->declared_storage_class);
if(declaration->is_inline) {
- if(declaration->modifiers & DM_FORCEINLINE)
+ if(declaration->decl_modifiers & DM_FORCEINLINE)
fputs("__forceinline ", out);
else {
- if(declaration->modifiers & DM_MICROSOFT_INLINE)
+ if(declaration->decl_modifiers & DM_MICROSOFT_INLINE)
fputs("__inline ", out);
else
fputs("inline ", out);
{ rts_strncmp, 1, "strncmp", 3, _C89 }
};
+/**
+ * Mangles an entity linker (ld) name for win32 usage.
+ *
+ * @param ent the entity to be mangled
+ * @param decl_modifiers the set of modifiers for this entity
+ */
+static ir_ident_ptr decorate_win32(ir_entity_ptr ent, decl_modifiers_t decl_modifiers) {
+ ir_ident_ptr id;
+
+ if (is_Method_type(get_entity_type(ent)))
+ id = decorate_win32_c_fkt(ent, get_entity_ident(ent));
+ else {
+ /* always add an underscore in win32 */
+ id = mangle(new_id_from_chars("_", 1), get_entity_ident(ent));
+ }
+
+ if (decl_modifiers & DM_DLLIMPORT) {
+ /* add prefix for imported symbols */
+ id = mangle(new_id_from_chars("__imp_", 6), id);
+ }
+ return id;
+}
+
+/**
+ * Mangles an entity linker (ld) name from a declaration.
+ *
+ * @param ent the entity to be mangled
+ * @param declaration the declaration
+ */
+static void mangle_ent_from_decl(ir_entity *ent, declaration_t *declaration)
+{
+ ident *id;
+
+ if (firm_opt.os_support == OS_SUPPORT_MINGW)
+ id = decorate_win32(ent, declaration->decl_modifiers);
+ else
+ id = get_entity_ident(ent);
+
+ set_entity_ld_ident(ent, id);
+}
+
static ir_entity* get_function_entity(declaration_t *declaration)
{
if(declaration->declaration_kind == DECLARATION_KIND_FUNCTION)
dbg_info *const dbgi = get_dbg_info(&declaration->source_position);
ir_entity *const entity = new_d_entity(global_type, id, ir_type_method, dbgi);
- set_entity_ld_ident(entity, id);
+ mangle_ent_from_decl(entity, declaration);
if(declaration->storage_class == STORAGE_CLASS_STATIC
|| declaration->is_inline) {
set_entity_visibility(entity, visibility_local);
ir_type *const irtype = get_ir_type(type);
dbg_info *const dbgi = get_dbg_info(&declaration->source_position);
ir_entity *const entity = new_d_entity(parent_type, id, irtype, dbgi);
- set_entity_ld_ident(entity, id);
+ mangle_ent_from_decl(entity, declaration);
declaration->declaration_kind = (unsigned char) declaration_kind;
declaration->v.entity = entity;
ir_type *const irtype = get_ir_type(type);
dbg_info *const dbgi = get_dbg_info(&declaration->source_position);
ir_entity *const entity = new_d_entity(global_type, id, irtype, dbgi);
- set_entity_ld_ident(entity, id);
+ mangle_ent_from_decl(entity, declaration);
if(type->base.qualifiers & TYPE_QUALIFIER_VOLATILE) {
set_entity_volatility(entity, volatility_is_volatile);
/* set inline flags */
if (declaration->is_inline)
set_irg_inline_property(irg, irg_inline_recomended);
- handle_decl_modifier_irg(irg, declaration->modifiers);
+ handle_decl_modifier_irg(irg, declaration->decl_modifiers);
next_value_number_function = 0;
initialize_function_parameters(declaration);
unsigned char declared_storage_class;
unsigned char storage_class;
unsigned char alignment; /**< Alignment of the declaration, 0 for default. */
- decl_modifiers_t modifiers; /**< MS __declspec modifiers. */
+ decl_modifiers_t decl_modifiers; /**< MS __declspec modifiers. */
const char *deprecated_string; /**< MS deprecated string if any. */
symbol_t *get_property_sym; /**< MS get property. */
symbol_t *put_property_sym; /**< MS put property. */
expression_t *enum_value;
} init;
scope_t scope; /**< The scope that this declaration opens. */
- scope_t *parent_scope; /**< The parant scope where this declaration lives. */
+ scope_t *parent_scope; /**< The parent scope where this declaration lives. */
/** next declaration in a scope */
declaration_t *next;
{
declaration_t *const declaration = allocate_declaration_zero();
declaration->declared_storage_class = specifiers->declared_storage_class;
- declaration->modifiers = specifiers->decl_modifiers;
+ declaration->decl_modifiers = specifiers->decl_modifiers;
declaration->deprecated = specifiers->deprecated;
declaration->deprecated_string = specifiers->deprecated_string;
declaration->get_property_sym = specifiers->get_property_sym;
declaration->type = specifiers->type;
declaration->declared_storage_class = specifiers->declared_storage_class;
declaration->source_position = specifiers->source_position;
- declaration->modifiers = specifiers->decl_modifiers;
+ declaration->decl_modifiers = specifiers->decl_modifiers;
if (declaration->declared_storage_class != STORAGE_CLASS_NONE) {
warningf(&declaration->source_position,
declaration->declared_storage_class = STORAGE_CLASS_NONE;
declaration->storage_class = STORAGE_CLASS_NONE;
declaration->source_position = source_position;
- declaration->modifiers = specifiers->decl_modifiers;
+ declaration->decl_modifiers = specifiers->decl_modifiers;
declaration->type = type;
} else {
declaration = parse_declarator(specifiers,/*may_be_abstract=*/true);