}
if (entity == NULL) {
- entity = allocate_entity_zero(kind, NAMESPACE_TAG);
+ entity = allocate_entity_zero(kind, NAMESPACE_TAG, symbol);
entity->compound.alignment = 1;
entity->base.source_position = pos;
- entity->base.symbol = symbol;
entity->base.parent_scope = current_scope;
if (symbol != NULL) {
environment_push(entity);
return;
}
- entity_t *const entity = allocate_entity_zero(ENTITY_ENUM_VALUE, NAMESPACE_NORMAL);
+ entity_t *const entity = allocate_entity_zero(ENTITY_ENUM_VALUE, NAMESPACE_NORMAL, token.symbol);
entity->enum_value.enum_type = enum_type;
- entity->base.symbol = token.symbol;
entity->base.source_position = token.source_position;
next_token();
}
if (entity == NULL) {
- entity = allocate_entity_zero(ENTITY_ENUM, NAMESPACE_TAG);
+ entity = allocate_entity_zero(ENTITY_ENUM, NAMESPACE_TAG, symbol);
entity->base.source_position = pos;
- entity->base.symbol = symbol;
entity->base.parent_scope = current_scope;
}
static entity_t *create_error_entity(symbol_t *symbol, entity_kind_tag_t kind)
{
- entity_t *const entity = allocate_entity_zero(kind, NAMESPACE_NORMAL);
+ entity_t *const entity = allocate_entity_zero(kind, NAMESPACE_NORMAL, symbol);
entity->base.source_position = *HERE;
- entity->base.symbol = symbol;
if (is_declaration(entity)) {
entity->declaration.type = type_error_type;
entity->declaration.implicit = true;
static void parse_identifier_list(scope_t *scope)
{
do {
- entity_t *const entity = allocate_entity_zero(ENTITY_PARAMETER, NAMESPACE_NORMAL);
+ entity_t *const entity = allocate_entity_zero(ENTITY_PARAMETER, NAMESPACE_NORMAL, token.symbol);
entity->base.source_position = token.source_position;
- entity->base.symbol = token.symbol;
/* a K&R parameter has no type, yet */
next_token();
entity_t *entity;
if (specifiers->storage_class == STORAGE_CLASS_TYPEDEF) {
- entity = allocate_entity_zero(ENTITY_TYPEDEF, NAMESPACE_NORMAL);
- entity->base.symbol = env.symbol;
+ entity = allocate_entity_zero(ENTITY_TYPEDEF, NAMESPACE_NORMAL, env.symbol);
entity->base.source_position = env.source_position;
entity->typedefe.type = orig_type;
} else {
/* create a declaration type entity */
if (flags & DECL_CREATE_COMPOUND_MEMBER) {
- entity = allocate_entity_zero(ENTITY_COMPOUND_MEMBER, NAMESPACE_NORMAL);
+ entity = allocate_entity_zero(ENTITY_COMPOUND_MEMBER, NAMESPACE_NORMAL, env.symbol);
if (env.symbol != NULL) {
if (specifiers->is_inline && is_type_valid(type)) {
orig_type = semantic_parameter(&env.source_position, orig_type,
specifiers, env.symbol);
- entity = allocate_entity_zero(ENTITY_PARAMETER, NAMESPACE_NORMAL);
+ entity = allocate_entity_zero(ENTITY_PARAMETER, NAMESPACE_NORMAL, env.symbol);
} else if (is_type_function(type)) {
- entity = allocate_entity_zero(ENTITY_FUNCTION, NAMESPACE_NORMAL);
+ entity = allocate_entity_zero(ENTITY_FUNCTION, NAMESPACE_NORMAL, env.symbol);
entity->function.is_inline = specifiers->is_inline;
entity->function.elf_visibility = default_visibility;
entity->function.parameters = env.parameters;
}
}
} else {
- entity = allocate_entity_zero(ENTITY_VARIABLE, NAMESPACE_NORMAL);
+ entity = allocate_entity_zero(ENTITY_VARIABLE, NAMESPACE_NORMAL, env.symbol);
entity->variable.elf_visibility = default_visibility;
entity->variable.thread_local = specifiers->thread_local;
}
}
- if (env.symbol != NULL) {
- entity->base.symbol = env.symbol;
- entity->base.source_position = env.source_position;
- } else {
- entity->base.source_position = specifiers->source_position;
- }
+ entity->base.source_position = env.symbol != NULL ? env.source_position : specifiers->source_position;
entity->declaration.type = orig_type;
entity->declaration.alignment = get_type_alignment(orig_type);
entity->declaration.modifiers = env.modifiers;
anchor = &(*anchor)->next;
*anchor = specifiers->attributes;
- entity = allocate_entity_zero(ENTITY_COMPOUND_MEMBER, NAMESPACE_NORMAL);
+ entity = allocate_entity_zero(ENTITY_COMPOUND_MEMBER, NAMESPACE_NORMAL, NULL);
entity->base.source_position = source_position;
entity->declaration.declared_storage_class = STORAGE_CLASS_NONE;
entity->declaration.storage_class = STORAGE_CLASS_NONE;
ntype->function.linkage = LINKAGE_C;
type_t *type = identify_new_type(ntype);
- entity_t *const entity = allocate_entity_zero(ENTITY_FUNCTION, NAMESPACE_NORMAL);
+ entity_t *const entity = allocate_entity_zero(ENTITY_FUNCTION, NAMESPACE_NORMAL, symbol);
entity->declaration.storage_class = STORAGE_CLASS_EXTERN;
entity->declaration.declared_storage_class = STORAGE_CLASS_EXTERN;
entity->declaration.type = type;
entity->declaration.implicit = true;
- entity->base.symbol = symbol;
entity->base.source_position = *source_position;
if (current_scope != NULL) {
}
/* otherwise we need to create a new one */
- label = allocate_entity_zero(ENTITY_LABEL, NAMESPACE_LABEL);
- label->base.symbol = symbol;
+ label = allocate_entity_zero(ENTITY_LABEL, NAMESPACE_LABEL, symbol);
label_push(label);
errorf(HERE, "multiple definitions of '__label__ %Y' (previous definition %P)",
symbol, &entity->base.source_position);
} else {
- entity = allocate_entity_zero(ENTITY_LOCAL_LABEL, NAMESPACE_LABEL);
+ entity = allocate_entity_zero(ENTITY_LOCAL_LABEL, NAMESPACE_LABEL, symbol);
entity->base.parent_scope = current_scope;
entity->base.source_position = token.source_position;
- entity->base.symbol = symbol;
*anchor = entity;
anchor = &entity->base.next;
}
if (entity == NULL) {
- entity = allocate_entity_zero(ENTITY_NAMESPACE, NAMESPACE_NORMAL);
- entity->base.symbol = symbol;
+ entity = allocate_entity_zero(ENTITY_NAMESPACE, NAMESPACE_NORMAL, symbol);
entity->base.source_position = token.source_position;
entity->base.parent_scope = current_scope;
}