summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0db4989)
In Ada, the 'val and 'pos attributes can be used to map from an
enumeration constant to its position in the enum and vice versa.
These operators did not work properly when the type in question was a
subrange of an enum type with "holes".
gdb/ChangeLog
2020-05-26 Tom Tromey <tromey@adacore.com>
* ada-lang.c (value_val_atr): Handle TYPE_CODE_RANGE.
* gdbtypes.c (discrete_position): Handle TYPE_CODE_RANGE.
gdb/testsuite/ChangeLog
2020-05-26 Tom Tromey <tromey@adacore.com>
* gdb.ada/arr_acc_idx_w_gap.exp: Add enum subrange tests.
* gdb.ada/arr_acc_idx_w_gap/enum_with_gap.ads (Enum_Subrange): New
type.
* gdb.ada/arr_acc_idx_w_gap/enum_with_gap_main.adb (V): New
variable.
+2020-05-26 Tom Tromey <tromey@adacore.com>
+
+ * ada-lang.c (value_val_atr): Handle TYPE_CODE_RANGE.
+ * gdbtypes.c (discrete_position): Handle TYPE_CODE_RANGE.
+
2020-05-25 Cristiano De Alti <cristiano_dealti@hotmail.com>
PR gdb/13519
2020-05-25 Cristiano De Alti <cristiano_dealti@hotmail.com>
PR gdb/13519
if (!integer_type_p (value_type (arg)))
error (_("'VAL requires integral argument"));
if (!integer_type_p (value_type (arg)))
error (_("'VAL requires integral argument"));
+ if (type->code () == TYPE_CODE_RANGE)
+ type = TYPE_TARGET_TYPE (type);
+
if (type->code () == TYPE_CODE_ENUM)
{
long pos = value_as_long (arg);
if (type->code () == TYPE_CODE_ENUM)
{
long pos = value_as_long (arg);
int
discrete_position (struct type *type, LONGEST val, LONGEST *pos)
{
int
discrete_position (struct type *type, LONGEST val, LONGEST *pos)
{
+ if (type->code () == TYPE_CODE_RANGE)
+ type = TYPE_TARGET_TYPE (type);
+
if (type->code () == TYPE_CODE_ENUM)
{
int i;
if (type->code () == TYPE_CODE_ENUM)
{
int i;
+2020-05-26 Tom Tromey <tromey@adacore.com>
+
+ * gdb.ada/arr_acc_idx_w_gap.exp: Add enum subrange tests.
+ * gdb.ada/arr_acc_idx_w_gap/enum_with_gap.ads (Enum_Subrange): New
+ type.
+ * gdb.ada/arr_acc_idx_w_gap/enum_with_gap_main.adb (V): New
+ variable.
+
2020-05-26 Christian Biesinger <cbiesinger@google.com>
* Makefile.in: Use = instead of == for the test command
2020-05-26 Christian Biesinger <cbiesinger@google.com>
* Makefile.in: Use = instead of == for the test command
" = \\(lit2 => 43, 42, 41\\)"
gdb_test "print s(2..4)" \
" = \"ell\""
" = \\(lit2 => 43, 42, 41\\)"
gdb_test "print s(2..4)" \
" = \"ell\""
+
+gdb_test "print v" " = lit3"
+gdb_test "print enum_subrange'pos(v)" " = 3"
+gdb_test "print enum_subrange'val(3)" " = lit3"
);
for Enum_With_Gaps'size use 16;
);
for Enum_With_Gaps'size use 16;
+ type Enum_Subrange is new Enum_With_Gaps range Lit1 .. Lit3;
+
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;
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;
type String_Access is access String;
type String_Access is access String;
procedure Do_Nothing (E : AR_Access);
procedure Do_Nothing (E : String_Access);
procedure Do_Nothing (E : AR_Access);
procedure Do_Nothing (E : String_Access);
Indexed_By_Enum : AR_Access :=
new AR'(LIT1 => 1, LIT2 => 43, LIT3 => 42, LIT4 => 41);
S : String_Access := new String'("Hello!");
Indexed_By_Enum : AR_Access :=
new AR'(LIT1 => 1, LIT2 => 43, LIT3 => 42, LIT4 => 41);
S : String_Access := new String'("Hello!");
+ V : Enum_Subrange := LIT3;
begin
Do_Nothing (Indexed_By_Enum); -- BREAK
Do_Nothing (S);
begin
Do_Nothing (Indexed_By_Enum); -- BREAK
Do_Nothing (S);