X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ast2firm.c;h=46f2f19aad6cf2912fa3a1ef463ed0139b337433;hb=78cc65b14fc5c53a16368fe5975c70c83e969b19;hp=3bda2459d8f39b8a6275a328da4debeca136152b;hpb=0e0faae013a4302a0cc4f6e465301a82483e0a52;p=cparser diff --git a/ast2firm.c b/ast2firm.c index 3bda245..46f2f19 100644 --- a/ast2firm.c +++ b/ast2firm.c @@ -312,6 +312,8 @@ static unsigned get_type_size(type_t *type) type = skip_typeref(type); switch(type->kind) { + case TYPE_ERROR: + panic("error type occured"); case TYPE_ATOMIC: return get_atomic_type_size(&type->atomic); case TYPE_ENUM: @@ -547,7 +549,7 @@ static ir_type *create_struct_type(compound_type_t *type) size_t align_all = 1; size_t offset = 0; size_t bit_offset = 0; - declaration_t *entry = type->declaration->context.declarations; + declaration_t *entry = type->declaration->scope.declarations; for( ; entry != NULL; entry = entry->next) { if(entry->namespc != NAMESPACE_NORMAL) continue; @@ -650,7 +652,7 @@ static ir_type *create_union_type(compound_type_t *type) int align_all = 1; int size = 0; - declaration_t *entry = declaration->context.declarations; + declaration_t *entry = declaration->scope.declarations; for( ; entry != NULL; entry = entry->next) { if(entry->namespc != NAMESPACE_NORMAL) continue; @@ -733,6 +735,8 @@ static ir_type *get_ir_type(type_t *type) ir_type *firm_type = NULL; switch(type->kind) { + case TYPE_ERROR: + panic("error type occured"); case TYPE_ATOMIC: firm_type = create_atomic_type(&type->atomic); break; @@ -2692,7 +2696,7 @@ static void create_initializer_compound(initializer_list_t *initializer, { declaration_t *compound_declaration = type->declaration; - declaration_t *compound_entry = compound_declaration->context.declarations; + declaration_t *compound_entry = compound_declaration->scope.declarations; compound_graph_path_entry_t entry; entry.type = COMPOUND_GRAPH_ENTRY_COMPOUND; @@ -3064,7 +3068,7 @@ static ir_node *compound_statement_to_firm(compound_statement_t *compound) ir_node *result = NULL; statement_t *statement = compound->statements; for( ; statement != NULL; statement = statement->base.next) { - //context2firm(&statement->context); + //context2firm(&statement->scope); if(statement->base.next == NULL && statement->kind == STATEMENT_EXPRESSION) { @@ -3283,7 +3287,7 @@ static void for_statement_to_firm(for_statement_t *statement) } /* create declarations */ - declaration_t *declaration = statement->context.declarations; + declaration_t *declaration = statement->scope.declarations; for( ; declaration != NULL; declaration = declaration->next) { create_local_declaration(declaration); } @@ -3382,7 +3386,9 @@ static void switch_statement_to_firm(const switch_statement_t *statement) current_switch_cond = cond; break_label = break_block; - statement_to_firm(statement->body); + if (statement->body != NULL) { + statement_to_firm(statement->body); + } if(get_cur_block() != NULL) { ir_node *jmp = new_Jmp(); @@ -3744,7 +3750,7 @@ static int count_decls_in_stmts(const statement_t *stmt) case STATEMENT_FOR: { const for_statement_t *const for_stmt = &stmt->fors; - count += count_local_declarations(for_stmt->context.declarations, NULL); + count += count_local_declarations(for_stmt->scope.declarations, NULL); count += count_decls_in_expression(for_stmt->initialisation); count += count_decls_in_expression(for_stmt->condition); count += count_decls_in_expression(for_stmt->step); @@ -3789,7 +3795,7 @@ static int get_function_n_local_vars(declaration_t *declaration) int count = 0; /* count parameters */ - count += count_local_declarations(declaration->context.declarations, NULL); + count += count_local_declarations(declaration->scope.declarations, NULL); /* count local variables declared in body */ count += count_decls_in_stmts(declaration->init.statement); @@ -3805,7 +3811,7 @@ static void initialize_function_parameters(declaration_t *declaration) ir_type *function_irtype = get_ir_type(declaration->type); int n = 0; - declaration_t *parameter = declaration->context.declarations; + declaration_t *parameter = declaration->scope.declarations; for( ; parameter != NULL; parameter = parameter->next, ++n) { assert(parameter->declaration_kind == DECLARATION_KIND_UNKNOWN); type_t *type = skip_typeref(parameter->type); @@ -4032,10 +4038,10 @@ create_var: panic("Invalid storage class for global variable"); } -static void context_to_firm(context_t *context) +static void scope_to_firm(scope_t *scope) { /* first pass: create declarations */ - declaration_t *declaration = context->declarations; + declaration_t *declaration = scope->declarations; for( ; declaration != NULL; declaration = declaration->next) { if(declaration->namespc != NAMESPACE_NORMAL) continue; @@ -4054,7 +4060,7 @@ static void context_to_firm(context_t *context) } /* second pass: create code */ - declaration = context->declarations; + declaration = scope->declarations; for( ; declaration != NULL; declaration = declaration->next) { if(declaration->namespc != NAMESPACE_NORMAL) continue; @@ -4107,5 +4113,5 @@ void translation_unit_to_firm(translation_unit_t *unit) break_label = NULL; current_switch_cond = NULL; - context_to_firm(&unit->context); + scope_to_firm(&unit->scope); }