Use array range beginning with one

This commit is contained in:
2025-07-17 11:44:42 +02:00
parent 34abb6b4f5
commit d5c7007a81
3 changed files with 362 additions and 366 deletions

View File

@@ -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);