X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ast2firm.c;h=3bda2459d8f39b8a6275a328da4debeca136152b;hb=02f439ffe8745e3717a2404cbc04ae44b59f4f9e;hp=8348ecab5f40dde427dd95e48f83f3e12071b191;hpb=8572a4c7c6a20c50c27e7ea05309dd25e11c3859;p=cparser diff --git a/ast2firm.c b/ast2firm.c index 8348eca..3bda245 100644 --- a/ast2firm.c +++ b/ast2firm.c @@ -63,7 +63,7 @@ ir_node *uninitialized_local_var(ir_graph *irg, ir_mode *mode, int pos) { const declaration_t *declaration = get_irg_loc_description(irg, pos); - warningf(declaration->source_position, "variable '%#T' might be used uninitialized\n", + warningf(declaration->source_position, "variable '%#T' might be used uninitialized", declaration->type, declaration->symbol); return new_r_Unknown(irg, mode); } @@ -241,8 +241,8 @@ static void init_atomic_modes(void) { static ir_mode *get_atomic_mode(const atomic_type_t* atomic_type) { ir_mode *res = NULL; - if ((unsigned)atomic_type->atype < (unsigned)ATOMIC_TYPE_LAST) - res = _atomic_modes[(unsigned)atomic_type->atype]; + if ((unsigned)atomic_type->akind < (unsigned)ATOMIC_TYPE_LAST) + res = _atomic_modes[(unsigned)atomic_type->akind]; if (res == NULL) panic("Encountered unknown atomic type"); return res; @@ -252,7 +252,7 @@ static unsigned get_type_size(type_t *type); static unsigned get_atomic_type_size(const atomic_type_t *type) { - switch(type->atype) { + switch(type->akind) { case ATOMIC_TYPE_CHAR: case ATOMIC_TYPE_SCHAR: case ATOMIC_TYPE_UCHAR: @@ -361,8 +361,8 @@ static ir_type *create_atomic_type(const atomic_type_t *type) ident *id = get_mode_ident(mode); ir_type *irtype = new_type_primitive(id, mode); - if(type->atype == ATOMIC_TYPE_LONG_DOUBLE - || type->atype == ATOMIC_TYPE_DOUBLE) { + if(type->akind == ATOMIC_TYPE_LONG_DOUBLE + || type->akind == ATOMIC_TYPE_DOUBLE) { set_type_alignment_bytes(irtype, 4); } @@ -960,7 +960,7 @@ static ir_node *create_symconst(dbg_info *dbgi, ir_mode *mode, static ir_node *string_to_firm(const source_position_t *const src_pos, const char *const id_prefix, - const char *const string) + const string_t *const value) { ir_type *const global_type = get_glob_type(); ir_type *const type = new_type_array(unique_ident("strtype"), 1, @@ -976,7 +976,8 @@ static ir_node *string_to_firm(const source_position_t *const src_pos, ir_type *const elem_type = ir_type_const_char; ir_mode *const mode = get_type_mode(elem_type); - const size_t slen = strlen(string) + 1; + const char* const string = value->begin; + const size_t slen = value->size; set_array_lower_bound_int(type, 0, 0); set_array_upper_bound_int(type, 0, slen); @@ -998,7 +999,7 @@ static ir_node *string_literal_to_firm( const string_literal_expression_t* literal) { return string_to_firm(&literal->expression.source_position, "Lstr", - literal->value); + &literal->value); } static ir_node *wide_string_literal_to_firm( @@ -2289,7 +2290,7 @@ static ir_node *classify_type_to_firm(const classify_type_expression_t *const ex { case TYPE_ATOMIC: { const atomic_type_t *const atomic_type = &type->atomic; - switch (atomic_type->atype) { + switch (atomic_type->akind) { /* should not be reached */ case ATOMIC_TYPE_INVALID: tc = no_type_class; @@ -2366,7 +2367,8 @@ static ir_node *function_name_to_firm( const source_position_t *const src_pos = &expr->expression.source_position; const char *const name = current_function_decl->symbol->string; - current_function_name = string_to_firm(src_pos, "__func__", name); + const string_t string = { name, strlen(name) + 1 }; + current_function_name = string_to_firm(src_pos, "__func__", &string); } return current_function_name; @@ -2780,19 +2782,18 @@ static void create_initializer_string(initializer_string_t *initializer, entry.prev = last_entry; ++len; - ir_type *irtype = get_entity_type(entity); - size_t arr_len = get_array_type_size(type); - const char *p = initializer->string; - size_t i = 0; - for(i = 0; i < arr_len; ++i, ++p) { + ir_type *const irtype = get_entity_type(entity); + size_t arr_len = get_array_type_size(type); + const char *const p = initializer->string.begin; + if (initializer->string.size < arr_len) { + arr_len = initializer->string.size; + } + for (size_t i = 0; i < arr_len; ++i) { entry.v.array_index = i; - ir_node *node = new_Const_long(mode_Bs, *p); + ir_node *node = new_Const_long(mode_Bs, p[i]); compound_graph_path *path = create_compound_path(irtype, &entry, len); add_compound_ent_value_w_path(entity, node, path); - - if(*p == '\0') - break; } } @@ -3112,6 +3113,8 @@ static void declaration_statement_to_firm(declaration_statement_t *statement) declaration_t *declaration = statement->declarations_begin; declaration_t *end = statement->declarations_end->next; for( ; declaration != end; declaration = declaration->next) { + if(declaration->namespc != NAMESPACE_NORMAL) + continue; create_local_variable(declaration); } } @@ -3645,6 +3648,8 @@ static int count_local_declarations(const declaration_t * decl, { int count = 0; for (; decl != end; decl = decl->next) { + if(decl->namespc != NAMESPACE_NORMAL) + continue; const type_t *type = skip_typeref(decl->type); if (!decl->address_taken && is_type_scalar(type)) ++count;