Add multiple of the pointer target size
This commit is contained in:
@ -74,15 +74,7 @@ namespace gcc
|
||||
{
|
||||
auto body_type = build_type(expression->body());
|
||||
|
||||
this->current_expression = build1(CONVERT_EXPR, this->symbol_map->lookup("Word"), TYPE_SIZE_UNIT(body_type));
|
||||
}
|
||||
|
||||
bool generic_visitor::is_integral_type(tree type)
|
||||
{
|
||||
gcc_assert(TYPE_P(type));
|
||||
|
||||
return type == this->symbol_map->lookup("Int")
|
||||
|| type == this->symbol_map->lookup("Word");
|
||||
this->current_expression = build1(CONVERT_EXPR, this->symbol_map->lookup("Word"), size_in_bytes(body_type));
|
||||
}
|
||||
|
||||
bool generic_visitor::is_numeric_type(tree type)
|
||||
@ -333,7 +325,9 @@ namespace gcc
|
||||
|
||||
location_t expression_location = get_location(&expression->position());
|
||||
|
||||
if (is_pointer_type(left_type) && is_integral_type(right_type))
|
||||
if ((is_pointer_type(left_type) || is_pointer_type(right_type))
|
||||
&& (expression->operation() == boot::binary_operator::sum
|
||||
|| expression->operation() == boot::binary_operator::subtraction))
|
||||
{
|
||||
this->current_expression = do_pointer_arithmetic(expression->operation(), left, right);
|
||||
if (this->current_expression == error_mark_node)
|
||||
@ -342,6 +336,10 @@ namespace gcc
|
||||
"invalid operation %s on a pointer and an integral type",
|
||||
boot::print_binary_operator(expression->operation()));
|
||||
}
|
||||
else if (TREE_TYPE(this->current_expression) == ssizetype)
|
||||
{
|
||||
this->current_expression = fold_convert(this->symbol_map->lookup("Int"), this->current_expression);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (left_type != right_type && !are_compatible_pointers(left, right))
|
||||
|
Reference in New Issue
Block a user