+2020-02-25 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * gdbtypes.c (create_array_type_with_stride): Handle negative
+ array strides.
+ * valarith.c (value_subscripted_rvalue): Likewise.
+
2020-02-25 Luis Machado <luis.machado@linaro.org>
* aarch64-tdep.c (aarch64_vnv_type): Fix comment typo.
&& !type_not_allocated (result_type)))
{
LONGEST low_bound, high_bound;
- unsigned int stride;
+ int stride;
/* If the array itself doesn't provide a stride value then take
whatever stride the range provides. Don't update BIT_STRIDE as
In such cases, the array length should be zero. */
if (high_bound < low_bound)
TYPE_LENGTH (result_type) = 0;
- else if (stride > 0)
- TYPE_LENGTH (result_type) =
- (stride * (high_bound - low_bound + 1) + 7) / 8;
+ else if (stride != 0)
+ {
+ /* Ensure that the type length is always positive, even in the
+ case where (for example in Fortran) we have a negative
+ stride. It is possible to have a single element array with a
+ negative stride in Fortran (this doesn't mean anything
+ special, it's still just a single element array) so do
+ consider that case when touching this code. */
+ LONGEST element_count = abs (high_bound - low_bound + 1);
+ TYPE_LENGTH (result_type)
+ = ((abs (stride) * element_count) + 7) / 8;
+ }
else
TYPE_LENGTH (result_type) =
TYPE_LENGTH (element_type) * (high_bound - low_bound + 1);
+2020-02-25 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * gdb.fortran/derived-type-striding.exp: Add a new test.
+ * gdb.fortran/derived-type-striding.f90: Add pointer variable for
+ new test.
+
2020-02-25 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.base/cached-source-file.exp: Avoid source file paths in test
# Test mixed type derived type.
if { $gcc_with_broken_stride } { setup_kfail *-*-* gcc/92775 }
gdb_test "p point_mixed_dimension" "= \\\(3, 3, 3, 3\\\)"
+
+gdb_test "p cloud_slice" " = \\\(\\\( x = 1, y = 2, z = 3 \\\)\\\)"
type(mixed_cartesian), dimension(10), target :: mixed_cloud
integer(kind=8), dimension(:), pointer :: point_dimension => null()
integer(kind=8), dimension(:), pointer :: point_mixed_dimension => null()
+ type(cartesian), dimension(:), pointer :: cloud_slice => null()
cloud(:)%x = 1
cloud(:)%y = 2
cloud(:)%z = 3
+ cloud_slice => cloud(3:2:-2)
point_dimension => cloud(1:9)%y
mixed_cloud(:)%x = 1
mixed_cloud(:)%y = 2
{
struct type *array_type = check_typedef (value_type (array));
struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
- ULONGEST elt_size = type_length_units (elt_type);
+ LONGEST elt_size = type_length_units (elt_type);
/* Fetch the bit stride and convert it to a byte stride, assuming 8 bits
in a byte. */
elt_size = stride / (unit_size * 8);
}
- ULONGEST elt_offs = elt_size * (index - lowerbound);
+ LONGEST elt_offs = elt_size * (index - lowerbound);
if (index < lowerbound
|| (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)