Wrong type for 'Length result.
authorJoel Brobecker <brobecker@adacore.com>
Fri, 7 Feb 2014 04:44:20 +0000 (23:44 -0500)
committerJoel Brobecker <brobecker@adacore.com>
Mon, 10 Feb 2014 09:15:43 +0000 (13:15 +0400)
commitaa4fb036e90f5c976f57cd08f2c024cb0fe24897
tree60e0046ff631e59ebd0bef7cd86a68956fe4d617
parent9dee8cc6aa668228309de7d0e23e1775beb7d12f
Wrong type for 'Length result.

Consider the following code:

   type Color is (Black, Red, Green, Blue, White);
   type Primary_Table is array (Color range Red .. Blue) of Boolean;
   Prim : Primary_Table := (True, False, False);

GDB prints the length of arrays in a fairly odd way:

   (gdb) p prim'length
   $2 = blue

The length returned should be an integer, not the array index type,
and this patch fixes this.

gdb/ChangeLog:

* ada-lang.c (ada_evaluate_subexp): Set the type of the value
returned by the 'Length attribute to integer.

testsuite/ChangeLog:

* gdb.ada/tick_length_array_enum_idx: New testcase.
gdb/ChangeLog
gdb/ada-lang.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/tick_length_array_enum_idx.exp [new file with mode: 0644]
gdb/testsuite/gdb.ada/tick_length_array_enum_idx/foo_n207_004.adb [new file with mode: 0644]
gdb/testsuite/gdb.ada/tick_length_array_enum_idx/pck.adb [new file with mode: 0644]
gdb/testsuite/gdb.ada/tick_length_array_enum_idx/pck.ads [new file with mode: 0644]