aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gcc/elna-tree.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/gcc/elna-tree.cc b/gcc/gcc/elna-tree.cc
index 9612ae2..afc809b 100644
--- a/gcc/gcc/elna-tree.cc
+++ b/gcc/gcc/elna-tree.cc
@@ -138,11 +138,14 @@ namespace elna::gcc
convert_expression = fold_build1(NEGATE_EXPR, size_type_node, convert_expression);
return fold_build2_loc(operation_location, POINTER_PLUS_EXPR, pointer_type, left, convert_expression);
}
- else if (POINTER_TYPE_P(left_type) && POINTER_TYPE_P(right_type) && left_type == right_type)
+ else if (POINTER_TYPE_P(left_type) && POINTER_TYPE_P(right_type))
{
- return fold_build2_loc(operation_location, POINTER_DIFF_EXPR, ptrdiff_type_node, left, right);
+ tree size_exp = pointer_stride(left_type, ptrdiff_type_node);
+ tree diff = fold_build2_loc(operation_location, POINTER_DIFF_EXPR, ptrdiff_type_node, left, right);
+
+ return fold_build2_loc(operation_location, EXACT_DIV_EXPR, ptrdiff_type_node, diff, size_exp);
}
- return error_mark_node;
+ gcc_unreachable();
}
gcc_unreachable();
}