X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=attribute.c;h=118f046a92b44a1321919a4719fad9acadd6e1dc;hb=f22121e4473703019e76f50d46ff52dcd7d0b020;hp=71f91d3eded5ef7947a797ef94a8213c5c67d1aa;hpb=c8977a026c0d4d6d4c96505e4b3948fae6436d08;p=cparser diff --git a/attribute.c b/attribute.c index 71f91d3..118f046 100644 --- a/attribute.c +++ b/attribute.c @@ -132,8 +132,7 @@ type_t *handle_attribute_mode(const attribute_t *attribute, type_t *orig_type) * specific modes (according to gcc philosophy that is...) */ attribute_argument_t *arg = attribute->a.arguments; if (arg == NULL) { - errorf(&attribute->source_position, - "__attribute__((mode(X))) misses argument"); + errorf(&attribute->pos, "__attribute__((mode(X))) misses argument"); return orig_type; } @@ -152,8 +151,8 @@ type_t *handle_attribute_mode(const attribute_t *attribute, type_t *orig_type) } else if (streq_underscore("DI", symbol_str)) { akind = sign ? ATOMIC_TYPE_LONGLONG : ATOMIC_TYPE_ULONGLONG; } else { - source_position_t const *const pos = &attribute->source_position; - warningf(WARN_OTHER, pos, "ignoring unknown mode '%s'", symbol_str); + warningf(WARN_OTHER, &attribute->pos, "ignoring unknown mode '%s'", + symbol_str); return orig_type; } @@ -162,12 +161,11 @@ type_t *handle_attribute_mode(const attribute_t *attribute, type_t *orig_type) copy->atomic.akind = akind; return identify_new_type(copy); } else if (is_type_pointer(type)) { - source_position_t const *const pos = &attribute->source_position; - warningf(WARN_OTHER, pos, "__attribute__((mode)) on pointers not implemented yet (ignored)"); + warningf(WARN_OTHER, &attribute->pos, "__attribute__((mode)) on pointers not implemented yet (ignored)"); return type; } - errorf(&attribute->source_position, + errorf(&attribute->pos, "__attribute__((mode)) only allowed on integer, enum or pointer type"); return orig_type; } @@ -188,15 +186,11 @@ static void handle_attribute_aligned(const attribute_t *attribute, } if (!is_po2(alignment)) { - errorf(&attribute->source_position, - "alignment must be a power of 2 but is %d\n", - alignment); + errorf(&attribute->pos, "alignment must be a power of 2 but is %d", alignment); return; } if (alignment <= 0) { - errorf(&attribute->source_position, - "alignment must be bigger than 0 but is %d\n", - alignment); + errorf(&attribute->pos, "alignment must be bigger than 0 but is %d", alignment); return; } @@ -214,7 +208,7 @@ static void handle_attribute_aligned(const attribute_t *attribute, break; default: - warningf(WARN_OTHER, &attribute->source_position, "alignment attribute specification on '%N' ignored", entity); + warningf(WARN_OTHER, &attribute->pos, "alignment attribute specification on '%N' ignored", entity); break; } } @@ -238,19 +232,19 @@ static void handle_attribute_visibility(const attribute_t *attribute, * specific modes (according to gcc philosophy that is...) */ attribute_argument_t *arg = attribute->a.arguments; if (arg == NULL) { - errorf(&attribute->source_position, + errorf(&attribute->pos, "__attribute__((visibility(X))) misses argument"); return; } const char *string = get_argument_string(arg); if (string == NULL) { - errorf(&attribute->source_position, + errorf(&attribute->pos, "__attribute__((visibility(X))) argument is not a string"); return; } elf_visibility_tag_t visibility = get_elf_visibility_from_string(string); if (visibility == ELF_VISIBILITY_ERROR) { - errorf(&attribute->source_position, + errorf(&attribute->pos, "unknown visibility type '%s'", string); return; } @@ -264,7 +258,7 @@ static void handle_attribute_visibility(const attribute_t *attribute, break; default: - warningf(WARN_OTHER, &attribute->source_position, "visibility attribute specification on '%N' ignored", entity); + warningf(WARN_OTHER, &attribute->pos, "visibility attribute specification on '%N' ignored", entity); break; } } @@ -274,8 +268,8 @@ static void warn_arguments(const attribute_t *attribute) if (attribute->a.arguments == NULL) return; - source_position_t const *const pos = &attribute->source_position; - char const *const what = get_attribute_name(attribute->kind); + position_t const *const pos = &attribute->pos; + char const *const what = get_attribute_name(attribute->kind); warningf(WARN_OTHER, pos, "attribute '%s' needs no arguments", what); } @@ -284,7 +278,7 @@ static void handle_attribute_packed_e(const attribute_t *attribute, { #if 0 if (entity->kind != ENTITY_STRUCT) { - warningf(WARN_OTHER, &attribute->source_position, "packed attribute on '%N' ignored", entity); + warningf(WARN_OTHER, &attribute->pos, "packed attribute on '%N' ignored", entity); return; } #endif @@ -296,7 +290,7 @@ static void handle_attribute_packed_e(const attribute_t *attribute, static void handle_attribute_packed(const attribute_t *attribute, type_t *type) { if (type->kind != TYPE_COMPOUND_STRUCT) { - source_position_t const *const pos = &attribute->source_position; + position_t const *const pos = &attribute->pos; warningf(WARN_OTHER, pos, "packed attribute on type '%T' ignored", type); return; } @@ -311,8 +305,7 @@ static void handle_attribute_asm(const attribute_t *attribute, 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"); + errorf(&attribute->pos, "Invalid asm attribute expression"); symbol_t *sym = symbol_table_insert(expression->string_literal.value.begin); entity->function.actual_name = sym; assert(argument->next == NULL); @@ -334,7 +327,7 @@ void handle_entity_attributes(const attribute_t *attributes, entity_t *entity) decl_modifiers_t modifiers = 0; const attribute_t *attribute = attributes; for ( ; attribute != NULL; attribute = attribute->next) { - switch(attribute->kind) { + switch (attribute->kind) { case ATTRIBUTE_GNU_CONST: modifiers |= DM_CONST; break; case ATTRIBUTE_GNU_DEPRECATED: modifiers |= DM_DEPRECATED; break; case ATTRIBUTE_GNU_NOINLINE: modifiers |= DM_NOINLINE; break; @@ -383,7 +376,7 @@ void handle_entity_attributes(const attribute_t *attributes, entity_t *entity) } if (modifiers != 0) { - switch(entity->kind) { + switch (entity->kind) { case ENTITY_TYPEDEF: entity->typedefe.modifiers |= modifiers; break; @@ -435,7 +428,7 @@ type_t *handle_type_attributes(const attribute_t *attributes, type_t *type) { const attribute_t *attribute = attributes; for ( ; attribute != NULL; attribute = attribute->next) { - switch(attribute->kind) { + switch (attribute->kind) { case ATTRIBUTE_GNU_PACKED: handle_attribute_packed(attribute, type); break; @@ -513,7 +506,7 @@ static bool attribute_argument_equal(const attribute_argument_t *arg1, /* TODO */ return false; } - panic("Unknown argument type found"); + panic("unknown argument type"); } static bool attribute_arguments_equal(const attribute_argument_t *args1,