Fix bit strides for -fgnat-encodings=minimal

With -fgnat-encodings=minimal, the enum_idx_packed.exp test will fail.
In this test case, we have an array (with dynamic length) of arrays,
and the inner array has a bit stride.  In this situation, the outer
array's bit stride must be updated to account for the entire bit
length of the inner array.

Here, again, some tests must be kfail'd when an older version of GNAT
is in use.

gdb/ChangeLog
2020-11-04  Tom Tromey  <tromey@adacore.com>

	* gdbtypes.c (update_static_array_size): Handle bit stride.

gdb/testsuite/ChangeLog
2020-11-04  Tom Tromey  <tromey@adacore.com>

	* gdb.ada/enum_idx_packed.exp: Test two forms of -fgnat-encodings.
This commit is contained in:
Tom Tromey
2020-11-04 08:49:16 -07:00
parent 24aa1b0282
commit b72795a8f5
4 changed files with 119 additions and 58 deletions

View File

@ -1241,6 +1241,20 @@ update_static_array_size (struct type *type)
TYPE_LENGTH (type) =
TYPE_LENGTH (element_type) * (high_bound - low_bound + 1);
/* If this array's element is itself an array with a bit stride,
then we want to update this array's bit stride to reflect the
size of the sub-array. Otherwise, we'll end up using the
wrong size when trying to find elements of the outer
array. */
if (element_type->code () == TYPE_CODE_ARRAY
&& TYPE_LENGTH (element_type) != 0
&& TYPE_FIELD_BITSIZE (element_type, 0) != 0
&& get_array_bounds (element_type, &low_bound, &high_bound) >= 0
&& high_bound >= low_bound)
TYPE_FIELD_BITSIZE (type, 0)
= ((high_bound - low_bound + 1)
* TYPE_FIELD_BITSIZE (element_type, 0));
return true;
}