Use array range beginning with one
This commit is contained in:
@ -154,7 +154,9 @@ namespace elna::gcc
|
||||
}
|
||||
else if (constant_expression != boolean_true_node)
|
||||
{
|
||||
this->current_expression = call_built_in(call_location, "__builtin_trap", void_type_node);
|
||||
tree assert_expression = call_built_in(call_location, "__builtin_trap", void_type_node);
|
||||
this->current_expression = build3(COND_EXPR, void_type_node, this->current_expression,
|
||||
NULL_TREE, assert_expression);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -486,7 +488,6 @@ namespace elna::gcc
|
||||
{
|
||||
gcc_unreachable();
|
||||
}
|
||||
|
||||
if (left_type == elna_bool_type_node)
|
||||
{
|
||||
return build2_loc(expression_location, logical_code, elna_bool_type_node, left, right);
|
||||
@ -497,8 +498,7 @@ namespace elna::gcc
|
||||
}
|
||||
else
|
||||
{
|
||||
error_at(expression_location,
|
||||
"Invalid operands of type '%s' and '%s' for operator %s",
|
||||
error_at(expression_location, "Invalid operands of type '%s' and '%s' for operator %s",
|
||||
print_type(left_type).c_str(), print_type(right_type).c_str(),
|
||||
elna::boot::print_binary_operator(expression->operation()));
|
||||
return error_mark_node;
|
||||
@ -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);
|
||||
|
||||
|
@ -21,7 +21,6 @@ along with GCC; see the file COPYING3. If not see
|
||||
|
||||
#include "function.h"
|
||||
#include "stor-layout.h"
|
||||
#include "fold-const.h"
|
||||
#include "diagnostic-core.h"
|
||||
|
||||
namespace elna::gcc
|
||||
@ -248,9 +247,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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user