Implement adding an integer to a pointer
This commit is contained in:
@ -42,6 +42,10 @@ namespace gcc
|
||||
{
|
||||
format_number = "%d\n";
|
||||
}
|
||||
else if (argument_type == unsigned_type_node)
|
||||
{
|
||||
format_number = "%u\n";
|
||||
}
|
||||
else if (argument_type == double_type_node)
|
||||
{
|
||||
format_number = "%f\n";
|
||||
@ -316,6 +320,16 @@ namespace gcc
|
||||
tree_code operator_code = ERROR_MARK;
|
||||
tree target_type = error_mark_node;
|
||||
|
||||
if (is_pointer_type(left_type)
|
||||
&& (right_type == integer_type_node || right_type == unsigned_type_node)
|
||||
&& expression->operation() == source::binary_operator::sum)
|
||||
{
|
||||
tree convert_expression = build1_loc(expression_location, CONVERT_EXPR,
|
||||
sizetype, right);
|
||||
this->current_expression = build2_loc(expression_location,
|
||||
POINTER_PLUS_EXPR, left_type, left, convert_expression);
|
||||
return;
|
||||
}
|
||||
if (left_type != right_type)
|
||||
{
|
||||
error_at(expression_location,
|
||||
|
Reference in New Issue
Block a user