/*
* This file is part of cparser.
- * Copyright (C) 2007-2009 Matthias Braun <matze@braunis.de>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
+ * Copyright (C) 2012 Matthias Braun <matze@braunis.de>
*/
#include <config.h>
* 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;
}
} 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;
}
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;
}
}
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;
}
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;
}
}
* 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;
}
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;
}
}
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);
}
{
#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
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;
}
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);
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;
}
if (modifiers != 0) {
- switch(entity->kind) {
+ switch (entity->kind) {
case ENTITY_TYPEDEF:
entity->typedefe.modifiers |= modifiers;
break;
{
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;
/* TODO */
return false;
}
- panic("Unknown argument type found");
+ panic("unknown argument type");
}
static bool attribute_arguments_equal(const attribute_argument_t *args1,