X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=attribute.c;fp=attribute.c;h=805943507a785899632f57a0110ce1afb09a7c12;hb=39f037e698ced8645048043c73e9797bdecd3360;hp=a29299a55c6ea994fb0c2251f6de7b61702af2c8;hpb=ef3b0164cbb6c9d616c3fdad92fb8da669e4b5d7;p=cparser diff --git a/attribute.c b/attribute.c index a29299a..8059435 100644 --- a/attribute.c +++ b/attribute.c @@ -295,6 +295,38 @@ static void handle_attribute_asm(const attribute_t *attribute, return; } +static void handle_attribute_alias(const attribute_t *attribute, + entity_t *entity) +{ + // TODO: return if not at function_scope + attribute_argument_t *arg = attribute->a.arguments; + if (arg == NULL) { + errorf(&attribute->pos, + "__attribute__((alias(X))) misses argument"); + return; + } + const char *string = get_argument_string(arg); + if (string == NULL) { + errorf(&attribute->pos, + "__attribute__((alias(X))) argument is not a string"); + return; + } + symbol_t *symbol = symbol_table_insert(string); + + switch (entity->kind) { + case ENTITY_VARIABLE: + entity->variable.alias = symbol; + break; + case ENTITY_FUNCTION: + entity->function.alias = symbol; + break; + default: + warningf(WARN_OTHER, &attribute->pos, "alias attribute on '%N' ignored", entity); + break; + } + return; +} + void handle_entity_attributes(const attribute_t *attributes, entity_t *entity) { if (entity->kind == ENTITY_TYPEDEF) { @@ -338,6 +370,10 @@ void handle_entity_attributes(const attribute_t *attributes, entity_t *entity) case ATTRIBUTE_MS_RESTRICT: modifiers |= DM_RESTRICT; break; case ATTRIBUTE_MS_NOALIAS: modifiers |= DM_NOALIAS; break; + case ATTRIBUTE_GNU_ALIAS: + handle_attribute_alias(attribute, entity); + break; + case ATTRIBUTE_GNU_PACKED: handle_attribute_packed_e(attribute, entity); break;