X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=attribute.c;h=97be0264b00bab45cec572184336dbea252b1110;hb=10d027a8444ae755a8ade716c9336f9b1ed17c20;hp=9385333b207912f80f0f40519a9668d62eed4887;hpb=9901ca07efc9af25e27ace2a0bd5885c3ddd6d5e;p=cparser diff --git a/attribute.c b/attribute.c index 9385333..97be026 100644 --- a/attribute.c +++ b/attribute.c @@ -242,7 +242,7 @@ static void warn_arguments(const attribute_t *attribute) if (warning.other) { warningf(&attribute->source_position, - "attribute '%s' needs no attributes", + "attribute '%s' needs no arguments", get_attribute_name(attribute->kind)); } } @@ -275,6 +275,21 @@ static void handle_attribute_packed(const attribute_t *attribute, type_t *type) handle_attribute_packed_e(attribute, (entity_t*) type->compound.compound); } +static void handle_attribute_asm(const attribute_t *attribute, + entity_t *entity) +{ + attribute_argument_t *argument = attribute->a.arguments; + assert (argument->kind == ATTRIBUTE_ARGUMENT_EXPRESSION); + expression_t *expression = argument->v.expression; + if (expression->kind != EXPR_STRING_LITERAL) + errorf(&attribute->source_position, + "Invalid asm attribute expression"); + symbol_t *sym = symbol_table_insert(expression->string_literal.value.begin); + entity->function.actual_name = sym; + assert (argument->next == NULL); + return; +} + void handle_entity_attributes(const attribute_t *attributes, entity_t *entity) { if (entity->kind == ENTITY_TYPEDEF) { @@ -310,6 +325,7 @@ void handle_entity_attributes(const attribute_t *attributes, entity_t *entity) case ATTRIBUTE_GNU_UNUSED: modifiers |= DM_UNUSED; break; case ATTRIBUTE_GNU_DLLIMPORT: modifiers |= DM_DLLIMPORT; break; case ATTRIBUTE_GNU_DLLEXPORT: modifiers |= DM_DLLEXPORT; break; + case ATTRIBUTE_GNU_WEAK: modifiers |= DM_WEAK; break; case ATTRIBUTE_MS_ALLOCATE: modifiers |= DM_MALLOC; break; case ATTRIBUTE_MS_DLLIMPORT: modifiers |= DM_DLLIMPORT; break; @@ -328,6 +344,10 @@ void handle_entity_attributes(const attribute_t *attributes, entity_t *entity) handle_attribute_packed_e(attribute, entity); break; + case ATTRIBUTE_GNU_ASM: + handle_attribute_asm(attribute, entity); + break; + case ATTRIBUTE_MS_ALIGN: case ATTRIBUTE_GNU_ALIGNED: handle_attribute_aligned(attribute, entity); @@ -378,7 +398,7 @@ type_t *handle_type_attributes(const attribute_t *attributes, type_t *type) switch(attribute->kind) { case ATTRIBUTE_GNU_PACKED: handle_attribute_packed(attribute, type); - break; + break; case ATTRIBUTE_GNU_CDECL: case ATTRIBUTE_MS_CDECL: type = change_calling_convention(type, CC_CDECL); @@ -419,7 +439,7 @@ const char *get_deprecated_string(const attribute_t *attribute) expression_t *expression = argument->v.expression; if (expression->kind != EXPR_STRING_LITERAL) return NULL; - return expression->string.value.begin; + return expression->literal.value.begin; } return NULL; }