diff --git a/gcc/elna-generic.cc b/gcc/elna-generic.cc index 6626adb..2a0fbfb 100644 --- a/gcc/elna-generic.cc +++ b/gcc/elna-generic.cc @@ -810,21 +810,18 @@ namespace elna::gcc this->current_expression = error_mark_node; return; } - if (this->current_expression != elna_word_type_node) - { - this->current_expression = convert(elna_word_type_node, this->current_expression); - } - tree offset = build2(MINUS_EXPR, elna_word_type_node, this->current_expression, size_one_node); + tree offset = fold_convert(elna_word_type_node, this->current_expression); if (TREE_CODE(TREE_TYPE(designator)) == ARRAY_TYPE) { tree element_type = TREE_TYPE(TREE_TYPE(designator)); this->current_expression = build4_loc(location, - ARRAY_REF, element_type, designator, offset, NULL_TREE, NULL_TREE); + ARRAY_REF, element_type, designator, offset, size_one_node, NULL_TREE); } else if (TREE_TYPE(designator) == elna_string_type_node) { + offset = build2(MINUS_EXPR, elna_word_type_node, offset, size_one_node); tree string_ptr = build3_loc(location, COMPONENT_REF, TREE_TYPE(elna_string_ptr_field_node), designator, elna_string_ptr_field_node, NULL_TREE); diff --git a/gcc/elna-tree.cc b/gcc/elna-tree.cc index d00a39a..adc96d0 100644 --- a/gcc/elna-tree.cc +++ b/gcc/elna-tree.cc @@ -248,9 +248,8 @@ namespace elna::gcc tree build_static_array_type(tree type, const std::uint64_t size) { - tree lower_bound = build_int_cst_type(integer_type_node, 0); tree upper_bound = build_int_cst_type(integer_type_node, size); - tree range_type = build_range_type(integer_type_node, lower_bound, upper_bound); + tree range_type = build_range_type(integer_type_node, size_one_node, upper_bound); return build_array_type(type, range_type); }