(Ada) Fix Length attribute on array access
Consider the following variable "Indexed_By_Enum", declared as an access to an array whose index type is an enumerated type whose underlying values have "gaps": type Enum_With_Gaps is (LIT0, LIT1, LIT2, LIT3, LIT4); for Enum_With_Gaps use (LIT0 => 3, LIT1 => 5, LIT2 => 8, LIT3 => 13, LIT4 => 21); for Enum_With_Gaps'size use 16; type MyWord is range 0 .. 16#FFFF# ; for MyWord'Size use 16; type AR is array (Enum_With_Gaps range <>) of MyWord; type AR_Access is access AR; Indexed_By_Enum : AR_Access := new AR'(LIT1 => 1, LIT2 => 43, LIT3 => 42, LIT4 => 41); Trying to print the length (number of elements) of this array using the 'Length attribute does not work: (gdb) print indexed_by_enum'length 'POS only defined on discrete types The problem occurs while trying to get the array's index type. It was using TYPE_INDEX_TYPE for that. It does not work for Ada arrays in general; use ada_index_type instead. gdb/ChangeLog: * ada-lang.c (ada_array_length): Use ada_index_type instead of TYPE_INDEX_TYPE. gdb/testsuite/ChangeLog: * gdb.ada/arr_acc_idx_w_gap: New testcase. Tested on x86_64-linux.
This commit is contained in:
parent
cc0e770c0d
commit
7150d33cda
7 changed files with 166 additions and 1 deletions
|
@ -3179,7 +3179,7 @@ ada_array_length (struct value *arr, int n)
|
|||
}
|
||||
|
||||
arr_type = check_typedef (arr_type);
|
||||
index_type = TYPE_INDEX_TYPE (arr_type);
|
||||
index_type = ada_index_type (arr_type, n, "length");
|
||||
if (index_type != NULL)
|
||||
{
|
||||
struct type *base_type;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue